Interface InMemorySorter<T>

All Superinterfaces:
org.apache.flink.util.Disposable, IndexedSortable
All Known Implementing Classes:
FixedLengthRecordSorter, NormalizedKeySorter

public interface InMemorySorter<T> extends IndexedSortable, org.apache.flink.util.Disposable
  • Method Details

    • reset

      void reset()
      Resets the sort buffer back to the state where it is empty. All contained data is discarded.
    • isEmpty

      boolean isEmpty()
      Checks whether the buffer is empty.
      Returns:
      True, if no record is contained, false otherwise.
    • dispose

      void dispose()
      Disposes the sorter. This method does not release the memory segments used by the sorter.
      Specified by:
      dispose in interface org.apache.flink.util.Disposable
    • getCapacity

      long getCapacity()
      Gets the total capacity of this sorter, in bytes.
      Returns:
      The sorter's total capacity.
    • getOccupancy

      long getOccupancy()
      Gets the number of bytes currently occupied in this sorter, records and sort index.
      Returns:
      The number of bytes occupied.
    • getRecord

      T getRecord(int logicalPosition) throws IOException
      Gets the record at the given logical position.
      Parameters:
      logicalPosition - The logical position of the record.
      Throws:
      IOException - Thrown, if an exception occurred during deserialization.
    • getRecord

      T getRecord(T reuse, int logicalPosition) throws IOException
      Gets the record at the given logical position.
      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

      boolean write(T record) throws IOException
      Writes a given record to this sort buffer. The written record will be appended and take the last logical position.
      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.
    • getIterator

      org.apache.flink.util.MutableObjectIterator<T> getIterator()
      Gets an iterator over all records in this buffer in their logical order.
      Returns:
      An iterator returning the records in their logical order.
    • writeToOutput

      void writeToOutput(ChannelWriterOutputView output) throws IOException
      Writes the records in this buffer in their logical order to the given output.
      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

      void writeToOutput(ChannelWriterOutputView output, LargeRecordHandler<T> largeRecordsOutput) throws IOException
      Throws:
      IOException
    • writeToOutput

      void writeToOutput(ChannelWriterOutputView output, int start, int num) throws IOException
      Writes a subset of the records in this buffer in their logical order to the given output.
      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.