Package org.apache.hadoop.io.compress
Interface Decompressor
@Public
@Evolving
public interface Decompressor
Specification of a stream-based 'de-compressor' which can be
plugged into a
CompressionInputStream to compress data.
This is modelled after Inflater-
Method Summary
Modifier and TypeMethodDescriptionintdecompress(byte[] b, int off, int len) Fills specified buffer with uncompressed data.voidend()Closes the decompressor and discards any unprocessed input.booleanfinished()Returnstrueif the end of the decompressed data output stream has been reached.intReturns the number of bytes remaining in the compressed data buffer.booleanReturnstrueif a preset dictionary is needed for decompression.booleanReturnstrueif 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) Sets preset dictionary for compression.voidsetInput(byte[] b, int off, int len) Sets input data for decompression.
-
Method Details
-
setInput
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.)- Parameters:
b- Input dataoff- Start offsetlen- Length
-
needsInput
boolean needsInput()Returnstrueif the input data buffer is empty andsetInput(byte[], int, int)should be called to provide more input.- Returns:
trueif the input data buffer is empty andsetInput(byte[], int, int)should be called in order to provide more input.
-
setDictionary
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.- Parameters:
b- Dictionary data bytesoff- Start offsetlen- Length
-
needsDictionary
boolean needsDictionary()Returnstrueif a preset dictionary is needed for decompression.- Returns:
trueif a preset dictionary is needed for decompression
-
finished
boolean finished()Returnstrueif the end of the decompressed data output stream has been reached. Indicates a concatenated data stream when finished() returnstrueandgetRemaining()returns a positive value. finished() will be reset with thereset()method.- 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.- Parameters:
b- Buffer for the uncompressed dataoff- Start offset of the datalen- Size of the buffer- Returns:
- The actual number of bytes of uncompressed data.
- Throws:
IOException- raised on errors performing I/O.
-
getRemaining
int getRemaining()Returns the number of bytes remaining in the compressed data buffer. Indicates a concatenated data stream iffinished()returnstrueand getRemaining() returns a positive value. Iffinished()returnstrueand getRemaining() returns a zero value, indicates that the end of data stream has been reached and is not a concatenated data stream.- Returns:
- The number of bytes remaining in the compressed data buffer.
-
reset
void reset()Resets decompressor and input and output buffers so that a new set of input data can be processed. Iffinished()} returnstrueandgetRemaining()returns a positive value, reset() is called before processing of the next data stream in the concatenated data stream.finished()will be reset and will returnfalsewhen reset() is called. -
end
void end()Closes the decompressor and discards any unprocessed input.
-