Class ByteBufferReadableFSDataInputStream

java.lang.Object
java.io.InputStream
org.apache.flink.core.fs.FSDataInputStream
org.apache.flink.state.forst.fs.ByteBufferReadableFSDataInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

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 Details

    • ByteBufferReadableFSDataInputStream

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

    • 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
    • read

      public int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(byte[] b) throws IOException
      Overrides:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Overrides:
      read in class InputStream
      Throws:
      IOException
    • skip

      public long skip(long n) throws IOException
      Overrides:
      skip in class InputStream
      Throws:
      IOException
    • available

      public int available() throws IOException
      Overrides:
      available in class InputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException
    • mark

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

      public void reset() throws IOException
      Overrides:
      reset in class InputStream
      Throws:
      IOException
    • markSupported

      public boolean markSupported()
      Overrides:
      markSupported in class InputStream