Please refer to the Data Compression page for a discussion of the advantages of in-memory and persistent database compression.
In-Memory Database Compression
To enable compression for an in-memory database, specify the
compressionLevel
,compressionMask
, andexpectedCompressionRatio
arguments in the call to methodopen_database()
. (These parameters have the same effect as described in the C API. Please refer to page Data Compression in C for further details.)For example:
exdb.open_database(dbname='testdb', dictionary=dict, is_disk=False, db_segment_size=128*1024*1024, compressionLevel=3, compressionMask=3, expectedCompressionRatio=30 );Persistent Database Compression
For persistent databases, compression is enabled by specifying the
DiskCompression
parameter when calling theexdb.init_runtime()
method and specifying thecompressionLevel
,compressionMask
, andexpectedCompressionRatio
arguments in the call to methodopen_database()
. (These parameters have the same effect as described in the C API. Please refer to page Data Compression in C for further details.)For example:
#Load Runtime configuration specified by parameters exdb.init_runtime(is_disk=True, tmgr='mvcc', DiskCompression=True) ... #Open the database specifying compression parameters exdb.open_database(dbname='testdb', dictionary=dict, is_disk=True, db_segment_size=128*1024*1024, compressionLevel=3, compressionMask=3, expectedCompressionRatio=30 );
Data Compression for IoT Communications
Data compression for IoT communications is enabled by setting the
compression_level
key of thecomm_params
dictionary parameter in the IoTCommunicator constructor. For example:iot_communicator = exdb.IoTCommunicator(comm_params = {'compression_level' : 1})The default level of
0
means no compression. As explained in the Data Compression page, the communications between each server-device pair will be compressed only if both sides (server and device) havecompression_level
greater than0
, and all communicating components must use the same compression level value.
Also explained in the Data Compression page is the formula used to determine the compression ratio. The
stat
dictionary of an IoTConnection can be examined to; elementssent_compression_ratio
andrecv_compression_ratio
show the compression efficiency for incoming and outgoing communications.