Skip to content

Compress and encrypt example

This example shows how to use various q compression and encryption algorithms on a PyKX table.

To follow along, download this zip archive that contains a copy of the python script and this writeup.

Here are the compression algorithms and their levels:

Algorithm Compression level
ipc 0
gzip 0-9
snappy 0
lz4hc 1-12

Quickstart

To run this example, execute the compress_and_encrypt.py file.

$ python compress_and_encrypt.py

Outcome

Writing in-memory trades table with gzip: {
    "compressedLength": 12503352,
    "uncompressedLength": 36666552,
    "algorithm": 2,
    "logicalBlockSize": 17,
    "zipLevel": 9
}

Writing in-memory trades table with snappy: {
    "compressedLength": 18911879,
    "uncompressedLength": 36666552,
    "algorithm": 3,
    "logicalBlockSize": 17,
    "zipLevel": 0
}

Writing in-memory trades table with lz4hc: {
    "compressedLength": 15233016,
    "uncompressedLength": 36666552,
    "algorithm": 4,
    "logicalBlockSize": 17,
    "zipLevel": 12
}

Writing on-disk trades table with lz4hc: {
    "compressedLength": 15233016,
    "uncompressedLength": 36666552,
    "algorithm": 4,
    "logicalBlockSize": 17,
    "zipLevel": 12
}

Loading master key

Writing in-memory trades table with lz4hc and encryption: {
    "compressedLength": 15240112,
    "uncompressedLength": 36666552,
    "algorithm": 20,
    "logicalBlockSize": 17,
    "zipLevel": 12
}