Class SeekableBAIS

java.lang.Object
java.io.InputStream
java.io.ByteArrayInputStream
org.apache.drill.exec.vector.complex.fn.SeekableBAIS
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.fs.PositionedReadable, org.apache.hadoop.fs.Seekable

public class SeekableBAIS extends ByteArrayInputStream implements org.apache.hadoop.fs.Seekable, org.apache.hadoop.fs.PositionedReadable
A ByteArrayInputStream that supports the HDFS Seekable API.
  • Constructor Details

    • SeekableBAIS

      public SeekableBAIS(byte[] buf, int offset, int length)
    • SeekableBAIS

      public SeekableBAIS(byte[] buf)
  • Method Details

    • seek

      public void seek(long pos) throws IOException
      Specified by:
      seek in interface org.apache.hadoop.fs.Seekable
      Throws:
      IOException
    • getPos

      public long getPos() throws IOException
      Specified by:
      getPos in interface org.apache.hadoop.fs.Seekable
      Throws:
      IOException
    • seekToNewSource

      public boolean seekToNewSource(long targetPos) throws IOException
      Specified by:
      seekToNewSource in interface org.apache.hadoop.fs.Seekable
      Throws:
      IOException
    • read

      public int read(long position, byte[] buffer, int offset, int length) throws IOException
      Read up to the specified number of bytes, from a given position within a file, and return the number of bytes read. This does not change the current offset of a file, and is thread-safe. Warning: Not all filesystems satisfy the thread-safety requirement.
      Specified by:
      read in interface org.apache.hadoop.fs.PositionedReadable
      Parameters:
      position - position within file
      buffer - destination buffer
      offset - offset in the buffer
      length - number of bytes to read
      Returns:
      actual number of bytes read; -1 means "none"
      Throws:
      IOException - IO problems.
    • readFully

      public void readFully(long position, byte[] buffer, int offset, int length) throws IOException
      Read the specified number of bytes, from a given position within a file. This does not change the current offset of a file, and is thread-safe. Warning: Not all filesystems satisfy the thread-safety requirement.
      Specified by:
      readFully in interface org.apache.hadoop.fs.PositionedReadable
      Parameters:
      position - position within file
      buffer - destination buffer
      offset - offset in the buffer
      length - number of bytes to read
      Throws:
      IOException - IO problems.
      EOFException - the end of the data was reached before the read operation completed
    • readFully

      public void readFully(long position, byte[] buffer) throws IOException
      Read number of bytes equal to the length of the buffer, from a given position within a file. This does not change the current offset of a file, and is thread-safe. Warning: Not all filesystems satisfy the thread-safety requirement.
      Specified by:
      readFully in interface org.apache.hadoop.fs.PositionedReadable
      Parameters:
      position - position within file
      buffer - destination buffer
      Throws:
      IOException - IO problems.
      EOFException - the end of the data was reached before the read operation completed