Compressorpublic class Bzip2Compressor extends java.lang.Object implements Compressor
Compressor based on the popular
bzip2 compression algorithm.
http://www.bzip2.org/| Constructor | Description |
|---|---|
Bzip2Compressor() |
Creates a new compressor with a default values for the
compression block size and work factor.
|
Bzip2Compressor(int blockSize,
int workFactor,
int directBufferSize) |
Creates a new compressor using the specified block size.
|
Bzip2Compressor(Configuration conf) |
Creates a new compressor, taking settings from the configuration.
|
| Modifier and Type | Method | Description |
|---|---|---|
int |
compress(byte[] b,
int off,
int len) |
Fills specified buffer with compressed data.
|
void |
end() |
Closes the compressor and discards any unprocessed input.
|
void |
finish() |
When called, indicates that compression should end
with the current contents of the input buffer.
|
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.
|
static java.lang.String |
getLibraryName() |
|
boolean |
needsInput() |
Returns true if the input data buffer is empty and
#setInput() should be called to provide more input.
|
void |
reinit(Configuration conf) |
Prepare the compressor to be used in a new stream with settings defined in
the given Configuration.
|
void |
reset() |
Resets compressor 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 compression.
|
public Bzip2Compressor()
public Bzip2Compressor(Configuration conf)
conf - configuration.public Bzip2Compressor(int blockSize,
int workFactor,
int directBufferSize)
blockSize - The block size to be used for compression. This is
an integer from 1 through 9, which is multiplied by 100,000 to
obtain the actual block size in bytes.workFactor - This parameter is a threshold that determines when a
fallback algorithm is used for pathological data. It ranges from
0 to 250.directBufferSize - Size of the direct buffer to be used.public void reinit(Configuration conf)
reinit in interface Compressorconf - Configuration storing new settingspublic void setInput(byte[] b,
int off,
int len)
Compressortrue indicating that more input data is required.setInput in interface Compressorb - Input dataoff - Start offsetlen - Lengthpublic void setDictionary(byte[] b,
int off,
int len)
CompressorsetDictionary in interface Compressorb - Dictionary data bytesoff - Start offsetlen - Lengthpublic boolean needsInput()
CompressorneedsInput in interface Compressortrue if the input data buffer is empty and
#setInput() should be called in order to provide more input.public void finish()
Compressorfinish in interface Compressorpublic boolean finished()
Compressorfinished in interface Compressortrue if the end of the compressed
data output stream has been reached.public int compress(byte[] b,
int off,
int len)
throws java.io.IOException
Compressorcompress in interface Compressorb - Buffer for the compressed dataoff - Start offset of the datalen - Size of the bufferjava.io.IOException - raised on errors performing I/O.public long getBytesWritten()
getBytesWritten in interface Compressorpublic long getBytesRead()
getBytesRead in interface Compressorpublic void reset()
Compressorreset in interface Compressorpublic void end()
Compressorend in interface Compressorpublic static java.lang.String getLibraryName()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.