public class HeaderlessChannelReaderInputView extends ChannelReaderInputView
DataInputViewthat is backed by a
BlockChannelReader, making it effectively a data input stream. This view is similar to the
ChannelReaderInputView, but does not expect a header for each block, giving a direct stream abstraction over sequence of written blocks. It therefore requires specification of the number of blocks and the number of bytes in the last block.
|Constructor and Description|
Creates a new channel reader that reads from the given channel, expecting a specified number of blocks in the channel, and returns only a specified number of bytes from the last block.
|Modifier and Type||Method and Description|
Advances the view to the next memory segment.
Gets the limit for reading bytes from the given memory segment.
Gets the next segment from the asynchronous block reader.
close, getChannel, isClosed, sendReadRequest, waitForFirstBlock
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
public HeaderlessChannelReaderInputView(BlockChannelReader<MemorySegment> reader, List<MemorySegment> memory, int numBlocks, int numBytesInLastBlock, boolean waitForFirstBlock) throws IOException
WARNING: If the number of blocks given here is higher than the number of blocks in the channel, then the last blocks will not be filled by the reader and will contain undefined data.
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.
numBytesInLastBlock- The number of valid bytes in the last block.
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.
protected MemorySegment nextSegment(MemorySegment current) throws IOException
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 reading
public void advance() throws IOException
AbstractPagedInputView.getLimitForSegment(MemorySegment)to get the next segment and set its limit.
IOException- Thrown, if the next segment could not be obtained.
protected int getLimitForSegment(MemorySegment segment)
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.