Skip to main content

Module lz4

Module lz4 

Source
Expand description

LZ4 block compression codec for string/log columns.

Uses lz4_flex (pure Rust, WASM-compatible) for fast decompression with reasonable compression ratios (3-5x for typical log text).

Data is split into 4KB blocks for random access: to read row N, decompress only the block containing that row, not the entire column.

Wire format:

[4 bytes] total uncompressed size (LE u32)
[4 bytes] block size (LE u32, default 4096)
[4 bytes] block count (LE u32)
[block_count × 4 bytes] compressed block lengths (LE u32 each)
[block_count × N bytes] compressed blocks (concatenated)

The block length table allows seeking to any block without decompressing preceding blocks.

Structs§

Lz4Decoder
LZ4 decoder wrapper.
Lz4Encoder
Streaming LZ4 encoder. Accumulates data and compresses on finish().

Functions§

decode
Decompress LZ4 block-compressed bytes back to raw data.
decode_block
Decompress a single block by index (for random access).
encode
Compress raw bytes using LZ4 block compression.
encode_with_block_size
Compress with a custom block size (useful for testing or tuning).