code wiki / (root) / nx_posting_compress.nx

nx_posting_compress.nx

buildroot/runtime/nx_posting_compress.nx

4000 B91 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_posting_compress.nx -- LIB: posting-list compression (Lucene Frame-of-Reference model) = the biggest perf+size lever for a billion-posting sovereign index. Sorted ascending doc-ids -> per 256-doc BLOCK: store first-id absolute + delta-encode the rest + BIT-PACK the deltas at the block's max bit-width. A dense list (small gaps) collapses to ~2 bits/posting vs 32. Roundtrip-exact (lossless). Built + gated NOW on fixtures; runs at NAS scale over the real index later. SIMD-decode is a later optimization; correctness first. No float. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_posting_compress.nx nx_posting_compress_gate.nx

imports: nx_syscalls.nx

imported by: nx_posting_compress_gate.nx

structs

none

consts

8const PC_BLOCK: i64 = 256

functions

11func pc_bitwidth(maxv: i64) -> i64 { var w: i64=0; while (1 << w) <= maxv { w = w + 1 } if w==0 { w=1 } return w }
called by 1: pc_compress
14func pc_putbits(buf: *u8, bitpos: i64, v: i64, w: i64) -> i64
called by 1: pc_compress
28func pc_getbits(buf: *u8, bitpos: i64, w: i64) -> i64
called by 1: pc_decompress
42func pc_compress(ids: *i64, n: i64, out: *u8) -> i64
called by 1: main calls 2: pc_bitwidthpc_putbits
72func pc_decompress(inp: *u8, nbytes: i64, out_ids: *i64) -> i64
called by 1: main calls 1: pc_getbits