evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evio::Compressor Class Reference

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 CompressorgetInstance ()
 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...
 

Detailed Description

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.

Date
04/29/2019
Author
timmer

Member Enumeration Documentation

Enum of supported data compression types.

Enumerator
UNCOMPRESSED 
LZ4 
LZ4_BEST 
GZIP 

Member Function Documentation

int evio::Compressor::compressLZ4 ( ByteBuffer src,
int  srcSize,
ByteBuffer dst,
int  maxSize 
)
static

Fastest LZ4 compression.

Returns length of compressed data in bytes.

Parameters
srcsource of uncompressed data from position.
srcSizenumber of bytes to compress.
dstdestination buffer from position.
maxSizemaximum number of bytes to write in dst.
Returns
length of compressed data in bytes.
Exceptions
EvioExceptionif maxSize < max # of compressed bytes or compression failed.

References evio::ByteBuffer::array(), and evio::ByteBuffer::position().

Referenced by evio::RecordOutput::build().

int evio::Compressor::compressLZ4 ( uint8_t *  src,
int  srcOff,
int  srcSize,
uint8_t *  dst,
int  dstOff,
int  maxSize 
)
static

Fastest LZ4 compression.

Returns length of compressed data in bytes.

Parameters
srcsource of uncompressed data.
srcOffstart offset in src.
srcSizenumber of bytes to compress.
dstdestination array.
dstOffstart offset in dst.
maxSizemaximum number of bytes to write in dst.
Returns
length of compressed data in bytes.
Exceptions
EvioExceptionif maxSize < max # of compressed bytes or compression failed.
int evio::Compressor::compressLZ4 ( ByteBuffer src,
int  srcOff,
int  srcSize,
ByteBuffer dst,
int  dstOff,
int  maxSize 
)
static

Fastest LZ4 compression.

Returns length of compressed data in bytes.

Parameters
srcsource of uncompressed data.
srcOffstart offset in src regardless of position.
srcSizenumber of bytes to compress.
dstdestination array.
dstOffstart offset in dst regardless of position.
maxSizemaximum number of bytes to write in dst.
Returns
length of compressed data in bytes.
Exceptions
EvioExceptionif maxSize < max # of compressed bytes or compression failed.

References evio::ByteBuffer::array().

int evio::Compressor::compressLZ4Best ( ByteBuffer src,
int  srcSize,
ByteBuffer dst,
int  maxSize 
)
static

Highest LZ4 compression.

Returns length of compressed data in bytes.

Parameters
srcsource of uncompressed data starting at position.
srcSizenumber of bytes to compress.
dstdestination buffer starting at position.
maxSizemaximum number of bytes to write in dst.
Returns
length of compressed data in bytes.
Exceptions
EvioExceptionif maxSize < max # of compressed bytes or compression failed.

References evio::ByteBuffer::array(), and evio::ByteBuffer::position().

Referenced by evio::RecordOutput::build().

int evio::Compressor::compressLZ4Best ( uint8_t *  src,
int  srcOff,
int  srcSize,
uint8_t *  dst,
int  dstOff,
int  maxSize 
)
static

Highest LZ4 compression.

Returns length of compressed data in bytes.

Parameters
srcsource of uncompressed data.
srcOffstart offset in src.
srcSizenumber of bytes to compress.
dstdestination array.
dstOffstart offset in dst.
maxSizemaximum number of bytes to write in dst.
Returns
length of compressed data in bytes.
Exceptions
EvioExceptionif maxSize < max # of compressed bytes or compression failed.
int evio::Compressor::compressLZ4Best ( ByteBuffer src,
int  srcOff,
int  srcSize,
ByteBuffer dst,
int  dstOff,
int  maxSize 
)
static

Highest LZ4 compression.

Returns length of compressed data in bytes.

Parameters
srcsource of uncompressed data.
srcOffstart offset in src.
srcSizenumber of bytes to compress.
dstdestination array.
dstOffstart offset in dst.
maxSizemaximum number of bytes to write in dst.
Returns
length of compressed data in bytes.
Exceptions
EvioExceptionif maxSize < max # of compressed bytes or compression failed.

References evio::ByteBuffer::array().

static Compressor& evio::Compressor::getInstance ( )
inlinestatic

Get an instance of this singleton class.

Returns
an instance of this singleton class.

Referenced by evio::RecordOutput::build(), evio::RecordInput::readRecord(), and evio::RecordInput::uncompressRecord().

int evio::Compressor::getMaxCompressedLength ( CompressionType  compressionType,
uint32_t  uncompressedLength 
)
static

Returns the maximum number of bytes needed to compress the given length of uncompressed data.

Depends on compression type. Unknown for gzip.

Parameters
compressionTypetype of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip). Default to none.
uncompressedLengthuncompressed data length in bytes.
Returns
maximum compressed length in bytes or -1 if unknown.

References GZIP, LZ4, LZ4_BEST, and UNCOMPRESSED.

Compressor::CompressionType evio::Compressor::toCompressionType ( uint32_t  type)
static

Method to convert an integer to a CompressionType object.

Parameters
typeinteger to convert.
Returns
corresponding CompressionType object.

References GZIP, LZ4, LZ4_BEST, and UNCOMPRESSED.

int evio::Compressor::uncompressLZ4 ( ByteBuffer src,
int  srcSize,
ByteBuffer dst 
)
static

LZ4 decompression.

Returns original length of decompressed data in bytes.

Parameters
srcsource of compressed data.
srcSizenumber of compressed bytes.
dstdestination array.
Returns
original (uncompressed) input size.
Exceptions
EvioExceptionif 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().

int evio::Compressor::uncompressLZ4 ( ByteBuffer src,
int  srcOff,
int  srcSize,
ByteBuffer dst 
)
static

LZ4 decompression.

Returns original length of decompressed data in bytes.

Parameters
srcsource of compressed data.
srcOffstart offset in src.
srcSizenumber of compressed bytes.
dstdestination array.
Returns
original (uncompressed) input size.
Exceptions
EvioExceptionif 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().

int evio::Compressor::uncompressLZ4 ( ByteBuffer src,
int  srcOff,
int  srcSize,
ByteBuffer dst,
int  dstOff 
)
static

LZ4 decompression.

Returns original length of decompressed data in bytes.

Parameters
srcsource of compressed data.
srcOffstart offset in src.
srcSizenumber of compressed bytes.
dstdestination array.
dstOffstart offset in dst.
Returns
original (uncompressed) input size.
Exceptions
EvioExceptionif 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().

int evio::Compressor::uncompressLZ4 ( uint8_t *  src,
int  srcOff,
int  srcSize,
uint8_t *  dst,
int  dstOff,
int  dstCapacity 
)
static

LZ4 decompression.

Returns original length of decompressed data in bytes.

Parameters
srcsource of compressed data.
srcOffstart offset in src.
srcSizenumber of compressed bytes.
dstdestination array.
dstOffstart offset in dst.
dstCapacitysize of destination buffer in bytes, which must be already allocated.
Returns
original (uncompressed) input size.
Exceptions
EvioExceptionif uncompressed data bytes > dstCapacity or source data is malformed.

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