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 Summary
Modifier and TypeMethodDescriptionbooleanappend(ByteBuffer source, int targetSubpartition, Buffer.DataType dataType) Appends data of the specified subpartition to thisDataBufferand returns true if thisDataBufferis full.voidfinish()Finishes thisDataBufferwhich means no record can be appended anymore.getNextBuffer(org.apache.flink.core.memory.MemorySegment transitBuffer) Copies data in thisDataBufferto the targetMemorySegmentin subpartition index order and returnsBufferWithSubpartitionwhich contains the copied data and the corresponding subpartition index.booleanReturns true if not all data appended to thisDataBufferis consumed.booleanWhether thisDataBufferis finished or not.booleanWhether thisDataBufferis released or not.longReturns the total number of bytes written to thisDataBuffer.longReturns the total number of records written to thisDataBuffer.voidrelease()Releases thisDataBufferwhich releases all resources.
-
Method Details
-
append
boolean append(ByteBuffer source, int targetSubpartition, Buffer.DataType dataType) throws IOException Appends data of the specified subpartition to thisDataBufferand returns true if thisDataBufferis full.- Throws:
IOException
-
getNextBuffer
BufferWithSubpartition getNextBuffer(@Nullable org.apache.flink.core.memory.MemorySegment transitBuffer) Copies data in thisDataBufferto the targetMemorySegmentin subpartition index order and returnsBufferWithSubpartitionwhich contains the copied data and the corresponding subpartition index. -
numTotalRecords
long numTotalRecords()Returns the total number of records written to thisDataBuffer. -
numTotalBytes
long numTotalBytes()Returns the total number of bytes written to thisDataBuffer. -
hasRemaining
boolean hasRemaining()Returns true if not all data appended to thisDataBufferis consumed. -
finish
void finish()Finishes thisDataBufferwhich means no record can be appended anymore. -
isFinished
boolean isFinished()Whether thisDataBufferis finished or not. -
release
void release()Releases thisDataBufferwhich releases all resources. -
isReleased
boolean isReleased()Whether thisDataBufferis released or not.
-