public class ChannelReaderInputView extends AbstractPagedInputView
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<org.apache.flink.core.memory.MemorySegment> |
reader |
headerLength| Constructor and Description |
|---|
ChannelReaderInputView(BlockChannelReader<org.apache.flink.core.memory.MemorySegment> reader,
List<org.apache.flink.core.memory.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<org.apache.flink.core.memory.MemorySegment> reader,
List<org.apache.flink.core.memory.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<org.apache.flink.core.memory.MemorySegment> |
close()
Closes this InputView, closing the underlying reader and returning all memory segments.
|
protected int |
getLimitForSegment(org.apache.flink.core.memory.MemorySegment segment)
Gets the limit for reading bytes from the given memory segment.
|
boolean |
isClosed() |
protected org.apache.flink.core.memory.MemorySegment |
nextSegment(org.apache.flink.core.memory.MemorySegment current)
Gets the next segment from the asynchronous block reader.
|
protected void |
sendReadRequest(org.apache.flink.core.memory.MemorySegment seg)
Sends a new read requests, if further requests remain.
|
void |
waitForFirstBlock() |
advance, clear, getCurrentPositionInSegment, getCurrentSegment, getCurrentSegmentLimit, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seekInput, skipBytes, skipBytesToReadprotected final BlockChannelReader<org.apache.flink.core.memory.MemorySegment> reader
protected int numRequestsRemaining
public ChannelReaderInputView(BlockChannelReader<org.apache.flink.core.memory.MemorySegment> reader, List<org.apache.flink.core.memory.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<org.apache.flink.core.memory.MemorySegment> reader, List<org.apache.flink.core.memory.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
IOExceptionpublic boolean isClosed()
public List<org.apache.flink.core.memory.MemorySegment> close() throws IOException
IOException - Thrown, if the underlying reader could not be properly closed.protected org.apache.flink.core.memory.MemorySegment nextSegment(org.apache.flink.core.memory.MemorySegment current)
throws IOException
EOFException.nextSegment in class AbstractPagedInputViewcurrent - 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(org.apache.flink.core.memory.MemorySegment segment)
AbstractPagedInputViewgetLimitForSegment in class AbstractPagedInputViewsegment - The segment to determine the limit for.protected void sendReadRequest(org.apache.flink.core.memory.MemorySegment seg)
throws IOException
seg - The segment to use for the read request.IOException - Thrown, if the reader is in error.Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.