Class HdfsDataInputStream

All Implemented Interfaces:
Closeable, DataInput, AutoCloseable, ByteBufferPositionedReadable, ByteBufferReadable, CanSetDropBehind, CanSetReadahead, CanUnbuffer, org.apache.hadoop.fs.HasEnhancedByteBufferAccess, org.apache.hadoop.fs.HasFileDescriptor, PositionedReadable, Seekable, org.apache.hadoop.fs.statistics.IOStatisticsSource, StreamCapabilities

@Public @Evolving public class HdfsDataInputStream extends FSDataInputStream
The Hdfs implementation of FSDataInputStream.
  • Constructor Details

    • HdfsDataInputStream

      public HdfsDataInputStream(org.apache.hadoop.hdfs.DFSInputStream in)
    • HdfsDataInputStream

      public HdfsDataInputStream(org.apache.hadoop.crypto.CryptoInputStream in)
  • Method Details

    • getWrappedStream

      public InputStream getWrappedStream()
      Get a reference to the wrapped output stream. We always want to return the actual underlying InputStream, even when we're using a CryptoStream. e.g. in the delegated methods below.
      Overrides:
      getWrappedStream in class FSDataInputStream
      Returns:
      the underlying output stream
    • getCurrentDatanode

      public org.apache.hadoop.hdfs.protocol.DatanodeInfo getCurrentDatanode()
      Get the datanode from which the stream is currently reading.
    • getCurrentBlock

      public org.apache.hadoop.hdfs.protocol.ExtendedBlock getCurrentBlock()
      Get the block containing the target position.
    • getAllBlocks

      public List<org.apache.hadoop.hdfs.protocol.LocatedBlock> getAllBlocks() throws IOException
      Get the collection of blocks that has already been located.
      Throws:
      IOException
    • getVisibleLength

      public long getVisibleLength()
      Get the visible length of the file. It will include the length of the last block even if that is in UnderConstruction state.
      Returns:
      The visible length of the file.
    • getReadStatistics

      public org.apache.hadoop.hdfs.ReadStatistics getReadStatistics()
      Get statistics about the reads which this DFSInputStream has done. Note that because HdfsDataInputStream is buffered, these stats may be higher than you would expect just by adding up the number of bytes read through HdfsDataInputStream.
    • clearReadStatistics

      public void clearReadStatistics()