code wiki / _hdl_build / nx_onsite_index.nx

nx_onsite_index.nx

buildroot/runtime/_hdl_build/nx_onsite_index.nx

9814 B194 linesdepth 5pulls 5 transitivereach 0 importersview sourcekind tooltopic onsite
docsdependenciesstructsconstsfunctions

about

nx_onsite_index.nx -- SITE-AGNOSTIC INGESTOR for the reusable onsite search client. Turns a site's search source (a 2-column "id<TAB>text" TSV -- the universal "search manifest source") into the durable pair the client reads: an inverted index (nx_search_inverted) + a MANIFEST (url<TAB>title<TAB>text, one line per doc, docid = line). REUSE not reinvent -- the gallery ALREADY produces id<TAB>text (knowledge/status/galx_search.tsv via nx_galx_search_index); any site emits the same shape and gets BM25 onsite search for free. "find files and articles": id = the file/article id, url = <url_prefix><id>, text = its searchable body. Usage: nx_onsite_index <src_id_text.tsv> <url_prefix> <idx_out> <manifest_out> [max_docs] e.g. nx_onsite_index knowledge/status/galx_search.tsv /img/ knowledge/index/gallery.idx knowledge/index/gallery.manifest COLLECT-THEN-BUILD with DEDUP: one pass collects the UNIQUE-by-id rows (galx_search.tsv had ~38% duplicate cids -- re-indexed images -- which would otherwise surface the same image many times); then a clean 2-pass index build + manifest write over the deduped set keeps idx docids and manifest lines aligned by construction. Pure-numeric tokens (image seeds/dims/steps) are scrubbed from the INDEXED copy (search noise); the manifest keeps the original text. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_search_inverted_persist.nx nx_onsite_index.nx

imports: nx_search_inverted_persist.nx

imported by: nobody (leaf or entry point)

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

main oi_puts oi_atoi sys_read_file sys_openat_rd sys_lseek sys_mmap sys_read sys_close oi_strlen nx_inv_hash_bytes_lower oi_dedup_seen oi_autosize_vocab oi_next_pow2 nx_inv_new_sized oi_scrub_numeric nx_inv_is_token_char nx_inv_index_row nx_inv_is_token_char ↻ nx_inv_hash_bytes_lower ↻ nx_inv_add_posting nx_inv_count_token nx_inv_slot_at nx_inv_slot_hash nx_inv_slot_set_hash nx_inv_slot_set_postings_c nx_inv_slot_postings_count nx_inv_finalize_offsets nx_inv_slot_at ↻ nx_inv_slot_hash ↻ nx_inv_slot_postings_count ↻ nx_inv_slot_set_postings_o nx_inv_slot_set_write_curs nx_inv_emit_row nx_inv_is_token_char ↻ nx_inv_hash_bytes_lower ↻ nx_inv_emit_posting nx_inv_slot_at ↻ nx_inv_slot_hash ↻ nx_inv_slot_postings_count ↻

structs

none

consts

19const OI_DEFAULT_MAX: i64 = 4000000
20const OI_SCRATCH_CAP: i64 = 1048576 // per-doc scrub scratch (>= longest doc text)
21const OI_VOCAB_CAP: i64 = 1048576 // 2^20 vocab slots (power of 2): CEILING for large corpora w/o saturating
22const OI_VOCAB_MIN: i64 = 2048 // 2^11 floor: smallest vocab table (tiny corpora still get headroom)
23const OI_DEDUP_CAP: i64 = 2097152 // 2^21 id-dedup hash-set slots (power of 2)

functions

25func oi_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
26func oi_num(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=(48 as u8);k=1}; while m>0{t[k]=((48+(m%10)) as u8);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 }
called by 1: main
27func oi_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: main
28func oi_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ if s[i]>=(48 as u8){ if s[i]<=(57 as u8){ v=v*10+((s[i]-(48 as u8)) as i64) } } i=i+1 } return v }
called by 1: main
31func oi_next_pow2(n: i64) -> i64 { var p: i64=1; while p<n { p=p*2 } return p }
called by 1: oi_autosize_vocab
37func oi_autosize_vocab(total_txt_bytes: i64) -> i64
called by 1: main calls 1: oi_next_pow2
46func oi_scrub_numeric(src: *u8, n: i64, dst: *u8) -> i64
called by 1: main calls 1: nx_inv_is_token_char
74func oi_dedup_seen(set: *i64, cap: i64, h: i64) -> i64
called by 1: main
89func main(argc: i64, argv: *i64) -> i64