public class ChannelReaderInputView extends AbstractChannelReaderInputView
DataInputView
that is backed by a BlockChannelReader
, making it effectively a data input stream. The view reads it data in blocks
from the underlying channel. The view can only read data that has been written by a ChannelWriterOutputView
, due to block formatting.Modifier and Type | Field and Description |
---|---|
protected int |
numRequestsRemaining |
protected BlockChannelReader<MemorySegment> |
reader |
headerLength
Constructor and Description |
---|
ChannelReaderInputView(BlockChannelReader<MemorySegment> reader,
List<MemorySegment> memory,
boolean waitForFirstBlock)
Creates a new channel reader that reads from the given channel until the last block (as
marked by a
ChannelWriterOutputView ) is found. |
ChannelReaderInputView(BlockChannelReader<MemorySegment> reader,
List<MemorySegment> memory,
int numBlocks,
boolean waitForFirstBlock)
Creates a new channel reader that reads from the given channel, expecting a specified number
of blocks in the channel.
|
Modifier and Type | Method and Description |
---|---|
List<MemorySegment> |
close()
Closes this InputView, closing the underlying reader and returning all memory segments.
|
FileIOChannel |
getChannel()
Get the underlying channel.
|
protected int |
getLimitForSegment(MemorySegment segment)
Gets the limit for reading bytes from the given memory segment.
|
boolean |
isClosed() |
protected MemorySegment |
nextSegment(MemorySegment current)
Gets the next segment from the asynchronous block reader.
|
protected void |
sendReadRequest(MemorySegment seg)
Sends a new read requests, if further requests remain.
|
void |
waitForFirstBlock() |
advance, clear, doAdvance, getCurrentPositionInSegment, getCurrentSegment, getCurrentSegmentLimit, getHeaderLength, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seekInput, skipBytes, skipBytesToRead
protected final BlockChannelReader<MemorySegment> reader
protected int numRequestsRemaining
public ChannelReaderInputView(BlockChannelReader<MemorySegment> reader, List<MemorySegment> memory, boolean waitForFirstBlock) throws IOException
ChannelWriterOutputView
) is found.reader
- The reader that reads the data from disk back into memory.memory
- A list of memory segments that the reader uses for reading the data in. If the
list contains more than one segment, the reader will asynchronously pre-fetch blocks
ahead.waitForFirstBlock
- A flag indicating weather this constructor call should block until
the first block has returned from the asynchronous I/O reader.IOException
- Thrown, if the read requests for the first blocks fail to be served by
the reader.public ChannelReaderInputView(BlockChannelReader<MemorySegment> reader, List<MemorySegment> memory, int numBlocks, boolean waitForFirstBlock) throws IOException
WARNING: The reader will lock if the number of blocks given here is actually lower than the actual number of blocks in the channel.
reader
- The reader that reads the data from disk back into memory.memory
- A list of memory segments that the reader uses for reading the data in. If the
list contains more than one segment, the reader will asynchronously pre-fetch blocks
ahead.numBlocks
- The number of blocks this channel will read. If this value is given, the
reader avoids issuing pre-fetch requests for blocks beyond the channel size.waitForFirstBlock
- A flag indicating weather this constructor call should block until
the first block has returned from the asynchronous I/O reader.IOException
- Thrown, if the read requests for the first blocks fail to be served by
the reader.public void waitForFirstBlock() throws IOException
IOException
public boolean isClosed()
public List<MemorySegment> close() throws IOException
close
in class AbstractChannelReaderInputView
IOException
- Thrown, if the underlying reader could not be properly closed.public FileIOChannel getChannel()
AbstractChannelReaderInputView
getChannel
in class AbstractChannelReaderInputView
protected MemorySegment nextSegment(MemorySegment current) throws IOException
EOFException
.nextSegment
in class AbstractPagedInputView
current
- The memory segment used for the next request.EOFException
- Thrown, if no further segments are available.IOException
- Thrown, if an I/O error occurred while readingAbstractPagedInputView.nextSegment(org.apache.flink.core.memory.MemorySegment)
protected int getLimitForSegment(MemorySegment segment)
AbstractPagedInputView
getLimitForSegment
in class AbstractPagedInputView
segment
- The segment to determine the limit for.protected void sendReadRequest(MemorySegment seg) throws IOException
seg
- The segment to use for the read request.IOException
- Thrown, if the reader is in error.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.