|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
org.apache.hadoop.fs.FSInputStream
org.apache.hadoop.hdfs.DFSInputStream
@InterfaceAudience.Private public class DFSInputStream
DFSInputStream provides bytes from a named file. It handles negotiation of the namenode and various datanodes as necessary.
Method Summary | |
---|---|
int |
available()
Return the size of the remaining available bytes if the size is less than or equal to Integer.MAX_VALUE ,
otherwise, return Integer.MAX_VALUE . |
void |
close()
Close it down! |
protected BlockReader |
getBlockReader(InetSocketAddress dnAddr,
String file,
Block block,
org.apache.hadoop.security.token.Token<BlockTokenIdentifier> blockToken,
long startOffset,
long len,
int bufferSize,
boolean verifyChecksum,
String clientName)
Retrieve a BlockReader suitable for reading. |
Block |
getCurrentBlock()
Returns the block containing the target position. |
DatanodeInfo |
getCurrentDatanode()
Returns the datanode from which the stream is currently reading. |
long |
getFileLength()
|
long |
getPos()
|
void |
mark(int readLimit)
|
boolean |
markSupported()
We definitely don't support marks |
int |
read()
|
int |
read(byte[] buf,
int off,
int len)
Read the entire buffer. |
int |
read(long position,
byte[] buffer,
int offset,
int length)
Read bytes starting from the specified position. |
void |
reset()
|
void |
seek(long targetPos)
Seek to a new arbitrary location |
boolean |
seekToNewSource(long targetPos)
Seek to given position on a node other than the current node. |
long |
skip(long n)
|
Methods inherited from class org.apache.hadoop.fs.FSInputStream |
---|
readFully, readFully |
Methods inherited from class java.io.InputStream |
---|
read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public long getFileLength()
public DatanodeInfo getCurrentDatanode()
public Block getCurrentBlock()
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] buf, int off, int len) throws IOException
read
in class InputStream
IOException
protected BlockReader getBlockReader(InetSocketAddress dnAddr, String file, Block block, org.apache.hadoop.security.token.Token<BlockTokenIdentifier> blockToken, long startOffset, long len, int bufferSize, boolean verifyChecksum, String clientName) throws IOException
dnAddr
- Address of the datanodefile
- File locationblock
- The Block objectblockToken
- The access token for securitystartOffset
- The read offset, relative to block headlen
- The number of bytes to readbufferSize
- The IO buffer size (not the client buffer size)verifyChecksum
- Whether to verify checksumclientName
- Client name
IOException
public int read(long position, byte[] buffer, int offset, int length) throws IOException
read
in interface org.apache.hadoop.fs.PositionedReadable
read
in class org.apache.hadoop.fs.FSInputStream
position
- start read from this positionbuffer
- read bufferoffset
- offset into bufferlength
- number of bytes to read
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
public void seek(long targetPos) throws IOException
seek
in interface org.apache.hadoop.fs.Seekable
seek
in class org.apache.hadoop.fs.FSInputStream
IOException
public boolean seekToNewSource(long targetPos) throws IOException
seekToNewSource
in interface org.apache.hadoop.fs.Seekable
seekToNewSource
in class org.apache.hadoop.fs.FSInputStream
IOException
public long getPos() throws IOException
getPos
in interface org.apache.hadoop.fs.Seekable
getPos
in class org.apache.hadoop.fs.FSInputStream
IOException
public int available() throws IOException
Integer.MAX_VALUE
,
otherwise, return Integer.MAX_VALUE
.
available
in class InputStream
IOException
public boolean markSupported()
markSupported
in class InputStream
public void mark(int readLimit)
mark
in class InputStream
public void reset() throws IOException
reset
in class InputStream
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |