code wiki / _hdl_build / nx_research_search.nx

nx_research_search.nx

buildroot/runtime/_hdl_build/nx_research_search.nx

6839 B141 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tooltopic research
docsdependenciesstructsconstsfunctions

about

nx_research_search.nx -- CROSS-SHARD QUERY over the self-growing researcher index. The grow organ builds append-only shards (research_0.idx, research_1.idx, ...); this is the consumption side: load every shard, query each for the argv terms, merge the candidate docs across shards, rank by #query-terms-matched, and print the top-K "score shard:path". Makes the grown + deduped + mined corpus actually searchable end-to-end. Sequentially loads shards 0,1,2,... until the first gap (grow numbers them contiguously). NOTE: loading ALL shards in one process is fine for a handful; at large shard counts this needs sys_munmap (the keystone) or a periodic shard-merge. Usage: nx_research_search <term> [term ...] expect_exit: 0 license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_search_inverted_persist.nx nx_itoa_lib.nx nx_research_search.nx

imports: nx_search_inverted_persist.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main rs_puts rs_cat rs_catnum nx_inv_load sys_read_file sys_openat_rd sys_lseek sys_mmap sys_read sys_close rs_load_docmap sys_read_file ↻ nx_inv_query_term nx_inv_hash_bytes_lower nx_inv_lookup_slot nx_inv_slot_at nx_inv_slot_hash nx_inv_slot_postings_count nx_inv_slot_postings_offse nx_inv_slot_write_cursor rs_strlen rs_num nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write sys_munmap

structs

none

consts

11const RS_TERMS: i64 = 8
12const RS_ROWIDS: i64 = 4096
13const RS_CAND: i64 = 16384
14const RS_TOPK: i64 = 15
15const RS_MAXSHARD: i64 = 4096

functions

17func rs_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main
22func rs_num(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
23func rs_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: main
24func rs_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i];i=i+1} return off+i }
called by 1: main
25func rs_catnum(dst: *u8, off: i64, v: i64) -> i64
called by 1: main
34func rs_load_docmap(path: *u8, paths_out: *i64, cap: i64) -> i64
called by 1: main calls 1: sys_read_file
51func main(argc: i64, argv: *i64) -> i64