Class ByteBufferReadableFSDataInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    @Experimental
    public class ByteBufferReadableFSDataInputStream
    extends org.apache.flink.core.fs.FSDataInputStream
    A FSDataInputStream delegates requests to other one and supports reading data with ByteBuffer.

    All methods in this class maybe used by ForSt, please start a discussion firstly if it has to be modified.

    • Constructor Detail

      • ByteBufferReadableFSDataInputStream

        public ByteBufferReadableFSDataInputStream​(Callable<org.apache.flink.core.fs.FSDataInputStream> inputStreamBuilder,
                                                   int inputStreamCapacity,
                                                   long totalFileSize)
                                            throws IOException
        Throws:
        IOException
    • Method Detail

      • readFully

        public int readFully​(ByteBuffer bb)
                      throws IOException
        Reads up to ByteBuffer#remaining bytes of data from the input stream into a ByteBuffer. Not Thread-safe yet since the interface of sequential read of ForSt only be accessed by one thread at a time. TODO: Rename all methods about 'readFully' to 'read' when next version of ForSt is ready.
        Parameters:
        bb - the buffer into which the data is read.
        Returns:
        the total number of bytes read into the buffer.
        Throws:
        IOException - If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
        NullPointerException - If bb is null.
      • readFully

        public int readFully​(long position,
                             ByteBuffer bb)
                      throws Exception
        Reads up to ByteBuffer#remaining bytes of data from the specific position of the input stream into a ByteBuffer. Thread-safe since the interface of random read of ForSt may be concurrently accessed by multiple threads. TODO: Support to split this method to other class.
        Parameters:
        position - the start offset in input stream at which the data is read.
        bb - the buffer into which the data is read.
        Returns:
        the total number of bytes read into the buffer.
        Throws:
        IOException - If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
        NullPointerException - If bb is null.
        Exception
      • seek

        public void seek​(long desired)
                  throws IOException
        Specified by:
        seek in class org.apache.flink.core.fs.FSDataInputStream
        Throws:
        IOException
      • getPos

        public long getPos()
                    throws IOException
        Specified by:
        getPos in class org.apache.flink.core.fs.FSDataInputStream
        Throws:
        IOException
      • mark

        public void mark​(int readlimit)
        Overrides:
        mark in class InputStream