evio
6.0
|
Singleton class used to provide data compression and decompression in a variety of formats. More...
#include <Compressor.h>
Public Types | |
enum | CompressionType { UNCOMPRESSED = 0, LZ4, LZ4_BEST, GZIP } |
Enum of supported data compression types. More... | |
Static Public Member Functions | |
static Compressor & | getInstance () |
Get an instance of this singleton class. More... | |
static CompressionType | toCompressionType (uint32_t type) |
Method to convert an integer to a CompressionType object. More... | |
static int | getMaxCompressedLength (CompressionType compressionType, uint32_t uncompressedLength) |
Returns the maximum number of bytes needed to compress the given length of uncompressed data. More... | |
static int | compressLZ4 (ByteBuffer &src, int srcSize, ByteBuffer &dst, int maxSize) |
Fastest LZ4 compression. More... | |
static int | compressLZ4 (uint8_t *src, int srcOff, int srcSize, uint8_t *dst, int dstOff, int maxSize) |
Fastest LZ4 compression. More... | |
static int | compressLZ4 (ByteBuffer &src, int srcOff, int srcSize, ByteBuffer &dst, int dstOff, int maxSize) |
Fastest LZ4 compression. More... | |
static int | compressLZ4Best (ByteBuffer &src, int srcSize, ByteBuffer &dst, int maxSize) |
Highest LZ4 compression. More... | |
static int | compressLZ4Best (uint8_t *src, int srcOff, int srcSize, uint8_t *dst, int dstOff, int maxSize) |
Highest LZ4 compression. More... | |
static int | compressLZ4Best (ByteBuffer &src, int srcOff, int srcSize, ByteBuffer &dst, int dstOff, int maxSize) |
Highest LZ4 compression. More... | |
static int | uncompressLZ4 (ByteBuffer &src, int srcSize, ByteBuffer &dst) |
LZ4 decompression. More... | |
static int | uncompressLZ4 (ByteBuffer &src, int srcOff, int srcSize, ByteBuffer &dst) |
LZ4 decompression. More... | |
static int | uncompressLZ4 (ByteBuffer &src, int srcOff, int srcSize, ByteBuffer &dst, int dstOff) |
LZ4 decompression. More... | |
static int | uncompressLZ4 (uint8_t *src, int srcOff, int srcSize, uint8_t *dst, int dstOff, int dstCapacity) |
LZ4 decompression. More... | |
Singleton class used to provide data compression and decompression in a variety of formats.
This class in NOT thread safe when using the gzip deflating and inflating routines.
|
static |
Fastest LZ4 compression.
Returns length of compressed data in bytes.
src | source of uncompressed data from position. |
srcSize | number of bytes to compress. |
dst | destination buffer from position. |
maxSize | maximum number of bytes to write in dst. |
EvioException | if maxSize < max # of compressed bytes or compression failed. |
References evio::ByteBuffer::array(), and evio::ByteBuffer::position().
Referenced by evio::RecordOutput::build().
|
static |
Fastest LZ4 compression.
Returns length of compressed data in bytes.
src | source of uncompressed data. |
srcOff | start offset in src. |
srcSize | number of bytes to compress. |
dst | destination array. |
dstOff | start offset in dst. |
maxSize | maximum number of bytes to write in dst. |
EvioException | if maxSize < max # of compressed bytes or compression failed. |
|
static |
Fastest LZ4 compression.
Returns length of compressed data in bytes.
src | source of uncompressed data. |
srcOff | start offset in src regardless of position. |
srcSize | number of bytes to compress. |
dst | destination array. |
dstOff | start offset in dst regardless of position. |
maxSize | maximum number of bytes to write in dst. |
EvioException | if maxSize < max # of compressed bytes or compression failed. |
References evio::ByteBuffer::array().
|
static |
Highest LZ4 compression.
Returns length of compressed data in bytes.
src | source of uncompressed data starting at position. |
srcSize | number of bytes to compress. |
dst | destination buffer starting at position. |
maxSize | maximum number of bytes to write in dst. |
EvioException | if maxSize < max # of compressed bytes or compression failed. |
References evio::ByteBuffer::array(), and evio::ByteBuffer::position().
Referenced by evio::RecordOutput::build().
|
static |
Highest LZ4 compression.
Returns length of compressed data in bytes.
src | source of uncompressed data. |
srcOff | start offset in src. |
srcSize | number of bytes to compress. |
dst | destination array. |
dstOff | start offset in dst. |
maxSize | maximum number of bytes to write in dst. |
EvioException | if maxSize < max # of compressed bytes or compression failed. |
|
static |
Highest LZ4 compression.
Returns length of compressed data in bytes.
src | source of uncompressed data. |
srcOff | start offset in src. |
srcSize | number of bytes to compress. |
dst | destination array. |
dstOff | start offset in dst. |
maxSize | maximum number of bytes to write in dst. |
EvioException | if maxSize < max # of compressed bytes or compression failed. |
References evio::ByteBuffer::array().
|
inlinestatic |
Get an instance of this singleton class.
Referenced by evio::RecordOutput::build(), evio::RecordInput::readRecord(), and evio::RecordInput::uncompressRecord().
|
static |
Returns the maximum number of bytes needed to compress the given length of uncompressed data.
Depends on compression type. Unknown for gzip.
compressionType | type of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip). Default to none. |
uncompressedLength | uncompressed data length in bytes. |
References GZIP, LZ4, LZ4_BEST, and UNCOMPRESSED.
|
static |
Method to convert an integer to a CompressionType object.
type | integer to convert. |
References GZIP, LZ4, LZ4_BEST, and UNCOMPRESSED.
|
static |
LZ4 decompression.
Returns original length of decompressed data in bytes.
src | source of compressed data. |
srcSize | number of compressed bytes. |
dst | destination array. |
EvioException | if destination buffer is too small to hold uncompressed data or source data is malformed. |
References evio::ByteBuffer::position().
Referenced by evio::RecordInput::readRecord(), and evio::RecordInput::uncompressRecord().
|
static |
LZ4 decompression.
Returns original length of decompressed data in bytes.
src | source of compressed data. |
srcOff | start offset in src. |
srcSize | number of compressed bytes. |
dst | destination array. |
EvioException | if destination buffer is too small to hold uncompressed data or source data is malformed. |
References evio::ByteBuffer::array(), evio::ByteBuffer::limit(), evio::ByteBuffer::position(), and evio::ByteBuffer::remaining().
|
static |
LZ4 decompression.
Returns original length of decompressed data in bytes.
src | source of compressed data. |
srcOff | start offset in src. |
srcSize | number of compressed bytes. |
dst | destination array. |
dstOff | start offset in dst. |
EvioException | if destination buffer is too small to hold uncompressed data or source data is malformed. |
References evio::ByteBuffer::array(), evio::ByteBuffer::limit(), and evio::ByteBuffer::remaining().
|
static |
LZ4 decompression.
Returns original length of decompressed data in bytes.
src | source of compressed data. |
srcOff | start offset in src. |
srcSize | number of compressed bytes. |
dst | destination array. |
dstOff | start offset in dst. |
dstCapacity | size of destination buffer in bytes, which must be already allocated. |
EvioException | if uncompressed data bytes > dstCapacity or source data is malformed. |