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 a MemorySegment. 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.
    • 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.
      • 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.