org.apache.hadoop.hdfs.client
Class HdfsDataInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.DataInputStream
              extended by org.apache.hadoop.fs.FSDataInputStream
                  extended by org.apache.hadoop.hdfs.client.HdfsDataInputStream
All Implemented Interfaces:
Closeable, DataInput, org.apache.hadoop.fs.ByteBufferReadable, org.apache.hadoop.fs.CanSetDropBehind, org.apache.hadoop.fs.CanSetReadahead, org.apache.hadoop.fs.HasFileDescriptor, org.apache.hadoop.fs.PositionedReadable, org.apache.hadoop.fs.Seekable
Direct Known Subclasses:
DFSClient.DFSDataInputStream

@InterfaceAudience.Public
@InterfaceStability.Evolving
public class HdfsDataInputStream
extends org.apache.hadoop.fs.FSDataInputStream

The Hdfs implementation of FSDataInputStream.


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
HdfsDataInputStream(org.apache.hadoop.hdfs.DFSInputStream in)
           
 
Method Summary
 List<org.apache.hadoop.hdfs.protocol.LocatedBlock> getAllBlocks()
          Get the collection of blocks that has already been located.
 org.apache.hadoop.hdfs.protocol.ExtendedBlock getCurrentBlock()
          Get the block containing the target position.
 org.apache.hadoop.hdfs.protocol.DatanodeInfo getCurrentDatanode()
          Get the datanode from which the stream is currently reading.
 DFSInputStream.ReadStatistics getReadStatistics()
          Get statistics about the reads which this DFSInputStream has done.
 long getVisibleLength()
          Get the visible length of the file.
 
Methods inherited from class org.apache.hadoop.fs.FSDataInputStream
getFileDescriptor, getPos, read, read, readFully, readFully, seek, seekToNewSource, setDropBehind, setReadahead
 
Methods inherited from class java.io.DataInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.Closeable
close
 

Constructor Detail

HdfsDataInputStream

public HdfsDataInputStream(org.apache.hadoop.hdfs.DFSInputStream in)
                    throws IOException
Throws:
IOException
Method Detail

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()
                      throws IOException
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.
Throws:
IOException

getReadStatistics

public DFSInputStream.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.



Copyright © 2013 Apache Software Foundation. All Rights Reserved.