mksqlite  2.5
A MATLAB interface to SQLite
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
NumberCompressor Class Reference

compressor class More...

#include <number_compressor.hpp>

+ Collaboration diagram for NumberCompressor:

Public Types

enum  compressor_type_e { CT_NONE = 0, CT_BLOSC, CT_QLIN16, CT_QLOG16 }
 supported compressor types More...
 

Public Member Functions

 NumberCompressor ()
 Ctor.
 
void free_result ()
 Clear self created results with memory deallocation.
 
void clear_data ()
 Reset input data (compressed and uncompressed) memory without deallocation!
 
void clear_err ()
 Reset recent error message.
 
int get_err ()
 Get recent error message id.
 
 ~NumberCompressor ()
 Dtor.
 
void setAllocator (void *(*Allocator)(size_t), void(*DeAllocator)(void *))
 Set memory management. More...
 
bool setCompressor (const char *strCompressorType, int iCompressionLevel=-1)
 Converts compressor ID string to category enum. More...
 
const char * getCompressorName ()
 Get compressor name.
 
bool isLossy ()
 Returns true, if current compressor modifies value data.
 
bool pack (void *rdata, size_t rdata_size, size_t rdata_element_size, bool isDoubleClass)
 Calls the qualified compressor (deflate) which always allocates sufficient memory (m_cdata) More...
 
bool unpack (void *cdata, size_t cdata_size, void *rdata, size_t rdata_size, size_t rdata_element_size)
 Calls the qualified compressor (inflate) More...
 

Public Attributes

bool m_result_is_const
 true, if result is const type
 
void * m_result
 compressor output
 
size_t m_result_size
 size of compressor output in bytes
 
void * m_rdata
 uncompressed data
 
size_t m_rdata_size
 size of uncompressed data in bytes
 
size_t m_rdata_element_size
 size of one element in bytes
 
bool m_rdata_is_double_type
 Flag type is mxDOUBLE_CLASS.
 
void * m_cdata
 compressed data
 
size_t m_cdata_size
 size of compressed data in bytes
 

Private Member Functions

bool bloscCompress ()
 Allocates memory for compressed data and use it to store results (lossless data compression) More...
 
bool bloscDecompress ()
 Uncompress compressed data m_cdata to data m_rdata. More...
 
bool linlogQuantizerCompress (bool bDoLog)
 Lossy data compression by linear or logarithmic quantization (16 bit) More...
 
bool linlogQuantizerDecompress (bool bDoLog)
 
 NumberCompressor (const NumberCompressor &)
 
NumberCompressoroperator= (const NumberCompressor &)
 

Private Attributes

Err m_err
 recent error
 
const char * m_strCompressorType
 name of compressor to use
 
compressor_type_e m_eCompressorType
 enum type of compressor to use
 
int m_iCompressionLevel
 compression level (0 to 9)
 
void *(* m_Allocator )(size_t szBytes)
 memory allocator
 
void(* m_DeAllocator )(void *ptr)
 memory deallocator
 

Detailed Description

compressor class

Definition at line 53 of file number_compressor.hpp.

Member Enumeration Documentation

◆ compressor_type_e

supported compressor types

Enumerator
CT_NONE 

no compression

CT_BLOSC 

using BLOSC compressor (lossless)

CT_QLIN16 

using linear quantization (lossy)

CT_QLOG16 

using logarithmic quantization (lossy)

Definition at line 57 of file number_compressor.hpp.

Constructor & Destructor Documentation

◆ NumberCompressor()

NumberCompressor::NumberCompressor ( const NumberCompressor )
private

inhibit copy constructor and assignment operator

Member Function Documentation

◆ bloscCompress()

bool NumberCompressor::bloscCompress ( )
inlineprivate

Allocates memory for compressed data and use it to store results (lossless data compression)

Returns
true on success

Definition at line 367 of file number_compressor.hpp.

References m_Allocator, and Err::set().

Referenced by pack().

+ Here is the caller graph for this function:

◆ bloscDecompress()

