org.apache.hadoop.mapred
Class IFileInputStream
java.lang.Object
java.io.InputStream
org.apache.hadoop.mapred.IFileInputStream
- All Implemented Interfaces:
- Closeable
@InterfaceAudience.Private
@InterfaceStability.Unstable
public class IFileInputStream
- extends InputStream
A checksum input stream, used for IFiles.
Used to validate the checksum of files created by IFileOutputStream
.
Field Summary |
static org.apache.commons.logging.Log |
LOG
|
Constructor Summary |
IFileInputStream(InputStream in,
long len,
org.apache.hadoop.conf.Configuration conf)
Create a checksum input stream that reads |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOG
public static final org.apache.commons.logging.Log LOG
IFileInputStream
public IFileInputStream(InputStream in,
long len,
org.apache.hadoop.conf.Configuration conf)
- Create a checksum input stream that reads
- Parameters:
in
- The input stream to be verified for checksum.len
- The length of the input stream including checksum bytes.
close
public void close()
throws IOException
- Close the input stream. Note that we need to read to the end of the
stream to validate the checksum.
- Specified by:
close
in interface Closeable
- Overrides:
close
in class InputStream
- Throws:
IOException
skip
public long skip(long n)
throws IOException
- Overrides:
skip
in class InputStream
- Throws:
IOException
getPosition
public long getPosition()
getSize
public long getSize()
read
public int read(byte[] b,
int off,
int len)
throws IOException
- Read bytes from the stream.
At EOF, checksum is validated, but the checksum
bytes are not passed back in the buffer.
- Overrides:
read
in class InputStream
- Throws:
IOException
readWithChecksum
public int readWithChecksum(byte[] b,
int off,
int len)
throws IOException
- Read bytes from the stream.
At EOF, checksum is validated and sent back
as the last four bytes of the buffer. The caller should handle
these bytes appropriately
- Throws:
IOException
read
public int read()
throws IOException
- Specified by:
read
in class InputStream
- Throws:
IOException
getChecksum
public byte[] getChecksum()
Copyright © 2014 Apache Software Foundation. All Rights Reserved.