code wiki / (root) / nx_blockmax_wand.nx

nx_blockmax_wand.nx

buildroot/runtime/nx_blockmax_wand.nx

4426 B79 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_blockmax_wand.nx -- LIB: block-max top-k pruning (block-max-WAND / MaxScore family) = the QUERY-SPEED lever for a billion-posting index. Instead of scoring every doc in every query term's postings, keep a top-k threshold and PRUNE any doc whose UPPER BOUND (sum of the per-BLOCK max impacts of the terms that contain it) can't beat the threshold. Composes the 256-doc blocks from nx_posting_compress -- each block carries a max-impact, so whole blocks skip. The invariant that makes it EXACT: upper_bound >= true score, so a pruned doc could never have entered the top-k. Built + gated NOW on a fixture (exactness vs exhaustive + measured skips); the pivot/skip-pointer scaling runs on the NAS index later. No float. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_blockmax_wand.nx nx_blockmax_wand_gate.nx

imports: nx_syscalls.nx

imported by: nx_blockmax_wand_gate.nx

structs

none

consts

10const BMW_B: i64 = 2 // demo block size (fine, so block-max < term-max); production block = 256 (nx_posting_compress)

functions

13func bmw_block_max(imp: *i64, cnt: i64, bm: *i64) -> i64
called by 1: main
23func bmw_find(docs: *i64, imp: *i64, cnt: i64, d: i64, blk: *i64) -> i64
called by 2: bmw_scorebmw_ub
29func bmw_score(td: *i64, ti: *i64, tc: *i64, nt: i64, d: i64) -> i64
36func bmw_ub(td: *i64, ti: *i64, tc: *i64, tbm: *i64, nt: i64, d: i64) -> i64
called by 1: bmw_blockmax calls 2: sys_mmapbmw_find
43func bmw_insert(tkd: *i64, tks: *i64, k: i64, filled: *i64, theta: *i64, d: i64, s: i64) -> i64
58func bmw_exhaustive(td: *i64, ti: *i64, tc: *i64, nt: i64, udocs: *i64, nu: i64, k: i64, tkd: *i64, tks: *i64) -> i64
called by 1: main calls 3: sys_mmapbmw_scorebmw_insert
66func bmw_blockmax(td: *i64, ti: *i64, tc: *i64, tbm: *i64, nt: i64, udocs: *i64, nu: i64, k: i64, tkd: *i64, tks: *i64) -> i64