Interface DataBuffer

All Known Implementing Classes:
HashBasedDataBuffer, SortBasedDataBuffer, SortBuffer, TieredStorageSortBuffer

public interface DataBuffer
Data of different subpartitions can be appended to a DataBuffer and after the DataBuffer is full or finished, the appended data can be copied from it in subpartition index order.

The lifecycle of a DataBuffer can be: new, write, [read, reset, write], finish, read, release. There can be multiple [read, reset, write] operations before finish.

  • Method Details

    • append

      boolean append(ByteBuffer source, int targetSubpartition, Buffer.DataType dataType) throws IOException
      Appends data of the specified subpartition to this DataBuffer and returns true if this DataBuffer is full.
      Throws:
      IOException
    • getNextBuffer

      BufferWithSubpartition getNextBuffer(@Nullable org.apache.flink.core.memory.MemorySegment transitBuffer)
      Copies data in this DataBuffer to the target MemorySegment in subpartition index order and returns BufferWithSubpartition which contains the copied data and the corresponding subpartition index.
    • numTotalRecords

      long numTotalRecords()
      Returns the total number of records written to this DataBuffer.
    • numTotalBytes

      long numTotalBytes()
      Returns the total number of bytes written to this DataBuffer.
    • hasRemaining

      boolean hasRemaining()
      Returns true if not all data appended to this DataBuffer is consumed.
    • finish

      void finish()
      Finishes this DataBuffer which means no record can be appended anymore.
    • isFinished

      boolean isFinished()
      Whether this DataBuffer is finished or not.
    • release

      void release()
      Releases this DataBuffer which releases all resources.
    • isReleased

      boolean isReleased()
      Whether this DataBuffer is released or not.