code wiki / _hdl_build / nx_estate_search_lib.nx

nx_estate_search_lib.nx

buildroot/runtime/_hdl_build/nx_estate_search_lib.nx

19514 B363 linesdepth 7pulls 19 transitivereach 2 importersview sourcekind librarytopic estate
docsdependenciesstructsconstsfunctions

about

nx_estate_search_lib.nx -- THE ESTATE QUERY, as a library so a gate drives it in-process on a fixture shard (search rungs E1/E1b/E4, 2026-09-14). es_query ranks with dss_search (the SAME scorer the public search runs: one ruler, two corpora) and renders one line per hit into a caller buffer: rank TAB score TAB url (the url row, else doc:<cid>) TAB snippet (the first ES_SNIPPET bytes of the document with control bytes folded to spaces). It returns the hit count, or ES_UNREADABLE when the shard cannot be opened -- an absent shard and an empty one are different facts and only one of them is a defect. E1b DEFINITION PRECEDENCE: an underscored term is also asked as its definition token (ss_def_token, the token the tree ingest writes once per function head), and the hits are re-ordered by a TIER before the score -- a document carrying a typed term's definition token ranks above one that only mentions the term, whatever the BM25 magnitude (es_def_precedence, the shape of dss_exact_precedence: a lexicographic key needs no coefficient, and a discount constant here would be a magic number nobody could justify). A one-word function name has no definition tier -- a NAMED residual, the same condition ss_ident_collapse already draws. license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_docportal_search_serve.nx nx_uxf_cid.nx nx_estate_search_lib.nx nx_estate_search.nx nx_estate_search_gate.nx

imports: nx_docportal_search_serve.nxnx_uxf_cid.nx

imported by: nx_estate_search.nxnx_estate_search_gate.nx

structs

none

consts

16const ES_DOMAIN: *u8 = "estate"
17const ES_TOP_DEFAULT: i64 = 10
18const ES_TOP_MAX: i64 = 50
19const ES_QBUF: i64 = 1024
20const ES_SNIPPET: i64 = 160
21const ES_PREFIXBUF: i64 = 512
22const ES_KEYBUF: i64 = 64
23const ES_BOX: i64 = 16
24const ES_WORD: i64 = 8
25const ES_NUMBUF: i64 = 28
26const ES_TAB: i64 = 9
27const ES_LF: i64 = 10
28const ES_SPACE: i64 = 32
29const ES_DIGIT0: i64 = 48
30const ES_DIGIT9: i64 = 57
31const ES_MMAP_OPEN: i64 = 1 // ss_open2 mode: mmap the segments, never read a multi-GB shard into anon RAM
32const ES_UNREADABLE: i64 = 0 - 3 // es_query: the shard could not be opened (the program exits 3 on it)
33const ES_LINE_RESERVE: i64 = 256 // per hit: rank, score, tabs, doc:<cid> and the newline beside the url and snippet
34const ES_DEFOFF: i64 = DSS_MAXTERMS // at most one definition token per query term the scorer will read
35const ES_LOOKUP_TERMS: i64 = 1 // a one-term query is a LOOKUP: it also asks for that term's definition token (a rung id, a bare name); prose has more
282const ES_UXF_HEAD_FIELDS: i64 = 5 // q hits top shard segments
283const ES_UXF_HIT_FIELDS: i64 = 4 // rank score url snippet
284const ES_UXF_HIT_COLS: i64 = ES_UXF_HIT_FIELDS - 1 // TAB separators per rendered hit line
285const ES_UXF_KEYLEN: i64 = 24 // "hit." + up to two digits of ES_TOP_MAX + ".snippet" + NUL, the longest key

functions

37func es_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
38func es_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { d[o + i] = s[i]; i = i + 1 } return o + i }
39func es_catn(d: *u8, o: i64, v: i64) -> i64
49func es_starts(a: *u8, p: *u8) -> i64 { var i: i64 = 0; while p[i] != (0 as u8) { if a[i] != p[i] { return 0 } i = i + 1 } return 1 }
called by 1: main
50func es_atoi(s: *u8) -> i64
called by 1: main
57func es_find(hay: *u8, n: i64, needle: *u8) -> i64
called by 2: ge_first_line_hasmain calls 1: es_slen
73func es_has_word(doc: *u8, dn: i64, tok: *u8) -> i64
94func es_def_precedence(defa: i64, sca: i64, defb: i64, scb: i64) -> i64
called by 1: es_query
103func es_query(domain: *u8, q: *u8, qn: i64, top: i64, out: *u8, cap: i64, olen: *i64, segs_out: *i64) -> i64
265func es_summary(out: *u8, o0: i64, q: *u8, hits: i64, top: i64, prefix: *u8, segs: i64) -> i64
calls 2: es_cates_catn
288func es_uxf_dup(src: *u8, n: i64) -> *u8
called by 1: es_uxf_envelope
297func es_uxf_hitkey(i: i64, col: *u8) -> *u8
called by 1: es_uxf_envelope calls 2: es_cates_catn
312func es_uxf_envelope(rendered: *u8, rn: i64, q: *u8, hits: i64, top: i64, prefix: *u8, segs: i64, canon_out: *u8, cid: *u8, fields_out: *i64) -> i64
360func es_uxf_envelope_size(rendered: *u8, rn: i64, q: *u8, hits: i64, top: i64, prefix: *u8, segs: i64) -> i64
calls 1: es_uxf_envelope