org.apache.hadoop.io.compress.snappy
Class SnappyDecompressor

java.lang.Object
  extended by org.apache.hadoop.io.compress.snappy.SnappyDecompressor
All Implemented Interfaces:
Decompressor

public class SnappyDecompressor
extends Object
implements Decompressor

A Decompressor based on the snappy compression algorithm. http://code.google.com/p/snappy/


Constructor Summary
SnappyDecompressor()
          Creates a new decompressor with the default buffer size.
SnappyDecompressor(int directBufferSize)
          Creates a new compressor.
 
Method Summary
 int decompress(byte[] b, int off, int len)
          Fills specified buffer with uncompressed data.
 void end()
          Resets decompressor and input and output buffers so that a new set of input data can be processed.
 boolean finished()
          Returns true if the end of the decompressed data output stream has been reached.
 int getRemaining()
          Returns 0.
 boolean needsDictionary()
          Returns false.
 boolean needsInput()
          Returns true if the input data buffer is empty and setInput(byte[], int, int) should be called to provide more input.
 void reset()
          Resets decompressor and input and output buffers so that a new set of input data can be processed.
 void setDictionary(byte[] b, int off, int len)
          Does nothing.
 void setInput(byte[] b, int off, int len)
          Sets input data for decompression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnappyDecompressor

public SnappyDecompressor(int directBufferSize)
Creates a new compressor.

Parameters:
directBufferSize - size of the direct buffer to be used.

SnappyDecompressor

public SnappyDecompressor()
Creates a new decompressor with the default buffer size.

Method Detail

setInput

public void setInput(byte[] b,
                     int off,
                     int len)
Sets input data for decompression. This should be called if and only if needsInput() returns true indicating that more input data is required. (Both native and non-native versions of various Decompressors require that the data passed in via b[] remain unmodified until the caller is explicitly notified--via needsInput()--that the buffer may be safely modified. With this requirement, an extra buffer-copy can be avoided.)

Specified by:
setInput in interface Decompressor
Parameters:
b - Input data
off - Start offset
len - Length

setDictionary

public void setDictionary(byte[] b,
                          int off,
                          int len)
Does nothing.

Specified by:
setDictionary in interface Decompressor
Parameters:
b - Dictionary data bytes
off - Start offset
len - Length

needsInput

public boolean needsInput()
Returns true if the input data buffer is empty and setInput(byte[], int, int) should be called to provide more input.

Specified by:
needsInput in interface Decompressor
Returns:
true if the input data buffer is empty and setInput(byte[], int, int) should be called in order to provide more input.

needsDictionary

public boolean needsDictionary()
Returns false.

Specified by:
needsDictionary in interface Decompressor
Returns:
false.

finished

public boolean finished()
Returns true if the end of the decompressed data output stream has been reached.

Specified by:
finished in interface Decompressor
Returns:
true if the end of the decompressed data output stream has been reached.

decompress

public int decompress(byte[] b,
                      int off,
                      int len)
               throws IOException
Fills specified buffer with uncompressed data. Returns actual number of bytes of uncompressed data. A return value of 0 indicates that needsInput() should be called in order to determine if more input data is required.

Specified by:
decompress in interface Decompressor
Parameters:
b - Buffer for the compressed data
off - Start offset of the data
len - Size of the buffer
Returns:
The actual number of bytes of compressed data.
Throws:
IOException

getRemaining

public int getRemaining()
Returns 0.

Specified by:
getRemaining in interface Decompressor
Returns:
0.

reset

public void reset()
Description copied from interface: Decompressor
Resets decompressor and input and output buffers so that a new set of input data can be processed.

Specified by:
reset in interface Decompressor

end

public void end()
Resets decompressor and input and output buffers so that a new set of input data can be processed.

Specified by:
end in interface Decompressor


Copyright © 2009 The Apache Software Foundation