Class SnappyDecompressor
java.lang.Object
org.apache.hadoop.io.compress.snappy.SnappyDecompressor
- All Implemented Interfaces:
Decompressor
- Direct Known Subclasses:
SnappyDecompressor.SnappyDirectDecompressor
A
Decompressor based on the snappy compression algorithm.
http://code.google.com/p/snappy/-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new decompressor with the default buffer size.SnappyDecompressor(int directBufferSize) Creates a new compressor. -
Method Summary
Modifier and TypeMethodDescriptionintdecompress(byte[] b, int off, int len) Fills specified buffer with uncompressed data.voidend()Resets decompressor and input and output buffers so that a new set of input data can be processed.booleanfinished()Returns true if the end of the decompressed data output stream has been reached.intReturns0.booleanReturnsfalse.booleanReturns true if the input data buffer is empty andsetInput(byte[], int, int)should be called to provide more input.voidreset()Resets decompressor and input and output buffers so that a new set of input data can be processed.voidsetDictionary(byte[] b, int off, int len) Does nothing.voidsetInput(byte[] b, int off, int len) Sets input data for decompression.
-
Constructor Details
-
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 Details
-
setInput
public void setInput(byte[] b, int off, int len) Sets input data for decompression. This should be called if and only ifneedsInput()returnstrueindicating that more input data is required. (Both native and non-native versions of various Decompressors require that the data passed in viab[]remain unmodified until the caller is explicitly notified--vianeedsInput()--that the buffer may be safely modified. With this requirement, an extra buffer-copy can be avoided.)- Specified by:
setInputin interfaceDecompressor- Parameters:
b- Input dataoff- Start offsetlen- Length
-
setDictionary
public void setDictionary(byte[] b, int off, int len) Does nothing.- Specified by:
setDictionaryin interfaceDecompressor- Parameters:
b- Dictionary data bytesoff- Start offsetlen- Length
-
needsInput
public boolean needsInput()Returns true if the input data buffer is empty andsetInput(byte[], int, int)should be called to provide more input.- Specified by:
needsInputin interfaceDecompressor- Returns:
trueif the input data buffer is empty andsetInput(byte[], int, int)should be called in order to provide more input.
-
needsDictionary
public boolean needsDictionary()Returnsfalse.- Specified by:
needsDictionaryin interfaceDecompressor- Returns:
false.
-
finished
public boolean finished()Returns true if the end of the decompressed data output stream has been reached.- Specified by:
finishedin interfaceDecompressor- Returns:
trueif the end of the decompressed data output stream has been reached.
-
decompress
Fills specified buffer with uncompressed data. Returns actual number of bytes of uncompressed data. A return value of 0 indicates thatneedsInput()should be called in order to determine if more input data is required.- Specified by:
decompressin interfaceDecompressor- Parameters:
b- Buffer for the uncompressed dataoff- Start offset of the datalen- Size of the buffer- Returns:
- The actual number of bytes of compressed data.
- Throws:
IOException- raised on errors performing I/O.
-
getRemaining
public int getRemaining()Returns0.- Specified by:
getRemainingin interfaceDecompressor- Returns:
0.
-
reset
public void reset()Description copied from interface:DecompressorResets decompressor and input and output buffers so that a new set of input data can be processed. IfDecompressor.finished()} returnstrueandDecompressor.getRemaining()returns a positive value, reset() is called before processing of the next data stream in the concatenated data stream.Decompressor.finished()will be reset and will returnfalsewhen reset() is called.- Specified by:
resetin interfaceDecompressor
-
end
public void end()Resets decompressor and input and output buffers so that a new set of input data can be processed.- Specified by:
endin interfaceDecompressor
-