BuiltInGzipDecompressor (Hadoop 1.2.1 API)
Date: 2013-07-22

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.hadoop.io.compress.zlib
Class BuiltInGzipDecompressor

    java.lang.Object
      org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor

All Implemented Interfaces:
  Decompressor

    @DoNotPool
    public class BuiltInGzipDecompressor

extends Object
implements Decompressor

A `Decompressor` based on the popular gzip compressed file format. http://www.gzip.org/

Constructor Summary
`BuiltInGzipDecompressor()` Creates a new (pure Java) gzip decompressor.

Method Summary
`int` | `decompress(byte[] b, int off, int len)` Decompress the data (gzip header, deflate stream, gzip trailer) in the provided buffer.
`void` | `end()` Closes the decompressor and discards any unprocessed input.
`boolean` | `finished()` Returns true if the end of the gzip substream (single "member") has been reached.
`long` | `getBytesRead()` Returns the total number of compressed bytes input so far, including gzip header/trailer bytes.
`int` | `getRemaining()` Returns the number of bytes remaining in the input buffer; normally called when finished() is true to determine amount of post-gzip-stream data.
`boolean` | `needsDictionary()` Returns `true` if a preset dictionary is needed for decompression.
`boolean` | `needsInput()` Returns true if the input data buffer is empty and `Decompressor.setInput(byte[], int, int)` should be called to provide more input.
`void` | `reset()` Resets everything, including the input buffer, regardless of whether the current gzip substream is finished.
`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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BuiltInGzipDecompressor

    public BuiltInGzipDecompressor()

  Creates a new (pure Java) gzip decompressor.

Method Detail

### needsInput

    public boolean needsInput()

  Returns true if the input data buffer is empty and `Decompressor.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 `Decompressor.setInput(byte[], int, int)` should be called in order to provide more input.

### setInput

    public void setInput(byte[] b,
                         int off,
                         int len)

  Sets input data for decompression. This should be called if and only if `Decompressor.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 `Decompressor.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

### decompress

    public int decompress(byte[] b,
                          int off,
                          int len)
                   throws IOException

  Decompress the data (gzip header, deflate stream, gzip trailer) in the provided buffer.

  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 number of decompressed bytes placed into b
  Throws:
    `IOException`

### getBytesRead

    public long getBytesRead()

  Returns the total number of compressed bytes input so far, including gzip header/trailer bytes.

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

### getRemaining

    public int getRemaining()

  Returns the number of bytes remaining in the input buffer; normally called when finished() is true to determine amount of post-gzip-stream data. Note that, other than the finished state with concatenated data after the end of the current gzip stream, this will never return a non-zero value unless called after `setInput(byte[] b, int off, int len)` and before `decompress(byte[] b, int off, int len)`. (That is, after `decompress(byte[] b, int off, int len)` it always returns zero, except in finished state with concatenated data.)

  Specified by:
    `getRemaining` in interface `Decompressor`
  Returns:
    the total (non-negative) number of unprocessed bytes in input

### needsDictionary

    public boolean needsDictionary()

  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

### setDictionary

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

  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

### finished

    public boolean finished()

  Returns true if the end of the gzip substream (single "member") has been reached.

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

### reset

    public void reset()

  Resets everything, including the input buffer, regardless of whether the current gzip substream is finished.

  Specified by:
    `reset` in interface `Decompressor`

### end

    public void end()

  Closes the decompressor and discards any unprocessed input.

  Specified by:
    `end` in interface `Decompressor`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 The Apache Software Foundation