Interface BlockReader

All Superinterfaces:
AutoCloseable, org.apache.hadoop.fs.ByteBufferReadable, Closeable
All Known Implementing Classes:
BlockReaderRemote, ExternalBlockReader

@Private public interface BlockReader extends org.apache.hadoop.fs.ByteBufferReadable, Closeable
A BlockReader is responsible for reading a single block from a single datanode.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without performing network I/O.
    void
    Close the block reader.
    getClientMmap(EnumSet<org.apache.hadoop.fs.ReadOption> opts)
    Get a ClientMmap object for this BlockReader.
    org.apache.hadoop.util.DataChecksum
     
    int
    Return the network distance between local machine and the remote machine.
    boolean
     
    int
    read(byte[] buf, int off, int len)
     
    int
    readAll(byte[] buf, int offset, int len)
    Similar to readFully(byte[], int, int) except that it will not throw an exception on EOF.
    void
    readFully(byte[] buf, int readOffset, int amtToRead)
    Read exactly the given amount of data, throwing an exception if EOF is reached before that amount
    long
    skip(long n)
    Skip the given number of bytes

    Methods inherited from interface org.apache.hadoop.fs.ByteBufferReadable

    read
  • Method Details

    • read

      int read(byte[] buf, int off, int len) throws IOException
      Throws:
      IOException
    • skip

      long skip(long n) throws IOException
      Skip the given number of bytes
      Throws:
      IOException
    • available

      int available()
      Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without performing network I/O. This may return more than what is actually present in the block.
    • close

      void close() throws IOException
      Close the block reader.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • readFully

      void readFully(byte[] buf, int readOffset, int amtToRead) throws IOException
      Read exactly the given amount of data, throwing an exception if EOF is reached before that amount
      Throws:
      IOException
    • readAll

      int readAll(byte[] buf, int offset, int len) throws IOException
      Similar to readFully(byte[], int, int) except that it will not throw an exception on EOF. However, it differs from the simple read(byte[], int, int) call in that it is guaranteed to read the data if it is available. In other words, if this call does not throw an exception, then either the buffer has been filled or the next call will return EOF.
      Throws:
      IOException
    • isShortCircuit

      boolean isShortCircuit()
      Returns:
      true only if this is a short-circuit read. All short-circuit reads are also local.
    • getClientMmap

      ClientMmap getClientMmap(EnumSet<org.apache.hadoop.fs.ReadOption> opts)
      Get a ClientMmap object for this BlockReader.
      Parameters:
      opts - The read options to use.
      Returns:
      The ClientMmap object, or null if mmap is not supported.
    • getDataChecksum

      org.apache.hadoop.util.DataChecksum getDataChecksum()
      Returns:
      The DataChecksum used by the read block
    • getNetworkDistance

      int getNetworkDistance()
      Return the network distance between local machine and the remote machine.