Class HashBasedDataBuffer
- java.lang.Object
-
- org.apache.flink.runtime.io.network.partition.HashBasedDataBuffer
-
- All Implemented Interfaces:
DataBuffer
public class HashBasedDataBuffer extends Object implements DataBuffer
* ADataBufferimplementation which sorts all appended records only by subpartition index. Records of the same subpartition keep the appended order.Different from the
SortBasedDataBuffer, in thisDataBufferimplementation, 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
Constructors Constructor Description HashBasedDataBuffer(LinkedList<org.apache.flink.core.memory.MemorySegment> freeSegments, BufferRecycler bufferRecycler, int numSubpartitions, int bufferSize, int numGuaranteedBuffers, int[] customReadOrder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanappend(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.BufferWithSubpartitiongetNextBuffer(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.booleanhasRemaining()Returns true if not all data appended to thisDataBufferis consumed.booleanisFinished()Whether thisDataBufferis finished or not.booleanisReleased()Whether thisDataBufferis released or not.longnumTotalBytes()Returns the total number of bytes written to thisDataBuffer.longnumTotalRecords()Returns the total number of records written to thisDataBuffer.voidrelease()Releases thisDataBufferwhich releases all resources.
-
-
-
Constructor Detail
-
HashBasedDataBuffer
public HashBasedDataBuffer(LinkedList<org.apache.flink.core.memory.MemorySegment> freeSegments, BufferRecycler bufferRecycler, int numSubpartitions, int bufferSize, int numGuaranteedBuffers, @Nullable int[] customReadOrder)
-
-
Method Detail
-
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
-
-