Class SeekableInputStream

java.lang.Object
java.io.InputStream
org.apache.parquet.io.SeekableInputStream
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
DelegatingSeekableInputStream

public abstract class SeekableInputStream extends InputStream
SeekableInputStream is an interface with the methods needed by Parquet to read data from a file or Hadoop data stream.
  • Constructor Details

    • SeekableInputStream

      public SeekableInputStream()
  • Method Details

    • getPos

      public abstract long getPos() throws IOException
      Return the current position in the InputStream.
      Returns:
      current position in bytes from the start of the stream
      Throws:
      IOException - If the underlying stream throws IOException
    • seek

      public abstract void seek(long newPos) throws IOException
      Seek to a new position in the InputStream.
      Parameters:
      newPos - the new position to seek to
      Throws:
      IOException - If the underlying stream throws IOException
    • readFully

      public abstract void readFully(byte[] bytes) throws IOException
      Read a byte array of data, from position 0 to the end of the array.

      This method is equivalent to read(bytes, 0, bytes.length).

      This method will block until len bytes are available to copy into the array, or will throw EOFException if the stream ends before the array is full.

      Parameters:
      bytes - a byte array to fill with data from the stream
      Throws:
      IOException - If the underlying stream throws IOException
      EOFException - If the stream has fewer bytes left than are needed to fill the array, bytes.length
    • readFully

      public abstract void readFully(byte[] bytes, int start, int len) throws IOException
      Read len bytes of data into an array, at position start.

      This method will block until len bytes are available to copy into the array, or will throw EOFException if the stream ends before the array is full.

      Parameters:
      bytes - a byte array to fill with data from the stream
      start - the starting position in the byte array for data
      len - the length of bytes to read into the byte array
      Throws:
      IOException - If the underlying stream throws IOException
      EOFException - If the stream has fewer than len bytes left
    • read

      public abstract int read(ByteBuffer buf) throws IOException
      Read buf.remaining() bytes of data into a ByteBuffer.

      This method will copy available bytes into the buffer, reading at most buf.remaining() bytes. The number of bytes actually copied is returned by the method, or -1 is returned to signal that the end of the underlying stream has been reached.

      Parameters:
      buf - a byte buffer to fill with data from the stream
      Returns:
      the number of bytes read or -1 if the stream ended
      Throws:
      IOException - If the underlying stream throws IOException
    • readFully

      public abstract void readFully(ByteBuffer buf) throws IOException
      Read buf.remaining() bytes of data into a ByteBuffer.

      This method will block until buf.remaining() bytes are available to copy into the buffer, or will throw EOFException if the stream ends before the buffer is full.

      Parameters:
      buf - a byte buffer to fill with data from the stream
      Throws:
      IOException - If the underlying stream throws IOException
      EOFException - If the stream has fewer bytes left than are needed to fill the buffer, buf.remaining()
    • readVectored

      public void readVectored(List<ParquetFileRange> ranges, ByteBufferAllocator allocator) throws IOException
      Read a set of disjoint file ranges in a vectored manner.
      Parameters:
      ranges - a list of non-overlapping file ranges to read
      allocator - the allocator to use for allocating ByteBuffers
      Throws:
      UnsupportedOperationException - if not available in this class/runtime (default)
      EOFException - if a range is past the known end of the file.
      IOException - any IO problem initiating the read operations.
      IllegalArgumentException - if there are overlapping ranges or a range element is invalid
    • readVectoredAvailable

      public boolean readVectoredAvailable(ByteBufferAllocator allocator)
      Parameters:
      allocator - the allocator to use for allocating ByteBuffers
      Returns:
      True if the operation is considered available for this allocator in the hadoop runtime.