Class HeaderlessChannelReaderInputView
java.lang.Object
org.apache.flink.runtime.memory.AbstractPagedInputView
org.apache.flink.runtime.io.disk.iomanager.AbstractChannelReaderInputView
org.apache.flink.runtime.io.disk.iomanager.ChannelReaderInputView
org.apache.flink.runtime.io.disk.iomanager.HeaderlessChannelReaderInputView
- All Implemented Interfaces:
DataInput,org.apache.flink.core.memory.DataInputView
A
DataInputView that 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.-
Field Summary
Fields inherited from class org.apache.flink.runtime.io.disk.iomanager.ChannelReaderInputView
numRequestsRemaining, readerFields inherited from class org.apache.flink.runtime.memory.AbstractPagedInputView
headerLength -
Constructor Summary
ConstructorsConstructorDescriptionHeaderlessChannelReaderInputView(BlockChannelReader<org.apache.flink.core.memory.MemorySegment> reader, List<org.apache.flink.core.memory.MemorySegment> memory, int numBlocks, int numBytesInLastBlock, boolean waitForFirstBlock) 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.HeaderlessChannelReaderInputView(BlockChannelReader<org.apache.flink.core.memory.MemorySegment> reader, List<org.apache.flink.core.memory.MemorySegment> memory, int numBlocks, int numBytesInLastBlock, boolean waitForFirstBlock, long offset) -
Method Summary
Modifier and TypeMethodDescriptionvoidadvance()Advances the view to the next memory segment.protected intgetLimitForSegment(org.apache.flink.core.memory.MemorySegment segment) Gets the limit for reading bytes from the given memory segment.protected org.apache.flink.core.memory.MemorySegmentnextSegment(org.apache.flink.core.memory.MemorySegment current) Gets the next segment from the asynchronous block reader.Methods inherited from class org.apache.flink.runtime.io.disk.iomanager.ChannelReaderInputView
close, getChannel, isClosed, sendReadRequest, waitForFirstBlockMethods inherited from class org.apache.flink.runtime.memory.AbstractPagedInputView
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
-
Constructor Details
-
HeaderlessChannelReaderInputView
public HeaderlessChannelReaderInputView(BlockChannelReader<org.apache.flink.core.memory.MemorySegment> reader, List<org.apache.flink.core.memory.MemorySegment> memory, int numBlocks, int numBytesInLastBlock, boolean waitForFirstBlock) throws IOException 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.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.
- Parameters:
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.- Throws:
IOException- Thrown, if the read requests for the first blocks fail to be served by the reader.
-
HeaderlessChannelReaderInputView
public HeaderlessChannelReaderInputView(BlockChannelReader<org.apache.flink.core.memory.MemorySegment> reader, List<org.apache.flink.core.memory.MemorySegment> memory, int numBlocks, int numBytesInLastBlock, boolean waitForFirstBlock, long offset) throws IOException - Throws:
IOException
-
-
Method Details
-
nextSegment
protected org.apache.flink.core.memory.MemorySegment nextSegment(org.apache.flink.core.memory.MemorySegment current) throws IOException Description copied from class:ChannelReaderInputViewGets the next segment from the asynchronous block reader. If more requests are to be issued, the method first sends a new request with the current memory segment. If no more requests are pending, the method adds the segment to the readers return queue, which thereby effectively collects all memory segments. Secondly, the method fetches the next non-consumed segment returned by the reader. If no further segments are available, this method thrown anEOFException.- Overrides:
nextSegmentin classChannelReaderInputView- Parameters:
current- The memory segment used for the next request.- Returns:
- The memory segment to read from next.
- Throws:
EOFException- Thrown, if no further segments are available.IOException- Thrown, if an I/O error occurred while reading- See Also:
-
advance
Description copied from class:AbstractPagedInputViewAdvances the view to the next memory segment. The reading will continue after the header of the next segment. This method usesAbstractPagedInputView.nextSegment(MemorySegment)andAbstractPagedInputView.getLimitForSegment(MemorySegment)to get the next segment and set its limit.- Overrides:
advancein classAbstractPagedInputView- Throws:
IOException- Thrown, if the next segment could not be obtained.- See Also:
-
getLimitForSegment
protected int getLimitForSegment(org.apache.flink.core.memory.MemorySegment segment) Description copied from class:AbstractPagedInputViewGets the limit for reading bytes from the given memory segment. This method must return the position of the byte after the last valid byte in the given memory segment. When the position returned by this method is reached, the view will attempt to switch to the next memory segment.- Overrides:
getLimitForSegmentin classChannelReaderInputView- Parameters:
segment- The segment to determine the limit for.- Returns:
- The limit for the given memory segment.
-