Skip to main content

Module for_encoding

Module for_encoding 

Source
Expand description

Frame-of-Reference (FOR) encoding for integer columns.

FOR encoding stores each value as a small, fixed-width offset from a per-block reference value (the minimum). This is optimal for columns where all values fall within a narrow range — e.g. HTTP status codes, sensor readings that hover around a baseline, or enum-style identifiers.

Unlike delta encoding (which stores differences between consecutive values), FOR stores differences from a global reference (the block minimum). This makes FOR ideal for data with a tight value range but no predictable ordering, while delta encoding excels at monotonic or slowly-changing sequences.

§Wire format

[count: u32 LE][reference: i64 LE][bit_width: u8][packed offsets…]
  • count — number of values (max u32::MAX).
  • reference — the minimum value in the block.
  • bit_width — bits needed to represent the largest offset from reference (0–64). When 0, all values equal the reference.
  • packed offsets — each offset packed at bit_width bits, MSB-first.

Structs§

ForDecoder
Frame-of-Reference decoder.
ForEncoder
Frame-of-Reference encoder for integer columns.