Class HsSubpartitionConsumerMemoryDataManager
- java.lang.Object
-
- org.apache.flink.runtime.io.network.partition.hybrid.HsSubpartitionConsumerMemoryDataManager
-
- All Implemented Interfaces:
HsDataView
public class HsSubpartitionConsumerMemoryDataManager extends Object implements HsDataView
This class is responsible for managing the data of a single consumer.HsSubpartitionMemoryDataManagerwill create a newHsSubpartitionConsumerMemoryDataManagerwhen a consumer is registered.
-
-
Constructor Summary
Constructors Constructor Description HsSubpartitionConsumerMemoryDataManager(Lock resultPartitionLock, Lock consumerLock, int subpartitionId, HsConsumerId consumerId, HsMemoryDataManagerOperation memoryDataManagerOperation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddBuffer(HsBufferContext bufferContext)voidaddInitialBuffers(Deque<HsBufferContext> buffers)Optional<ResultSubpartition.BufferAndBacklog>consumeBuffer(int toConsumeIndex, Collection<Buffer> buffersToRecycle)Check whether the head ofunConsumedBuffersis the buffer to be consumed.intgetBacklog()Get the number of buffers whoseBuffer.DataTypeis buffer.Buffer.DataTypepeekNextToConsumeDataType(int nextToConsumeIndex, Collection<Buffer> buffersToRecycle)Check whether the head ofunConsumedBuffersis the buffer to be consumed next time.voidreleaseDataView()Release thisHsDataViewwhen related subpartition view is releasing.
-
-
-
Constructor Detail
-
HsSubpartitionConsumerMemoryDataManager
public HsSubpartitionConsumerMemoryDataManager(Lock resultPartitionLock, Lock consumerLock, int subpartitionId, HsConsumerId consumerId, HsMemoryDataManagerOperation memoryDataManagerOperation)
-
-
Method Detail
-
addInitialBuffers
public void addInitialBuffers(Deque<HsBufferContext> buffers)
-
addBuffer
public boolean addBuffer(HsBufferContext bufferContext)
-
consumeBuffer
public Optional<ResultSubpartition.BufferAndBacklog> consumeBuffer(int toConsumeIndex, Collection<Buffer> buffersToRecycle)
Check whether the head ofunConsumedBuffersis the buffer to be consumed. If so, return the buffer and backlog.- Specified by:
consumeBufferin interfaceHsDataView- Parameters:
toConsumeIndex- index of buffer to be consumed.buffersToRecycle- buffers to recycle if needed.- Returns:
- If the head of
unConsumedBuffersis target, return optional of the buffer and backlog. Otherwise, returnOptional.empty().
-
peekNextToConsumeDataType
public Buffer.DataType peekNextToConsumeDataType(int nextToConsumeIndex, Collection<Buffer> buffersToRecycle)
Check whether the head ofunConsumedBuffersis the buffer to be consumed next time. If so, return the next buffer's data type.- Specified by:
peekNextToConsumeDataTypein interfaceHsDataView- Parameters:
nextToConsumeIndex- index of the buffer to be consumed next time.buffersToRecycle- buffers to recycle if needed.- Returns:
- If the head of
unConsumedBuffersis target, return the buffer's data type. Otherwise, returnBuffer.DataType.NONE.
-
getBacklog
public int getBacklog()
Description copied from interface:HsDataViewGet the number of buffers whoseBuffer.DataTypeis buffer.- Specified by:
getBacklogin interfaceHsDataView- Returns:
- backlog of this view's corresponding subpartition.
-
releaseDataView
public void releaseDataView()
Description copied from interface:HsDataViewRelease thisHsDataViewwhen related subpartition view is releasing.- Specified by:
releaseDataViewin interfaceHsDataView
-
-