code wiki / (root) / nx_search_inverted.nx

nx_search_inverted.nx

buildroot/runtime/nx_search_inverted.nx

26152 B691 linesdepth 3pulls 3 transitivereach 201 importersview sourcekind librarytopic search
docsdependenciesstructsconstsfunctions

about

nx_search_inverted.nx -- token-postings inverted index. module: nishi-core.search.inverted depends: nishi-core.io.syscalls disk_kb: 6 capability: CORE_IO wired_status: FULLY_WIRED license_tier: PUBLIC_NISHI_SUBSTRATE genealogy_id: salton_1971_inverted_index + fnv_1a_64bit_hash + nishi_build_the_system_cardinal_2026 Search-engine Brick #2. Replaces O(N*M) linear scan with O(M_query * log(V) + sum(postings_per_qtoken)) lookup. At 2.6M rows + ~50K vocab: sub-millisecond query latency. In-memory index built from JSONL once; held in process memory. File-backed persistence queued (nx_search_inverted_persist). Tokenization: split on whitespace + ASCII punctuation, lowercase ASCII letters, keep alphanumerics. Minimum token length = 2. Maximum token length = 64. Hash: FNV-1a 64-bit (per nx_canary_value substrate convention).

dependencies 1 imports · 37 importers

syscalls.nx nx_search_inverted.nx nx_artifact_store.nx nx_corpus_measure.nx nx_corpus_search.nx nx_crawl_doc.nx nx_diora_index_demo.nx nx_diora_live_reach.nx nx_diora_live_reach_guarded.nx nx_diora_live_serp.nx nx_dms_search.nx nx_docstore_test.nx

diagram shows first 10 each side; +0 more imports, +27 more importers in the complete lists below.

imports: syscalls.nx

imported by: nx_artifact_store.nxnx_corpus_measure.nxnx_corpus_search.nxnx_crawl_doc.nxnx_diora_index_demo.nxnx_diora_live_reach.nxnx_diora_live_reach_guarded.nxnx_diora_live_serp.nxnx_dms_search.nxnx_docstore_test.nxnx_entity_discover.nxnx_html_to_nishi_page.nxnx_index_migrate_gate.nxnx_inv_bounded_gate.nxnx_live_crawl.nxnx_live_https.nxnx_nishi_page_emit.nxnx_pipeline_walker.nxnx_research_digest.nxnx_search_handler_flow.nxnx_search_inverted_persist.nxnx_search_inverted_test.nxnx_search_neutrality_gate.nxnx_search_onsite_engine.nxnx_search_query_parser.nxnx_search_server.nxnx_search_snippet_extract.nxnx_simhash.nxnx_warc_index.nxnx_wiki_archive_router.nxnx_wiki_https_daemon.nxnx_wiki_https_daemon_mv.nxnx_wiki_index_builder.nxnx_wiki_main.nxnx_wiki_routes.nxnx_wiki_search_wiring.nxnx_wiki_vhost_table.nx

structs

161struct NxInvIndex
623struct NxInvQueryResult

consts

28const NX_MAGIC_4294967296: i64 = 4294967296
29const NX_MAGIC_4194304: i64 = 4194304
33const NX_INV_OK: i64 = 1
34const NX_INV_FILE_NOT_FOUND: i64 = 2
35const NX_INV_BAD_ARGS: i64 = 3
36const NX_INV_NO_MATCHES: i64 = 4
37const NX_INV_OUT_OF_VOCAB: i64 = 5
38const NX_INV_BUILD_FAIL: i64 = 6
52const NX_INV_FNV1A_OFFSET_BASIS: i64 = -3750763034362895579
53const NX_INV_FNV1A_PRIME: i64 = 1099511628211
102const NX_INV_VOCAB_CAPACITY: i64 = 131072 // 128 K slots (~50% load at 50K vocab)
103const NX_INV_MAX_POSTINGS_PER: i64 = 16384 // cap per token (most tokens have <100)
104const NX_INV_MAX_TOTAL_ROWS: i64 = 8388608 // 8 M rows ceiling
105const NX_INV_MIN_TOKEN_LEN: i64 = 2
106const NX_INV_MAX_TOKEN_LEN: i64 = 64
159const NX_INV_SLOT_BYTES: i64 = 32
171const NX_INV_INDEX_BYTES: i64 = 56 // 7 fields * 8 bytes
632const NX_INV_QUERY_RESULT_BYTES: i64 = 48

functions

40func nx_inv_verdict_name(v: i64) -> *u8
55func nx_inv_hash_bytes_lower(bytes: *u8, n: i64) -> i64
83func nx_inv_is_token_char(c: i64) -> i64
131func nx_bm25_tf(text: *u8, n: i64, term_hash: i64) -> i64
175func nx_inv_new(expected_rows: i64) -> *NxInvIndex
called by 19: mainmainmainmainmainmain+13
202func nx_inv_new_sized(cap: i64) -> *NxInvIndex
221func nx_inv_new_bounded(cap: i64, post_cap: i64) -> *NxInvIndex
called by 2: mainmain
241func nx_inv_slot_at(idx: *NxInvIndex, slot_i: i64) -> *u8
245func nx_inv_slot_hash(slot: *u8) -> i64
250func nx_inv_slot_set_hash(slot: *u8, h: i64)
called by 1: nx_inv_count_token
255func nx_inv_slot_postings_offset(slot: *u8) -> i64
260func nx_inv_slot_set_postings_offset(slot: *u8, off: i64)
265func nx_inv_slot_postings_count(slot: *u8) -> i64
270func nx_inv_slot_set_postings_count(slot: *u8, c: i64)
called by 1: nx_inv_count_token
275func nx_inv_slot_write_cursor(slot: *u8) -> i64
280func nx_inv_slot_set_write_cursor(slot: *u8, c: i64)
286func nx_inv_count_token(idx: *NxInvIndex, token_hash: i64) -> i64
322func nx_inv_finalize_offsets(idx: *NxInvIndex) -> i64
348func nx_inv_emit_posting(idx: *NxInvIndex, token_hash: i64, row_id: i64) -> i64
392func nx_inv_add_posting(idx: *NxInvIndex, token_hash: i64, row_id: i64) -> i64
400func nx_inv_lookup_slot(idx: *NxInvIndex, token_hash: i64) -> *u8
424func nx_inv_index_row(
474func nx_inv_emit_row(
523func nx_inv_build_from_jsonl(jsonl_path: *u8) -> *NxInvIndex
634func nx_inv_query_term(