public class HashBasedDataBuffer extends Object implements DataBuffer
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 and Description |
|---|
HashBasedDataBuffer(LinkedList<org.apache.flink.core.memory.MemorySegment> freeSegments,
BufferRecycler bufferRecycler,
int numSubpartitions,
int bufferSize,
int numGuaranteedBuffers,
int[] customReadOrder) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
append(ByteBuffer source,
int targetSubpartition,
Buffer.DataType dataType)
Partial data of the target record can be written if this
HashBasedDataBuffer is full. |
void |
finish()
Finishes this
DataBuffer which means no record can be appended anymore. |
BufferWithSubpartition |
getNextBuffer(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. |
boolean |
hasRemaining()
Returns true if not all data appended to this
DataBuffer is consumed. |
boolean |
isFinished()
Whether this
DataBuffer is finished or not. |
boolean |
isReleased()
Whether this
DataBuffer is released or not. |
long |
numTotalBytes()
Returns the total number of bytes written to this
DataBuffer. |
long |
numTotalRecords()
Returns the total number of records written to this
DataBuffer. |
void |
release()
Releases this
DataBuffer which releases all resources. |
public HashBasedDataBuffer(LinkedList<org.apache.flink.core.memory.MemorySegment> freeSegments, BufferRecycler bufferRecycler, int numSubpartitions, int bufferSize, int numGuaranteedBuffers, @Nullable int[] customReadOrder)
public boolean append(ByteBuffer source, int targetSubpartition, Buffer.DataType dataType) throws IOException
HashBasedDataBuffer is 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).append in interface DataBufferIOExceptionpublic BufferWithSubpartition getNextBuffer(org.apache.flink.core.memory.MemorySegment transitBuffer)
DataBufferDataBuffer to the target MemorySegment in subpartition
index order and returns BufferWithSubpartition which contains the copied data and the
corresponding subpartition index.getNextBuffer in interface DataBufferpublic long numTotalRecords()
DataBufferDataBuffer.numTotalRecords in interface DataBufferpublic long numTotalBytes()
DataBufferDataBuffer.numTotalBytes in interface DataBufferpublic boolean hasRemaining()
DataBufferDataBuffer is consumed.hasRemaining in interface DataBufferpublic void finish()
DataBufferDataBuffer which means no record can be appended anymore.finish in interface DataBufferpublic boolean isFinished()
DataBufferDataBuffer is finished or not.isFinished in interface DataBufferpublic void release()
DataBufferDataBuffer which releases all resources.release in interface DataBufferpublic boolean isReleased()
DataBufferDataBuffer is released or not.isReleased in interface DataBufferCopyright © 2014–2025 The Apache Software Foundation. All rights reserved.