Class BufferedKVExternalSorter

java.lang.Object
org.apache.flink.table.runtime.operators.sort.BufferedKVExternalSorter

public class BufferedKVExternalSorter extends Object
Sorter for buffered input in the form of Key-Value Style. First, sort and spill buffered inputs (without data copy, just write index and normalized key). Second, merge disk outputs and return iterator.

For Hash Aggregation:We store the data in MemorySegmentHashTable in KeyValue format. When memory is not enough, we spill all the data in memory onto disk and degenerate it into Sort Aggregation. So we need a BufferedKVExternalSorter to write the data that already in memory to disk, and then carry out SortMerge.

  • Constructor Details

  • Method Details

    • getKVIterator

      public org.apache.flink.util.MutableObjectIterator<org.apache.flink.api.java.tuple.Tuple2<org.apache.flink.table.data.binary.BinaryRowData,org.apache.flink.table.data.binary.BinaryRowData>> getKVIterator() throws IOException
      Throws:
      IOException
    • sortAndSpill

      public void sortAndSpill(ArrayList<org.apache.flink.core.memory.MemorySegment> recordBufferSegments, long numElements, MemorySegmentPool pool) throws IOException
      Throws:
      IOException
    • close

      public void close()