Class NormalizedKeySorter<T>
java.lang.Object
org.apache.flink.runtime.operators.sort.NormalizedKeySorter<T>
- All Implemented Interfaces:
IndexedSortable,InMemorySorter<T>,org.apache.flink.util.Disposable
-
Constructor Summary
ConstructorsConstructorDescriptionNormalizedKeySorter(org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer, org.apache.flink.api.common.typeutils.TypeComparator<T> comparator, List<org.apache.flink.core.memory.MemorySegment> memory) NormalizedKeySorter(org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer, org.apache.flink.api.common.typeutils.TypeComparator<T> comparator, List<org.apache.flink.core.memory.MemorySegment> memory, int maxNormalizedKeyBytes) -
Method Summary
Modifier and TypeMethodDescriptionintcompare(int i, int j) Compare items at the given addresses consistent with the semantics ofComparator.compare(Object, Object).intcompare(int segmentNumberI, int segmentOffsetI, int segmentNumberJ, int segmentOffsetJ) Compare records at the given addresses consistent with the semantics ofComparator.compare(Object, Object).voiddispose()Disposes the sorter.longGets the total capacity of this sorter, in bytes.final org.apache.flink.util.MutableObjectIterator<T>Gets an iterator over all records in this buffer in their logical order.longGets the number of bytes currently occupied in this sorter, records and sort index.getRecord(int logicalPosition) Gets the record at the given logical position.Gets the record at the given logical position.booleanisEmpty()Checks whether the buffer is empty.intGets the size of each record, the number of bytes separating the head of successive records.intGets the number of elements in each memory segment.voidreset()Resets the sort buffer back to the state where it is empty.intsize()Gets the number of elements in the sortable.voidswap(int i, int j) Swap items at the given addresses.voidswap(int segmentNumberI, int segmentOffsetI, int segmentNumberJ, int segmentOffsetJ) Swap records at the given addresses.booleanWrites a given record to this sort buffer.voidwriteToOutput(ChannelWriterOutputView output) Writes the records in this buffer in their logical order to the given output.voidwriteToOutput(ChannelWriterOutputView output, int start, int num) Writes a subset of the records in this buffer in their logical order to the given output.voidwriteToOutput(ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput)
-
Constructor Details
-
NormalizedKeySorter
-
NormalizedKeySorter
-
-
Method Details
-
recordSize
public int recordSize()Description copied from interface:IndexedSortableGets the size of each record, the number of bytes separating the head of successive records.- Specified by:
recordSizein interfaceIndexedSortable- Returns:
- The record size
-
recordsPerSegment
public int recordsPerSegment()Description copied from interface:IndexedSortableGets the number of elements in each memory segment.- Specified by:
recordsPerSegmentin interfaceIndexedSortable- Returns:
- The number of records per segment
-
reset
public void reset()Resets the sort buffer back to the state where it is empty. All contained data is discarded.- Specified by:
resetin interfaceInMemorySorter<T>
-
isEmpty
public boolean isEmpty()Checks whether the buffer is empty.- Specified by:
isEmptyin interfaceInMemorySorter<T>- Returns:
- True, if no record is contained, false otherwise.
-
dispose
public void dispose()Description copied from interface:InMemorySorterDisposes the sorter. This method does not release the memory segments used by the sorter.- Specified by:
disposein interfaceorg.apache.flink.util.Disposable- Specified by:
disposein interfaceInMemorySorter<T>
-
getCapacity
public long getCapacity()Description copied from interface:InMemorySorterGets the total capacity of this sorter, in bytes.- Specified by:
getCapacityin interfaceInMemorySorter<T>- Returns:
- The sorter's total capacity.
-
getOccupancy
public long getOccupancy()Description copied from interface:InMemorySorterGets the number of bytes currently occupied in this sorter, records and sort index.- Specified by:
getOccupancyin interfaceInMemorySorter<T>- Returns:
- The number of bytes occupied.
-
getRecord
Description copied from interface:InMemorySorterGets the record at the given logical position.- Specified by:
getRecordin interfaceInMemorySorter<T>- Parameters:
logicalPosition- The logical position of the record.- Throws:
IOException- Thrown, if an exception occurred during deserialization.
-
getRecord
Description copied from interface:InMemorySorterGets the record at the given logical position.- Specified by:
getRecordin interfaceInMemorySorter<T>- Parameters:
reuse- The reuse object to deserialize the record into.logicalPosition- The logical position of the record.- Throws:
IOException- Thrown, if an exception occurred during deserialization.
-
write
Writes a given record to this sort buffer. The written record will be appended and take the last logical position.- Specified by:
writein interfaceInMemorySorter<T>- Parameters:
record- The record to be written.- Returns:
- True, if the record was successfully written, false, if the sort buffer was full.
- Throws:
IOException- Thrown, if an error occurred while serializing the record into the buffers.
-
compare
public int compare(int i, int j) Description copied from interface:IndexedSortableCompare items at the given addresses consistent with the semantics ofComparator.compare(Object, Object).- Specified by:
comparein interfaceIndexedSortable
-
compare
public int compare(int segmentNumberI, int segmentOffsetI, int segmentNumberJ, int segmentOffsetJ) Description copied from interface:IndexedSortableCompare records at the given addresses consistent with the semantics ofComparator.compare(Object, Object).- Specified by:
comparein interfaceIndexedSortable- Parameters:
segmentNumberI- index of memory segment containing first recordsegmentOffsetI- offset into memory segment containing first recordsegmentNumberJ- index of memory segment containing second recordsegmentOffsetJ- offset into memory segment containing second record- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
-
swap
public void swap(int i, int j) Description copied from interface:IndexedSortableSwap items at the given addresses.- Specified by:
swapin interfaceIndexedSortable
-
swap
public void swap(int segmentNumberI, int segmentOffsetI, int segmentNumberJ, int segmentOffsetJ) Description copied from interface:IndexedSortableSwap records at the given addresses.- Specified by:
swapin interfaceIndexedSortable- Parameters:
segmentNumberI- index of memory segment containing first recordsegmentOffsetI- offset into memory segment containing first recordsegmentNumberJ- index of memory segment containing second recordsegmentOffsetJ- offset into memory segment containing second record
-
size
public int size()Description copied from interface:IndexedSortableGets the number of elements in the sortable.- Specified by:
sizein interfaceIndexedSortable- Returns:
- The number of elements.
-
getIterator
Gets an iterator over all records in this buffer in their logical order.- Specified by:
getIteratorin interfaceInMemorySorter<T>- Returns:
- An iterator returning the records in their logical order.
-
writeToOutput
Writes the records in this buffer in their logical order to the given output.- Specified by:
writeToOutputin interfaceInMemorySorter<T>- Parameters:
output- The output view to write the records to.- Throws:
IOException- Thrown, if an I/O exception occurred writing to the output view.
-
writeToOutput
public void writeToOutput(ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput) throws IOException - Specified by:
writeToOutputin interfaceInMemorySorter<T>- Throws:
IOException
-
writeToOutput
Writes a subset of the records in this buffer in their logical order to the given output.- Specified by:
writeToOutputin interfaceInMemorySorter<T>- Parameters:
output- The output view to write the records to.start- The logical start position of the subset.num- The number of elements to write.- Throws:
IOException- Thrown, if an I/O exception occurred writing to the output view.
-