Block compressor that uses the ZLIB algorithm. More...
#include <BlockCompressionCodecZlib.h>
Public Member Functions | |
BlockCompressionCodecZlib (const Args &args) | |
virtual | ~BlockCompressionCodecZlib () |
virtual void | set_args (const Args &args) |
Sets arguments to control compression behavior. More... | |
virtual void | deflate (const DynamicBuffer &input, DynamicBuffer &output, BlockHeader &header, size_t reserve=0) |
Compresses a buffer using the ZLIB algorithm. More... | |
virtual void | inflate (const DynamicBuffer &input, DynamicBuffer &output, BlockHeader &header) |
Decompresses a buffer compressed with the ZLIB algorithm. More... | |
virtual int | get_type () |
Returns enum value representing compression type ZLIB. More... | |
Public Member Functions inherited from Hypertable::BlockCompressionCodec | |
virtual | ~BlockCompressionCodec () |
Destructor. More... | |
Private Attributes | |
z_stream | m_stream_inflate |
Inflate state. More... | |
bool | m_inflate_initialized |
Flag indicating that inflate state has been initialized. More... | |
z_stream | m_stream_deflate |
Deflate state. More... | |
bool | m_deflate_initialized |
Flag indicating that deflate state has been initialized. More... | |
int | m_level |
Compression level. More... | |
Additional Inherited Members | |
Public Types inherited from Hypertable::BlockCompressionCodec | |
enum | Type { UNKNOWN =-1, NONE =0, BMZ =1, ZLIB =2, LZO =3, QUICKLZ =4, SNAPPY =5, COMPRESSION_TYPE_LIMIT =6 } |
Enumeration for compression type. More... | |
typedef std::vector< String > | Args |
Compression codec argument vector. More... | |
Static Public Member Functions inherited from Hypertable::BlockCompressionCodec | |
static const char * | get_compressor_name (uint16_t algo) |
Returns string mnemonic for compression type. More... | |
Block compressor that uses the ZLIB algorithm.
This class provides a way to compress and decompress blocks of data using the libz compression algorithm, a general purpose, dictionary-based compression algorithm that provides a good compression ratio at the expense of speed.
Definition at line 46 of file BlockCompressionCodecZlib.h.
BlockCompressionCodecZlib::BlockCompressionCodecZlib | ( | const Args & | args | ) |
Definition at line 33 of file BlockCompressionCodecZlib.cc.
|
virtual |
Definition at line 40 of file BlockCompressionCodecZlib.cc.
|
virtual |
Compresses a buffer using the ZLIB algorithm.
This method first checks m_deflate_initialized. If is false it initializes m_stream_deflate and sets m_deflate_initialized to true. It then reserves enough space in output
to hold the serialized header
followed by the compressed input followed by reserve
bytes. If the resulting compressed buffer is larger than the input buffer, then the input buffer is copied directly to the output buffer and the compression type is set to BlockCompressionCodec::NONE. Before serailizing header
, the data_length, data_zlength, data_checksum, and compression_type fields are set appropriately. The output buffer is formatted as follows:
header | compressed data | reserve |
input | Input buffer |
output | Output buffer |
header | Block header populated by function |
reserve | Additional space to reserve at end of output buffer |
Implements Hypertable::BlockCompressionCodec.
Definition at line 73 of file BlockCompressionCodecZlib.cc.
|
inlinevirtual |
Returns enum value representing compression type ZLIB.
Returns the enum value ZLIB
Implements Hypertable::BlockCompressionCodec.
Definition at line 111 of file BlockCompressionCodecZlib.h.
|
virtual |
Decompresses a buffer compressed with the ZLIB algorithm.
This method first checks m_inflate_initialized. If is false it initializes m_stream_inflate and sets m_inflate_initialized to true. It then decompresses the input
buffer and fills in header
.
input | Input buffer |
output | Output buffer |
header | Block header |
Implements Hypertable::BlockCompressionCodec.
Definition at line 132 of file BlockCompressionCodecZlib.cc.
|
virtual |
Sets arguments to control compression behavior.
The arguments accepted by this method are described in the following table.
Argument | Description |
---|---|
–best or –9 | Best compression ratio |
–normal | Normal compression ratio |
args | Vector of arguments |
Reimplemented from Hypertable::BlockCompressionCodec.
Definition at line 47 of file BlockCompressionCodecZlib.cc.
|
private |
Flag indicating that deflate state has been initialized.
Definition at line 125 of file BlockCompressionCodecZlib.h.
|
private |
Flag indicating that inflate state has been initialized.
Definition at line 119 of file BlockCompressionCodecZlib.h.
|
private |
Compression level.
Definition at line 128 of file BlockCompressionCodecZlib.h.
|
private |
Deflate state.
Definition at line 122 of file BlockCompressionCodecZlib.h.
|
private |
Inflate state.
Definition at line 116 of file BlockCompressionCodecZlib.h.