Class BinaryIndexedSortable
- java.lang.Object
-
- org.apache.flink.table.runtime.operators.sort.BinaryIndexedSortable
-
- All Implemented Interfaces:
IndexedSortable
- Direct Known Subclasses:
BinaryInMemorySortBuffer
,BinaryKVInMemorySortBuffer
public abstract class BinaryIndexedSortable extends Object implements IndexedSortable
abstract sortable, provide basic compare and swap. Support writing of index and normalizedKey.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
currentSortIndexOffset
protected MemorySegment
currentSortIndexSegment
protected int
indexEntrySize
protected int
lastIndexEntryOffset
protected MemorySegmentPool
memorySegmentPool
protected int
numRecords
static int
OFFSET_LEN
protected RandomAccessInputView
recordBuffer
protected BinaryRowData
row1
protected BinaryRowDataSerializer
serializer
protected BinaryRowDataSerializer
serializer1
protected ArrayList<MemorySegment>
sortIndex
-
Constructor Summary
Constructors Constructor Description BinaryIndexedSortable(NormalizedKeyComputer normalizedKeyComputer, BinaryRowDataSerializer serializer, RecordComparator comparator, ArrayList<MemorySegment> recordBufferSegments, MemorySegmentPool memorySegmentPool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkNextIndexOffset()
check if we need request next index memory.int
compare(int i, int j)
Compare items at the given addresses consistent with the semantics ofComparator.compare(Object, Object)
.int
compare(int segmentNumberI, int segmentOffsetI, int segmentNumberJ, int segmentOffsetJ)
Compare records at the given addresses consistent with the semantics ofComparator.compare(Object, Object)
.protected MemorySegment
nextMemorySegment()
int
recordSize()
Gets the size of each record, the number of bytes separating the head of successive records.int
recordsPerSegment()
Gets the number of elements in each memory segment.int
size()
Gets the number of elements in the sortable.void
swap(int i, int j)
Swap items at the given addresses.void
swap(int segmentNumberI, int segmentOffsetI, int segmentNumberJ, int segmentOffsetJ)
Swap records at the given addresses.protected void
writeIndexAndNormalizedKey(RowData record, long currOffset)
Write of index and normalizedKey.void
writeToOutput(AbstractPagedOutputView output)
Spill: Write all records to aAbstractPagedOutputView
.
-
-
-
Field Detail
-
OFFSET_LEN
public static final int OFFSET_LEN
- See Also:
- Constant Field Values
-
serializer
protected final BinaryRowDataSerializer serializer
-
recordBuffer
protected final RandomAccessInputView recordBuffer
-
currentSortIndexSegment
protected MemorySegment currentSortIndexSegment
-
memorySegmentPool
protected final MemorySegmentPool memorySegmentPool
-
sortIndex
protected final ArrayList<MemorySegment> sortIndex
-
indexEntrySize
protected final int indexEntrySize
-
lastIndexEntryOffset
protected final int lastIndexEntryOffset
-
serializer1
protected final BinaryRowDataSerializer serializer1
-
row1
protected final BinaryRowData row1
-
currentSortIndexOffset
protected int currentSortIndexOffset
-
numRecords
protected int numRecords
-
-
Constructor Detail
-
BinaryIndexedSortable
public BinaryIndexedSortable(NormalizedKeyComputer normalizedKeyComputer, BinaryRowDataSerializer serializer, RecordComparator comparator, ArrayList<MemorySegment> recordBufferSegments, MemorySegmentPool memorySegmentPool)
-
-
Method Detail
-
nextMemorySegment
protected MemorySegment nextMemorySegment()
-
checkNextIndexOffset
protected boolean checkNextIndexOffset()
check if we need request next index memory.
-
writeIndexAndNormalizedKey
protected void writeIndexAndNormalizedKey(RowData record, long currOffset)
Write of index and normalizedKey.
-
compare
public int compare(int i, int j)
Description copied from interface:IndexedSortable
Compare items at the given addresses consistent with the semantics ofComparator.compare(Object, Object)
.- Specified by:
compare
in interfaceIndexedSortable
-
compare
public int compare(int segmentNumberI, int segmentOffsetI, int segmentNumberJ, int segmentOffsetJ)
Description copied from interface:IndexedSortable
Compare records at the given addresses consistent with the semantics ofComparator.compare(Object, Object)
.- Specified by:
compare
in 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:IndexedSortable
Swap items at the given addresses.- Specified by:
swap
in interfaceIndexedSortable
-
swap
public void swap(int segmentNumberI, int segmentOffsetI, int segmentNumberJ, int segmentOffsetJ)
Description copied from interface:IndexedSortable
Swap records at the given addresses.- Specified by:
swap
in 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:IndexedSortable
Gets the number of elements in the sortable.- Specified by:
size
in interfaceIndexedSortable
- Returns:
- The number of elements.
-
recordSize
public int recordSize()
Description copied from interface:IndexedSortable
Gets the size of each record, the number of bytes separating the head of successive records.- Specified by:
recordSize
in interfaceIndexedSortable
- Returns:
- The record size
-
recordsPerSegment
public int recordsPerSegment()
Description copied from interface:IndexedSortable
Gets the number of elements in each memory segment.- Specified by:
recordsPerSegment
in interfaceIndexedSortable
- Returns:
- The number of records per segment
-
writeToOutput
public void writeToOutput(AbstractPagedOutputView output) throws IOException
Spill: Write all records to aAbstractPagedOutputView
.- Throws:
IOException
-
-