nodedb_codec/fastlanes/mod.rs
1// SPDX-License-Identifier: Apache-2.0
2
3//! FastLanes-inspired FOR + bit-packing codec for integer columns.
4//!
5//! Frame-of-Reference (FOR): subtract the minimum value from all values,
6//! reducing them to small unsigned residuals. Then bit-pack the residuals
7//! using the minimum number of bits.
8//!
9//! The bit-packing loop is written as simple scalar operations on contiguous
10//! arrays, which LLVM auto-vectorizes to AVX2/AVX-512/NEON/WASM-SIMD without
11//! explicit intrinsics. This is the FastLanes insight: structured scalar code
12//! that the compiler vectorizes, portable across all targets.
13//!
14//! Wire format:
15//! ```text
16//! [4 bytes] total value count (LE u32)
17//! [2 bytes] block count (LE u16)
18//! For each block:
19//! [2 bytes] values in this block (LE u16, max 1024)
20//! [1 byte] bit width (0-64)
21//! [8 bytes] min value / reference (LE i64)
22//! [N bytes] bit-packed residuals
23//! ```
24//!
25//! Block size: 1024 values. Last block may be smaller.
26
27mod bits;
28mod block;
29mod codec;
30mod header;
31mod iterator;
32mod range;
33
34pub use block::bit_width_for_range;
35pub use codec::{decode, encode};
36pub use iterator::BlockIterator;
37pub use range::{block_byte_offsets, block_count, decode_block_range, decode_single_block};