public final class FixedLengthRecordSorter<T> extends Object implements InMemorySorter<T>
Constructor and Description |
---|
FixedLengthRecordSorter(TypeSerializer<T> serializer,
TypeComparator<T> comparator,
List<MemorySegment> memory) |
Modifier and Type | Method and Description |
---|---|
int |
compare(int i,
int j)
Compare items at the given addresses consistent with the semantics of
Comparator.compare(Object, Object) . |
void |
dispose()
Disposes the sorter.
|
long |
getCapacity()
Gets the total capacity of this sorter, in bytes.
|
MutableObjectIterator<T> |
getIterator()
Gets an iterator over all records in this buffer in their logical order.
|
long |
getOccupancy()
Gets the number of bytes currently occupied in this sorter, records and sort index.
|
T |
getRecord(int logicalPosition)
Gets the record at the given logical position.
|
T |
getRecord(T reuse,
int logicalPosition)
Gets the record at the given logical position.
|
boolean |
isEmpty()
Checks whether the buffer is empty.
|
void |
reset()
Resets the sort buffer back to the state where it is empty.
|
int |
size()
Gets the number of elements in the sortable.
|
void |
swap(int i,
int j)
Swap items at the given addresses.
|
boolean |
write(T record)
Writes a given record to this sort buffer.
|
void |
writeToOutput(ChannelWriterOutputView output)
Writes the records in this buffer in their logical order to the given output.
|
void |
writeToOutput(ChannelWriterOutputView output,
int start,
int num)
Writes a subset of the records in this buffer in their logical order to the given output.
|
void |
writeToOutput(ChannelWriterOutputView output,
LargeRecordHandler<T> largeRecordsOutput) |
public FixedLengthRecordSorter(TypeSerializer<T> serializer, TypeComparator<T> comparator, List<MemorySegment> memory)
public void reset()
reset
in interface InMemorySorter<T>
public boolean isEmpty()
isEmpty
in interface InMemorySorter<T>
public void dispose()
InMemorySorter
dispose
in interface InMemorySorter<T>
public long getCapacity()
InMemorySorter
getCapacity
in interface InMemorySorter<T>
public long getOccupancy()
InMemorySorter
getOccupancy
in interface InMemorySorter<T>
public T getRecord(int logicalPosition) throws IOException
InMemorySorter
getRecord
in interface InMemorySorter<T>
logicalPosition
- The logical position of the record.IOException
- Thrown, if an exception occurred during deserialization.public T getRecord(T reuse, int logicalPosition) throws IOException
InMemorySorter
getRecord
in interface InMemorySorter<T>
reuse
- The reuse object to deserialize the record into.logicalPosition
- The logical position of the record.IOException
- Thrown, if an exception occurred during deserialization.public boolean write(T record) throws IOException
write
in interface InMemorySorter<T>
record
- The record to be written.IOException
- Thrown, if an error occurred while serializing the record into the buffers.public int compare(int i, int j)
IndexedSortable
Comparator.compare(Object, Object)
.compare
in interface IndexedSortable
public void swap(int i, int j)
IndexedSortable
swap
in interface IndexedSortable
public int size()
IndexedSortable
size
in interface IndexedSortable
public final MutableObjectIterator<T> getIterator()
getIterator
in interface InMemorySorter<T>
public void writeToOutput(ChannelWriterOutputView output) throws IOException
writeToOutput
in interface InMemorySorter<T>
output
- The output view to write the records to.IOException
- Thrown, if an I/O exception occurred writing to the output view.public void writeToOutput(ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput) throws IOException
writeToOutput
in interface InMemorySorter<T>
IOException
public void writeToOutput(ChannelWriterOutputView output, int start, int num) throws IOException
writeToOutput
in interface InMemorySorter<T>
output
- The output view to write the records to.start
- The logical start position of the subset.num
- The number of elements to write.IOException
- Thrown, if an I/O exception occurred writing to the output view.Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.