Class HashBasedDataBuffer
java.lang.Object
org.apache.flink.runtime.io.network.partition.HashBasedDataBuffer
- All Implemented Interfaces:
DataBuffer
* A
DataBuffer implementation which sorts all appended records only by subpartition
index. Records of the same subpartition keep the appended order.
Different from the SortBasedDataBuffer, in this DataBuffer implementation,
memory segment boundary serves as the nature data boundary of different subpartitions, which
means that one memory segment can never contain data from different subpartitions.
-
Constructor Summary
ConstructorsConstructorDescriptionHashBasedDataBuffer(LinkedList<org.apache.flink.core.memory.MemorySegment> freeSegments, BufferRecycler bufferRecycler, int numSubpartitions, int bufferSize, int numGuaranteedBuffers, int[] customReadOrder) -
Method Summary
Modifier and TypeMethodDescriptionbooleanappend(ByteBuffer source, int targetSubpartition, Buffer.DataType dataType) Partial data of the target record can be written if thisHashBasedDataBufferis 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.
-
Constructor Details
-
HashBasedDataBuffer
public HashBasedDataBuffer(LinkedList<org.apache.flink.core.memory.MemorySegment> freeSegments, BufferRecycler bufferRecycler, int numSubpartitions, int bufferSize, int numGuaranteedBuffers, @Nullable int[] customReadOrder)
-
-
Method Details
-
append
public boolean append(ByteBuffer source, int targetSubpartition, Buffer.DataType dataType) throws IOException Partial data of the target record can be written if thisHashBasedDataBufferis full. The remaining data of the target record will be written to the next data region (a new data buffer or this data buffer after reset).- Specified by:
appendin interfaceDataBuffer- Throws:
IOException
-
getNextBuffer
public BufferWithSubpartition getNextBuffer(org.apache.flink.core.memory.MemorySegment transitBuffer) Description copied from interface:DataBufferCopies data in thisDataBufferto the targetMemorySegmentin subpartition index order and returnsBufferWithSubpartitionwhich contains the copied data and the corresponding subpartition index.- Specified by:
getNextBufferin interfaceDataBuffer
-
numTotalRecords
public long numTotalRecords()Description copied from interface:DataBufferReturns the total number of records written to thisDataBuffer.- Specified by:
numTotalRecordsin interfaceDataBuffer
-
numTotalBytes
public long numTotalBytes()Description copied from interface:DataBufferReturns the total number of bytes written to thisDataBuffer.- Specified by:
numTotalBytesin interfaceDataBuffer
-
hasRemaining
public boolean hasRemaining()Description copied from interface:DataBufferReturns true if not all data appended to thisDataBufferis consumed.- Specified by:
hasRemainingin interfaceDataBuffer
-
finish
public void finish()Description copied from interface:DataBufferFinishes thisDataBufferwhich means no record can be appended anymore.- Specified by:
finishin interfaceDataBuffer
-
isFinished
public boolean isFinished()Description copied from interface:DataBufferWhether thisDataBufferis finished or not.- Specified by:
isFinishedin interfaceDataBuffer
-
release
public void release()Description copied from interface:DataBufferReleases thisDataBufferwhich releases all resources.- Specified by:
releasein interfaceDataBuffer
-
isReleased
public boolean isReleased()Description copied from interface:DataBufferWhether thisDataBufferis released or not.- Specified by:
isReleasedin interfaceDataBuffer
-