Interface BlockChannelReader<T>
-
- All Superinterfaces:
FileIOChannel
- All Known Implementing Classes:
AsynchronousBlockReader
public interface BlockChannelReader<T> extends FileIOChannel
A reader that reads data in blocks from a file channel. The reader reads the blocks into aMemorySegment
. To support asynchronous implementations, the read method does not immediately return the full memory segment, but rather adds it to a blocking queue of finished read operations.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.io.disk.iomanager.FileIOChannel
FileIOChannel.Enumerator, FileIOChannel.ID
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
getNextReturnedBlock()
Gets the next memory segment that has been filled with data by the reader.LinkedBlockingQueue<T>
getReturnQueue()
Gets the queue in which the full memory segments are queued after the read is complete.void
readBlock(T segment)
Issues a read request, which will fill the given segment with the next block in the underlying file channel.void
seekToPosition(long position)
-
Methods inherited from interface org.apache.flink.runtime.io.disk.iomanager.FileIOChannel
close, closeAndDelete, deleteChannel, getChannelID, getNioFileChannel, getSize, isClosed
-
-
-
-
Method Detail
-
readBlock
void readBlock(T segment) throws IOException
Issues a read request, which will fill the given segment with the next block in the underlying file channel. Once the read request is fulfilled, the segment will be added to this reader's return queue.- Parameters:
segment
- The segment to read the block into.- Throws:
IOException
- Thrown, when the reader encounters an I/O error.
-
seekToPosition
void seekToPosition(long position) throws IOException
- Throws:
IOException
-
getNextReturnedBlock
T getNextReturnedBlock() throws IOException
Gets the next memory segment that has been filled with data by the reader. This method blocks until such a segment is available, or until an error occurs in the reader, or the reader is closed.WARNING: If this method is invoked without any segment ever returning (for example, because the
readBlock(T)
method has not been invoked appropriately), the method may block forever.- Returns:
- The next memory segment from the reader's return queue.
- Throws:
IOException
- Thrown, if an I/O error occurs in the reader while waiting for the request to return.
-
getReturnQueue
LinkedBlockingQueue<T> getReturnQueue()
Gets the queue in which the full memory segments are queued after the read is complete.- Returns:
- The queue with the full memory segments.
-
-