Class BufferedKVExternalSorter
java.lang.Object
org.apache.flink.table.runtime.operators.sort.BufferedKVExternalSorter
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 Summary
ConstructorsConstructorDescriptionBufferedKVExternalSorter(org.apache.flink.runtime.io.disk.iomanager.IOManager ioManager, BinaryRowDataSerializer keySerializer, BinaryRowDataSerializer valueSerializer, NormalizedKeyComputer nKeyComputer, RecordComparator comparator, int pageSize, int maxNumFileHandles, boolean compressionEnabled, int compressionBlockSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()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>> voidsortAndSpill(ArrayList<org.apache.flink.core.memory.MemorySegment> recordBufferSegments, long numElements, MemorySegmentPool pool)
-
Constructor Details
-
BufferedKVExternalSorter
public BufferedKVExternalSorter(org.apache.flink.runtime.io.disk.iomanager.IOManager ioManager, BinaryRowDataSerializer keySerializer, BinaryRowDataSerializer valueSerializer, NormalizedKeyComputer nKeyComputer, RecordComparator comparator, int pageSize, int maxNumFileHandles, boolean compressionEnabled, int compressionBlockSize)
-
-
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()
-