public class HsSubpartitionFileReaderImpl extends Object implements HsSubpartitionFileReader
HsSubpartitionFileReader
.
Note: This class is not thread safe.
Modifier and Type | Class and Description |
---|---|
static class |
HsSubpartitionFileReaderImpl.BufferIndexOrError
Indicates a buffer with index or an error.
|
static class |
HsSubpartitionFileReaderImpl.Factory
Factory of
HsSubpartitionFileReader . |
Constructor and Description |
---|
HsSubpartitionFileReaderImpl(int subpartitionId,
HsConsumerId consumerId,
FileChannel dataFileChannel,
HsSubpartitionConsumerInternalOperations operations,
HsFileDataIndex dataIndex,
int maxBufferReadAhead,
Consumer<HsSubpartitionFileReader> fileReaderReleaser,
ByteBuffer headerBuf) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(HsSubpartitionFileReader that)
Provides priority calculation logic for io scheduler.
|
Optional<ResultSubpartition.BufferAndBacklog> |
consumeBuffer(int nextBufferToConsume,
Collection<Buffer> buffersToRecycle)
Try to consume next buffer.
|
boolean |
equals(Object o) |
void |
fail(Throwable failureCause)
Fail this
HsSubpartitionFileReader caused by failureCause. |
int |
getBacklog()
Get the number of buffers whose
Buffer.DataType is buffer. |
Deque<HsSubpartitionFileReaderImpl.BufferIndexOrError> |
getLoadedBuffers() |
int |
hashCode() |
Buffer.DataType |
peekNextToConsumeDataType(int nextBufferToConsume,
Collection<Buffer> buffersToRecycle)
Get dataType of next buffer to consume.
|
void |
prepareForScheduling()
Refresh downstream consumption progress for another round scheduling of reading.
|
void |
readBuffers(Queue<MemorySegment> buffers,
BufferRecycler recycler)
Read subpartition data into buffers.
|
void |
releaseDataView()
Release this
HsDataView when related subpartition view is releasing. |
public HsSubpartitionFileReaderImpl(int subpartitionId, HsConsumerId consumerId, FileChannel dataFileChannel, HsSubpartitionConsumerInternalOperations operations, HsFileDataIndex dataIndex, int maxBufferReadAhead, Consumer<HsSubpartitionFileReader> fileReaderReleaser, ByteBuffer headerBuf)
public void readBuffers(Queue<MemorySegment> buffers, BufferRecycler recycler) throws IOException
This transfers the ownership of used buffers to this class. It's this class' responsibility to release the buffers using the recycler when no longer needed.
Calling this method does not always use up all the provided buffers. It's this class' decision when to stop reading. Currently, it stops reading when: 1) buffers are used up, or 2) reaches the end of the subpartition data within the region, or 3) enough data have been read ahead the downstream consuming offset.
readBuffers
in interface HsSubpartitionFileReader
buffers
- for reading, note that the ownership of the buffer taken out from the queue is
transferred to this class, and the unused buffer must be returned.recycler
- to return buffer to read buffer pool.IOException
public void fail(Throwable failureCause)
HsSubpartitionFileReader
HsSubpartitionFileReader
caused by failureCause.fail
in interface HsSubpartitionFileReader
failureCause
- represents the reason why it failed.public void prepareForScheduling()
prepareForScheduling
in interface HsSubpartitionFileReader
public int compareTo(HsSubpartitionFileReader that)
compareTo
in interface Comparable<HsSubpartitionFileReader>
public Deque<HsSubpartitionFileReaderImpl.BufferIndexOrError> getLoadedBuffers()
public Optional<ResultSubpartition.BufferAndBacklog> consumeBuffer(int nextBufferToConsume, Collection<Buffer> buffersToRecycle) throws Throwable
HsDataView
Only invoked by consumer thread.
consumeBuffer
in interface HsDataView
nextBufferToConsume
- next buffer index to consume.buffersToRecycle
- buffers to recycle if needed.Optional.empty()
.Throwable
public Buffer.DataType peekNextToConsumeDataType(int nextBufferToConsume, Collection<Buffer> buffersToRecycle)
HsDataView
peekNextToConsumeDataType
in interface HsDataView
nextBufferToConsume
- next buffer index to consumebuffersToRecycle
- buffers to recycle if needed.Buffer.DataType.NONE
.public void releaseDataView()
HsDataView
HsDataView
when related subpartition view is releasing.releaseDataView
in interface HsDataView
public int getBacklog()
HsDataView
Buffer.DataType
is buffer.getBacklog
in interface HsDataView
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.