sketch_hll4.nx
buildroot/runtime/sketch_hll4.nx
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 · 2 importers
imports: syscalls.nxmurmur3.nxsketch_hll.nxsketch_types.nx
imported by: sketch_hll4_test.nxsketch_hll4_vs_hll8_bench.nx
structs
| 40 | struct Hll4Except { |
| 47 | struct Hll4 { |
consts
| 28 | const NX_HLL4_LGK_MIN: i64 = 4 |
| 29 | const NX_HLL4_LGK_MAX: i64 = 10 |
| 31 | const NX_HLL4_SEED_HI: i64 = 0x9747B28C |
| 32 | const NX_HLL4_SEED_LO: i64 = 0x36185EC0 |
| 35 | const NX_HLL4_SENTINEL: i64 = 15 |
| 89 | const NX_HLL4_EXCEPT_INITIAL_CAP: i64 = 8 |
functions
| 65 | func nx_hll4_get_packed(regs: *u8, idx: i64) -> i64 { |
| 74 | func nx_hll4_set_packed(regs: *u8, idx: i64, value: i64) -> i64 {
called by 1: nx_hll4_write |
| 91 | func nx_hll4_except_find(h: *Hll4, idx: i64) -> i64 { |
| 103 | func nx_hll4_except_set(h: *Hll4, idx: i64, value: i64) -> i64 { |
| 142 | func nx_hll4_read(h: *Hll4, idx: i64) -> i64 { |
| 156 | func nx_hll4_write(h: *Hll4, idx: i64, value: i64) -> i64 { |
| 169 | func nx_hll4_alloc(lg_k: i64, seed: i64) -> *Hll4 { |
| 194 | func nx_hll4_add(h: *Hll4, key: *u8, len: i64) -> i64 { |
| 223 | func nx_hll4_estimate(h: *Hll4) -> i64 { |
| 252 | func nx_hll4_query(h: *Hll4) -> *ApproxI64 { |
| 263 | func nx_hll4_memory_bytes(h: *Hll4) -> i64 {
called by 1: main |
| 268 | func nx_hll4_exception_count(h: *Hll4) -> i64 { |