org.apache.hadoop.io.compress.zlib
Class ZlibDecompressor

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

public class ZlibDecompressor
extends Object
implements Decompressor

A Decompressor based on the popular zlib compression algorithm. http://www.zlib.net/


Nested Class Summary
static class ZlibDecompressor.CompressionHeader
          The headers to detect from compressed data.
 
Constructor Summary
ZlibDecompressor()
           
ZlibDecompressor(ZlibDecompressor.CompressionHeader header, int directBufferSize)
          Creates a new decompressor.
 
Method Summary
 int decompress(byte[] b, int off, int len)
          Fills specified buffer with uncompressed data.
 void end()
          Closes the decompressor and discards any unprocessed input.
protected  void finalize()
           
 boolean finished()
          Returns true if the end of the compressed data output stream has been reached.
 long getBytesRead()
          Returns the total number of uncompressed bytes input so far.
 long getBytesWritten()
          Returns the total number of compressed bytes output so far.
 boolean needsDictionary()
          Returns true if a preset dictionary is needed for decompression.
 boolean needsInput()
          Returns true if the input data buffer is empty and #setInput() should be called to provide more input.
 void reset()
          Resets decompressor so that a new set of input data can be processed.
 void setDictionary(byte[] b, int off, int len)
          Sets preset dictionary for compression.
 void setInput(byte[] b, int off, int len)
          Sets input data for decompression.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZlibDecompressor

public ZlibDecompressor(ZlibDecompressor.CompressionHeader header,
                        int directBufferSize)
Creates a new decompressor.


ZlibDecompressor

public ZlibDecompressor()
Method Detail

setInput

public void setInput(byte[] b,
                     int off,
                     int len)
Description copied from interface: Decompressor
Sets input data for decompression. This should be called whenever #needsInput() returns true indicating that more input data is required.

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)
Description copied from interface: Decompressor
Sets preset dictionary for compression. A preset dictionary is used when the history buffer can be predetermined.

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

needsInput

public boolean needsInput()
Description copied from interface: Decompressor
Returns true if the input data buffer is empty and #setInput() should be called to provide more input.

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

needsDictionary

public boolean needsDictionary()
Description copied from interface: Decompressor
Returns true if a preset dictionary is needed for decompression.

Specified by:
needsDictionary in interface Decompressor
Returns:
true if a preset dictionary is needed for decompression

finished

public boolean finished()
Description copied from interface: Decompressor
Returns true if the end of the compressed data output stream has been reached.

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

decompress

public int decompress(byte[] b,
                      int off,
                      int len)
               throws IOException
Description copied from interface: Decompressor
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

getBytesWritten

public long getBytesWritten()
Returns the total number of compressed bytes output so far.

Returns:
the total (non-negative) number of compressed bytes output so far

getBytesRead

public long getBytesRead()
Returns the total number of uncompressed bytes input so far.

Returns:
the total (non-negative) number of uncompressed bytes input so far

reset

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

Specified by:
reset in interface Decompressor

end

public void end()
Description copied from interface: Decompressor
Closes the decompressor and discards any unprocessed input.

Specified by:
end in interface Decompressor

finalize

protected void finalize()
Overrides:
finalize in class Object


Copyright © 2008 The Apache Software Foundation