code wiki / (root) / nx_sketch_hll4.nx

nx_sketch_hll4.nx

buildroot/runtime/nx_sketch_hll4.nx

8855 B276 linesdepth 6pulls 11 transitivereach 0 importersview sourcekind sketch/demotopic sketch
docsdependenciesstructsconstsfunctions

about

sketch_hll4.nx -- HLL_4 with Heule exception table. 4 bits per register addresses rho in [0, 14]; rho = 15 is the SENTINEL meaning "see exception table for the true value." An exception table holds (idx, value) pairs for the rare registers whose true rho exceeds 14. MEMORY: HLL_4 at lg_k=10 = m/2 bytes register array + ~40 bytes header + ~0 bytes exception (lazy-allocated; most workloads never trigger). Total HLL_4-10 < HLL_8-10 by ~46% in typical use. Matches DataSketches HLL_4-12 = 2095 bytes. Heule et al. 2013 observation: P(rho > 14) is small enough that a few sentinel slots + a hash-table-class exception map is strictly cheaper than 6-bit or 8-bit dense storage at high lgK. For HLL_4-12 at N = 10^9, expected exceptions < 50 entries. Per the lossless-language discipline (doc 20): the typed envelope API is invariant across packing strategies. HLL_4, HLL_6, HLL_8 all return the same ApproxI64 shape; users see memory drop without semantic change.

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_murmur3.nx nx_sketch_hll.nx nx_sketch_types.nx nx_sketch_hll4.nx

imports: nx_syscalls.nxnx_murmur3.nxnx_sketch_hll.nxnx_sketch_types.nx

imported by: nobody (leaf or entry point)

structs

46struct Hll4Except
53struct Hll4

consts

34const NX_HLL4_LGK_MIN: i64 = 4
35const NX_HLL4_LGK_MAX: i64 = 10
37const NX_HLL4_SEED_HI: i64 = 0x9747B28C
38const NX_HLL4_SEED_LO: i64 = 0x36185EC0
41const NX_HLL4_SENTINEL: i64 = 15
95const NX_HLL4_EXCEPT_INITIAL_CAP: i64 = 8

functions

71func nx_hll4_get_packed(regs: *u8, idx: i64) -> i64
called by 1: nx_hll4_read
80func nx_hll4_set_packed(regs: *u8, idx: i64, value: i64) -> i64
called by 1: nx_hll4_write
97func nx_hll4_except_find(h: *Hll4, idx: i64) -> i64
109func nx_hll4_except_set(h: *Hll4, idx: i64, value: i64) -> i64
148func nx_hll4_read(h: *Hll4, idx: i64) -> i64
162func nx_hll4_write(h: *Hll4, idx: i64, value: i64) -> i64
175func nx_hll4_alloc(lg_k: i64, seed: i64) -> *Hll4
calls 1: sys_mmap
200func nx_hll4_add(h: *Hll4, key: *u8, len: i64) -> i64
229func nx_hll4_estimate(h: *Hll4) -> i64
258func nx_hll4_query(h: *Hll4) -> *ApproxI64
269func nx_hll4_memory_bytes(h: *Hll4) -> i64
274func nx_hll4_exception_count(h: *Hll4) -> i64