bool NumberCompressor::bloscDecompress ( )
inlineprivate

Uncompress compressed data m_cdata to data m_rdata.

m_rdata must point to writable storage space and m_rdata_size must specify the legal space.

Returns
true on success

Definition at line 404 of file number_compressor.hpp.

References Err::set().

Referenced by unpack().

+ Here is the caller graph for this function:

◆ linlogQuantizerCompress()

bool NumberCompressor::linlogQuantizerCompress ( bool  bDoLog)
inlineprivate

Lossy data compression by linear or logarithmic quantization (16 bit)

Allocates m_cdata and use it to store compressed data from m_rdata. Only double types accepted! NaN, +Inf and -Inf are allowed.

Parameters
[in]bDoLogUsing logarithmic (true) or linear (false) quantization.

Definition at line 439 of file number_compressor.hpp.

References Err::set().

Referenced by pack().

+ Here is the caller graph for this function:

◆ linlogQuantizerDecompress()

bool NumberCompressor::linlogQuantizerDecompress ( bool  bDoLog)
inlineprivate
Parameters
[in]bDoLogUsing logarithmic (true) or linear (false) quantization.
Returns
true on success

Uncompress compressed data m_cdata to data m_rdata. m_rdata must point to writable storage space and m_rdata_size must specify the legal space. (lossy data compression)

Definition at line 570 of file number_compressor.hpp.

References Err::set().

Referenced by unpack().

+ Here is the caller graph for this function:

◆ pack()

bool NumberCompressor::pack ( void *  rdata,
size_t  rdata_size,
size_t  rdata_element_size,
bool  isDoubleClass 
)
inline

Calls the qualified compressor (deflate) which always allocates sufficient memory (m_cdata)

Parameters
[in]rdatapointer to raw data (byte stream)
[in]rdata_sizelength of raw data in bytes
[in]rdata_element_sizesize of one element in bytes
[in]isDoubleClasstrue, if elements represent double types
Returns
true on success

deploy result (compressed data)

Definition at line 264 of file number_compressor.hpp.

References bloscCompress(), clear_data(), clear_err(), CT_BLOSC, CT_QLIN16, CT_QLOG16, free_result(), linlogQuantizerCompress(), m_cdata, and m_cdata_size.

◆ setAllocator()

void NumberCompressor::setAllocator ( void *(*)(size_t)  Allocator,
void(*)(void *)  DeAllocator 
)
inline

Set memory management.

Parameters
[in]Allocatormemory allocating functor
[in]DeAllocatormemory deallocating functor

Definition at line 163 of file number_compressor.hpp.

References m_Allocator, and m_DeAllocator.

◆ setCompressor()

bool NumberCompressor::setCompressor ( const char *  strCompressorType,
int  iCompressionLevel = -1 
)
inline

Converts compressor ID string to category enum.

Parameters
[in]strCompressorTypeCompressor name as string
[in]iCompressionLevelCompression level (compressor dependent)

Definition at line 183 of file number_compressor.hpp.

References Err::clear(), COMPRESSOR_DEFAULT_ID, and CT_NONE.

Referenced by NumberCompressor().

+ Here is the caller graph for this function:

◆ unpack()

bool NumberCompressor::unpack ( void *  cdata,
size_t  cdata_size,
void *  rdata,
size_t  rdata_size,
size_t  rdata_element_size 
)
inline

Calls the qualified compressor (inflate)

Parameters
[in]cdatapointer to compressed data
[in]cdata_sizelength of compressed data in bytes
[in,out]rdatapointer to memory for decompressed data
[out]rdata_sizeavailable space ar rdata in bytes
[in]rdata_element_sizesize of one element in decompressed vector
Returns
true on success

acquire compressed data

dispatch

deplay result (uncompressed/raw data)

Definition at line 316 of file number_compressor.hpp.

References bloscDecompress(), clear_data(), clear_err(), CT_BLOSC, CT_QLIN16, CT_QLOG16, free_result(), linlogQuantizerDecompress(), m_rdata, and m_rdata_size.


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