41 : m_workmem(0), m_offset(0), m_fp_len(19) {
49 #define _NEXT_ARG(_code_) do { \
51 HT_EXPECT(it != arg_end, Error::BLOCK_COMPRESSOR_INVALID_ARG); \
57 Args::const_iterator it = args.begin(), arg_end = args.end();
59 for (; it != arg_end; ++it) {
60 if (*it ==
"--fp-len")
62 else if (*it ==
"--offset")
64 else HT_ERRORF(
"unknown bmz compressor argument: %s", (*it).c_str());
73 size_t inlen = input.
fill();
77 output.
reserve(outlen + headerlen + reserve);
85 if (outlen >= inlen) {
87 memcpy(output.
base + headerlen, input.
base, inlen);
107 const uint8_t *ip = input.
base;
108 size_t remain = input.
fill();
110 header.
decode(&ip, &remain);
121 memcpy(output.
base, ip, outlen);
131 output.
ptr = output.
base + outlen;
int bmz_pack(const void *in, size_t in_len, void *out, size_t *out_len_p, size_t offset, size_t fp_len, unsigned flags, void *work_mem)
Perform bmz compression.
virtual void set_args(const Args &args)
Sets arguments to control compression behavior.
size_t m_offset
Starting offset of fingerprints.
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.
#define HT_EXPECT(_e_, _code_)
uint32_t fletcher32(const void *data8, size_t len8)
Compute fletcher32 checksum for arbitary data.
Bentley-McIlroy large common substring compression.
BlockCompressionCodecBmz(const Args &args)
Constructor.
virtual void deflate(const DynamicBuffer &input, DynamicBuffer &output, BlockHeader &header, size_t reserve=0)
Compresses a buffer using the BMZ algorithm.
Logging routines and macros.
Compatibility Macros for C/C++.
size_t m_fp_len
Fingerprint length.
int bmz_init()
Perform bmz initialization only needs to be called once, mostly for sanity checks.
int bmz_unpack(const void *in, size_t in_len, void *out, size_t *out_len_p, void *work_mem)
Perform bmz decompression.
Importing boost::thread and boost::thread_group into the Hypertable namespace.
size_t bmz_pack_buflen(size_t in_len)
Compute bmz compression output buffer length.
size_t bmz_unpack_worklen(size_t out_len)
Return size of work memory for bmz decompression.
virtual ~BlockCompressionCodecBmz()
Destructor.
Implementation of checksum routines.
virtual void inflate(const DynamicBuffer &input, DynamicBuffer &output, BlockHeader &header)
Decompresses a buffer compressed with the BMZ algorithm.
DynamicBuffer m_workmem
Working memory buffer used by deflate() and inflate()
uint8_t * base
Pointer to the allocated memory buffer.
size_t fill() const
Returns the size of the used portion.
#define HT_ERRORF(msg,...)
#define _NEXT_ARG(_code_)
Declarations for BlockCompressionCodecBmz.
size_t bmz_pack_worklen(size_t in_len, size_t fp_len)
Return size of work memory for bmz compression.
void reserve(size_t len, bool nocopy=false)
Reserve space for additional data Will grow the space to exactly what's needed.