public class HashBufferAccumulator extends Object implements BufferAccumulator, HashSubpartitionBufferAccumulatorContext
BufferAccumulator. The BufferAccumulator receives
the records from TieredStorageProducerClient and the records will accumulate and
transform to finished buffers. The accumulated buffers will be transferred to the corresponding
tier dynamically.
To avoid the buffer waiting deadlock between the subpartitions, the HashBufferAccumulator requires at least n buffers (n is the number of subpartitions) to make
sure that each subpartition has at least one buffer to accumulate the receiving data. Once an
accumulated buffer is finished, the buffer will be flushed immediately.
Note that this class need not be thread-safe, because it should only be accessed from the main thread.
| Constructor and Description |
|---|
HashBufferAccumulator(int numSubpartitions,
int bufferSize,
TieredStorageMemoryManager memoryManager) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the accumulator.
|
void |
flushAccumulatedBuffers(TieredStorageSubpartitionId subpartitionId,
List<Buffer> accumulatedBuffers)
Flush the accumulated
Buffers of the subpartition. |
void |
receive(ByteBuffer record,
TieredStorageSubpartitionId subpartitionId,
Buffer.DataType dataType,
boolean isBroadcast)
Receives the records from tiered store producer, these records will be accumulated and
transformed into finished buffers.
|
BufferBuilder |
requestBufferBlocking()
Request
BufferBuilder from the BufferPool. |
void |
setup(java.util.function.BiConsumer<TieredStorageSubpartitionId,List<Buffer>> accumulatedBufferFlusher)
Setup the accumulator.
|
public HashBufferAccumulator(int numSubpartitions,
int bufferSize,
TieredStorageMemoryManager memoryManager)
public void setup(java.util.function.BiConsumer<TieredStorageSubpartitionId,List<Buffer>> accumulatedBufferFlusher)
BufferAccumulatorsetup in interface BufferAccumulatoraccumulatedBufferFlusher - accepts the accumulated buffers. The first field is the subpartition id,
while the list in the second field contains accumulated buffers in order for that
subpartition.public void receive(ByteBuffer record, TieredStorageSubpartitionId subpartitionId, Buffer.DataType dataType, boolean isBroadcast) throws IOException
BufferAccumulatorNote that when isBroadcast is true, for a broadcast-only partition, the subpartitionId value will always be 0. Conversely, for a non-broadcast-only partition, the subpartitionId value will range from 0 to the number of subpartitions.
receive in interface BufferAccumulatorrecord - the received recordsubpartitionId - the subpartition id of the recorddataType - the data type of the recordisBroadcast - whether the record is a broadcast recordIOExceptionpublic void close()
BufferAccumulatorclose in interface AutoCloseableclose in interface BufferAccumulatorpublic BufferBuilder requestBufferBlocking()
HashSubpartitionBufferAccumulatorContextBufferBuilder from the BufferPool.requestBufferBlocking in interface HashSubpartitionBufferAccumulatorContextpublic void flushAccumulatedBuffers(TieredStorageSubpartitionId subpartitionId, List<Buffer> accumulatedBuffers)
HashSubpartitionBufferAccumulatorContextBuffers of the subpartition.flushAccumulatedBuffers in interface HashSubpartitionBufferAccumulatorContextsubpartitionId - the subpartition idaccumulatedBuffers - the accumulated buffersCopyright © 2014–2023 The Apache Software Foundation. All rights reserved.