code wiki / _hdl_build / nx_docportal_search_serve.nx

nx_docportal_search_serve.nx

buildroot/runtime/_hdl_build/nx_docportal_search_serve.nx

57794 B1035 linesdepth 4pulls 7 transitivereach 11 importersview sourcekind librarytopic docportal
docsdependenciesstructsconstsfunctions

about

nx_docportal_search_serve.nx -- R2: the PUBLIC /search serve handler over the SOVEREIGN seg_store search. bytes-in -> bytes-out (no socket -- the gate drives it directly, like dad_handle). Parses GET /search?q=<query>, runs dss_search over the domain's PUBLIC seg_store shard (NO tsv), reads each hit's text (ss_hget) and renders a branded results page with Content-Length (sites.elf's buffered reverse proxy needs the length). A stale/old- format shard (-2) degrades to "0 results", never a 500. license_tier: ORIGINAL

dependencies 1 imports · 7 importers

nx_docportal_search_seg.nx nx_docportal_search_serve.nx nx_docportal_admin_daemon.nx nx_docportal_search_serve_gate.nx nx_nishi_search_census.nx nx_search_latency_bench.nx nx_search_relevance_bench.nx nx_serp_census.nx nx_serp_probe.nx

imports: nx_docportal_search_seg.nx

imported by: nx_docportal_admin_daemon.nxnx_docportal_search_serve_gate.nxnx_nishi_search_census.nxnx_search_latency_bench.nxnx_search_relevance_bench.nxnx_serp_census.nxnx_serp_probe.nx

structs

none

consts

9const DSV_ASCII_0: i64 = 48
10const DSV_DEC: i64 = 10
11const DSV_TSBUF: i64 = 16
13const DSV_MAGIC_1000000: i64 = 1000000
14const DSV_MAGIC_1024: i64 = 1024
15const DSV_MAGIC_80000: i64 = 80000
17const DSV_OUTCAP: i64 = 262144
18const DSV_BODYCAP: i64 = 786432 // uniform per-request body mmap size (>= the largest body 600000); munmap'd every request to kill the leak
19const DSV_MAXR: i64 = 30 // results per page (20->30 2026-07-24: fuller SERPs; the shrunk tf-scan cap keeps it fast)
20const DSV_SNIP: i64 = 240 // chars of a hit's text to show

functions

22func dsv_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
23func dsv_cat(out: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { out[o] = s[i]; o = o + 1; i = i + 1 } return o }
24func dsv_catn(out: *u8, o: i64, v: i64) -> i64
35func dsv_esc(out: *u8, o: i64, src: *u8, n: i64) -> i64
called by 3: dsv_hldsv_resultdss_serve calls 1: dsv_cat
48func dsv_hexval(c: u8) -> i64
called by 1: dsv_urldecode
55func dsv_urldecode(src: *u8, n: i64, out: *u8, outcap: i64) -> i64
called by 1: dsv_qparam calls 1: dsv_hexval
78func dsv_qparam(req: *u8, req_n: i64, name: *u8, nlen: i64, out: *u8, outcap: i64) -> i64
116func dsv_host(req: *u8, req_n: i64, out: *u8, cap: i64) -> i64
called by 2: dad_handlemain
148func dsv_tokq(q: *u8, qn: i64, termstore: *u8, termptrs: *i64, tbl: *u8) -> i64
called by 2: dss_servedsv_doc_serve calls 1: ss_tok_next2
172func dsv_hl(out: *u8, o: i64, src: *u8, n: i64, termptrs: *i64, nterms: i64, tbl: *u8) -> i64
208func dsv_urlenc(out: *u8, o: i64, src: *u8, n: i64) -> i64
230func dsv_mkurlkey(cid: i64, out: *u8) -> i64
245func dsv_result(body: *u8, b: i64, txt: *u8, tn: i64, cid: i64, q: *u8, qn: i64, termptrs: *i64, nterms: i64, tbl: *u8, url: *u8, ul: i64, webscope: i64) -> i64
307func dsv_style(body: *u8, b: i64) -> i64
called by 2: dss_servedsv_doc_serve calls 1: dsv_cat
313func dsv_jesc(out: *u8, o: i64, src: *u8, n: i64) -> i64
337func dsv_respond_json(out: *u8, status: *u8, body: *u8, b: i64) -> i64
350func dsv_respond(out: *u8, status: *u8, body: *u8, b: i64) -> i64
365func dsv_scope(req: *u8, req_n: i64, domain: *u8, effdom: *u8) -> i64
399func dsv_scope_name(body: *u8, b: i64, scope: i64) -> i64
405func dsv_tabs(body: *u8, b: i64, q: *u8, qn: i64, scope: i64) -> i64
called by 1: dss_serve calls 2: dsv_catdsv_urlenc
423func dsv_now_us() -> i64
435func dsv_best_sentence(txt: *u8, tn: i64, termptrs: *i64, nterms: i64, tbl: *u8, offout: *i64, lenout: *i64) -> i64
called by 2: dsv_resultdss_serve calls 1: dss_streq
501func dss_serve(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64
709func dsv_atoin(s: *u8, n: i64, okbox: *i64) -> i64
729func dsv_doc_serve(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64
798func dss_api_openapi(srv: *u8, out: *u8) -> i64
946func dss_api_suggest(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64
987func dss_api_doc(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64