Skip to main content

Module frequency

Module frequency 

Source
Expand description

Frequency encoding (encoding id 10), the BtrBlocks shape for columns where one value dominates but the rest are wide and scattered, so neither RLE (short runs) nor Dict (high exception cardinality) wins.

The dominant value is stored once; everything else becomes an exception patched back in by position. Both exception streams ride the frame-of-reference container. Layout: count: u32 LE, top: u64 LE, positions_len: u32 LE, positions container, values container.

Functionsยง

decode
Decodes an encoded buffer, appending at most max_values values to out. The count and both exception streams are claims until checked: the count against the caller ceiling, the streams against each other, and every position against the materialized range. The exception streams patch chunk by chunk in lockstep, so scratch stays two MiniBlock chunks however many exceptions the segment holds.
encode
Encodes values into out, returning the encoded byte length.