org.apache.hadoop.mapred
Class IFileInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by 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.


Constructor Summary
IFileInputStream(InputStream in, long len)
          Create a checksum input stream that reads
 
Method Summary
 void close()
          Close the input stream.
 byte[] getChecksum()
           
 long getPosition()
           
 long getSize()
           
 int read()
           
 int read(byte[] b, int off, int len)
          Read bytes from the stream.
 int readWithChecksum(byte[] b, int off, int len)
          Read bytes from the stream.
 long skip(long n)
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IFileInputStream

public IFileInputStream(InputStream in,
                        long len)
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.
Method Detail

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 © 2012 Apache Software Foundation. All Rights Reserved.