compress

Syntax

compress(X, [method='lz4'])

Arguments

X is a vector or a table.

method (optional) is a string indicating the compression algorithm. It can be either "lz4" or "delta". The default value is "lz4".

Details

Compress a vector or a table with the specified compression algorithm. The compressed variable needs to be decompressed with function decompress before it can be used in a calculation.

Examples

x=1..100000000
y=compress(x, "delta");

y.typestr();
// output
HUGE COMPRESS VECTOR

select name, bytes from objs() where name in `x`y;
name bytes
x 402653952
y 13634544

Please note that if function size is applied on the compressed vector y, the result is the length of the compressed vector y instead of the original vector x. To extract information about x from y, we need to decompress y first.

y.size();
// output
12670932

z=decompress(y);
z.size();
// output
100000000

Related functions: decompress