0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
Hypertable::BlockCompressionCodecZlib Class Reference

Block compressor that uses the ZLIB algorithm. More...

#include <BlockCompressionCodecZlib.h>

Inheritance diagram for Hypertable::BlockCompressionCodecZlib:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::BlockCompressionCodecZlib:
Collaboration graph
[legend]

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< StringArgs
 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

BlockCompressionCodecZlib::BlockCompressionCodecZlib ( const Args args)

Definition at line 33 of file BlockCompressionCodecZlib.cc.

BlockCompressionCodecZlib::~BlockCompressionCodecZlib ( )
virtual

Definition at line 40 of file BlockCompressionCodecZlib.cc.

Member Function Documentation

void BlockCompressionCodecZlib::deflate ( const DynamicBuffer input,
DynamicBuffer output,
BlockHeader header,
size_t  reserve = 0 
)
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:

headercompressed datareserve
Parameters
inputInput buffer
outputOutput buffer
headerBlock header populated by function
reserveAdditional space to reserve at end of output buffer

Implements Hypertable::BlockCompressionCodec.

Definition at line 73 of file BlockCompressionCodecZlib.cc.

virtual int Hypertable::BlockCompressionCodecZlib::get_type ( )
inlinevirtual

Returns enum value representing compression type ZLIB.

Returns the enum value ZLIB

See also
BlockCompressionCodec::ZLIB
Returns
Compression type (ZLIB)

Implements Hypertable::BlockCompressionCodec.

Definition at line 111 of file BlockCompressionCodecZlib.h.

void BlockCompressionCodecZlib::inflate ( const DynamicBuffer input,
DynamicBuffer output,
BlockHeader header 
)
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.

See also
deflate() for description of input buffer format
Parameters
inputInput buffer
outputOutput buffer
headerBlock header

Implements Hypertable::BlockCompressionCodec.

Definition at line 132 of file BlockCompressionCodecZlib.cc.

void BlockCompressionCodecZlib::set_args ( const Args args)
virtual

Sets arguments to control compression behavior.

The arguments accepted by this method are described in the following table.

ArgumentDescription
–best or –9 Best compression ratio
–normal Normal compression ratio
Parameters
argsVector of arguments

Reimplemented from Hypertable::BlockCompressionCodec.

Definition at line 47 of file BlockCompressionCodecZlib.cc.

Member Data Documentation

bool Hypertable::BlockCompressionCodecZlib::m_deflate_initialized
private

Flag indicating that deflate state has been initialized.

Definition at line 125 of file BlockCompressionCodecZlib.h.

bool Hypertable::BlockCompressionCodecZlib::m_inflate_initialized
private

Flag indicating that inflate state has been initialized.

Definition at line 119 of file BlockCompressionCodecZlib.h.

int Hypertable::BlockCompressionCodecZlib::m_level
private

Compression level.

Definition at line 128 of file BlockCompressionCodecZlib.h.

z_stream Hypertable::BlockCompressionCodecZlib::m_stream_deflate
private

Deflate state.

Definition at line 122 of file BlockCompressionCodecZlib.h.

z_stream Hypertable::BlockCompressionCodecZlib::m_stream_inflate
private

Inflate state.

Definition at line 116 of file BlockCompressionCodecZlib.h.


The documentation for this class was generated from the following files: