34 : m_inflate_initialized(false), m_deflate_initialized(false),
35 m_level(Z_BEST_SPEED) {
48 Args::const_iterator it = args.begin(), arg_end = args.end();
50 for (; it != arg_end; ++it) {
51 if (*it ==
"--best" || *it ==
"-9") {
58 else if (*it ==
"--normal") {
59 m_level = Z_DEFAULT_COMPRESSION;
67 "to Zlib codec: '%s'", (*it).c_str());
76 uint32_t avail_out = input.
fill() + 6 + (((input.
fill() / 16000) + 1) * 5);
99 assert(ret == Z_STREAM_END);
105 if (zlen >= input.
fill()) {
135 const uint8_t *msg_ptr = input.
base;
136 size_t remaining = input.
fill();
151 header.
decode(&msg_ptr, &remaining);
155 "header zlength = %lu, actual = %lu",
162 "checksum mismatch header=%lx, computed=%lx",
180 if (ret != Z_STREAM_END)
182 "inflate error (return value = %d)", ret);
186 "inflate error, expected %lu but only inflated to %lu bytes",
void free()
Frees resources.
bool m_deflate_initialized
Flag indicating that deflate state has been initialized.
z_stream m_stream_deflate
Deflate state.
bool m_inflate_initialized
Flag indicating that inflate state has been initialized.
virtual void deflate(const DynamicBuffer &input, DynamicBuffer &output, BlockHeader &header, size_t reserve=0)
Compresses a buffer using the ZLIB algorithm.
int m_level
Compression level.
virtual ~BlockCompressionCodecZlib()
virtual void inflate(const DynamicBuffer &input, DynamicBuffer &output, BlockHeader &header)
Decompresses a buffer compressed with the ZLIB algorithm.
uint8_t * ptr
Pointer to the end of the used part of the buffer.
A dynamic, resizable and reference counted memory buffer.
std::vector< String > Args
Compression codec argument vector.
uint32_t fletcher32(const void *data8, size_t len8)
Compute fletcher32 checksum for arbitary data.
A dynamic, resizable memory buffer.
z_stream m_stream_inflate
Inflate state.
Logging routines and macros.
Declarations for BlockCompressionCodecZlib.
Compatibility Macros for C/C++.
virtual void set_args(const Args &args)
Sets arguments to control compression behavior.
Implementation of checksum routines.
void clear()
Clears the buffer.
#define HT_THROWF(_code_, _fmt_,...)
uint8_t * base
Pointer to the allocated memory buffer.
BlockCompressionCodecZlib(const Args &args)
size_t fill() const
Returns the size of the used portion.
This is a generic exception class for Hypertable.
long unsigned int Lu
Shortcut for printf formats.
void reserve(size_t len, bool nocopy=false)
Reserve space for additional data Will grow the space to exactly what's needed.