code wiki / _hdl_build / nx_docportal_search_serve.nx
nx_docportal_search_serve.nx
buildroot/runtime/_hdl_build/nx_docportal_search_serve.nx
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
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
| 9 | const DSV_ASCII_0: i64 = 48 |
| 10 | const DSV_DEC: i64 = 10 |
| 11 | const DSV_TSBUF: i64 = 16 |
| 13 | const DSV_MAGIC_1000000: i64 = 1000000 |
| 14 | const DSV_MAGIC_1024: i64 = 1024 |
| 15 | const DSV_MAGIC_80000: i64 = 80000 |
| 17 | const DSV_OUTCAP: i64 = 262144 |
| 18 | const DSV_BODYCAP: i64 = 786432 // uniform per-request body mmap size (>= the largest body 600000); munmap'd every request to kill the leak |
| 19 | const DSV_MAXR: i64 = 30 // results per page (20->30 2026-07-24: fuller SERPs; the shrunk tf-scan cap keeps it fast) |
| 20 | const DSV_SNIP: i64 = 240 // chars of a hit's text to show |
functions
| 22 | func dsv_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 23 | func 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 } |
| 24 | func dsv_catn(out: *u8, o: i64, v: i64) -> i64 |
| 35 | func dsv_esc(out: *u8, o: i64, src: *u8, n: i64) -> i64 |
| 48 | func dsv_hexval(c: u8) -> i64 called by 1: dsv_urldecode |
| 55 | func dsv_urldecode(src: *u8, n: i64, out: *u8, outcap: i64) -> i64 |
| 78 | func dsv_qparam(req: *u8, req_n: i64, name: *u8, nlen: i64, out: *u8, outcap: i64) -> i64 called by 6: dsv_scopedss_servedsv_doc_servedss_api_searchdss_api_suggestdss_api_doc calls 1: dsv_urldecode |
| 116 | func dsv_host(req: *u8, req_n: i64, out: *u8, cap: i64) -> i64 |
| 148 | func dsv_tokq(q: *u8, qn: i64, termstore: *u8, termptrs: *i64, tbl: *u8) -> i64 |
| 172 | func dsv_hl(out: *u8, o: i64, src: *u8, n: i64, termptrs: *i64, nterms: i64, tbl: *u8) -> i64 |
| 208 | func dsv_urlenc(out: *u8, o: i64, src: *u8, n: i64) -> i64 |
| 230 | func dsv_mkurlkey(cid: i64, out: *u8) -> i64 |
| 245 | func 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 |
| 307 | func dsv_style(body: *u8, b: i64) -> i64 |
| 313 | func dsv_jesc(out: *u8, o: i64, src: *u8, n: i64) -> i64 |
| 337 | func dsv_respond_json(out: *u8, status: *u8, body: *u8, b: i64) -> i64 called by 4: dss_api_openapidss_api_searchdss_api_suggestdss_api_doc calls 3: dsv_catdsv_catnsys_munmap |
| 350 | func dsv_respond(out: *u8, status: *u8, body: *u8, b: i64) -> i64 |
| 365 | func dsv_scope(req: *u8, req_n: i64, domain: *u8, effdom: *u8) -> i64 |
| 393 | func dsv_scope_link(body: *u8, b: i64, scope: i64) -> i64 |
| 399 | func dsv_scope_name(body: *u8, b: i64, scope: i64) -> i64 |
| 405 | func dsv_tabs(body: *u8, b: i64, q: *u8, qn: i64, scope: i64) -> i64 |
| 423 | func dsv_now_us() -> i64 |
| 435 | func dsv_best_sentence(txt: *u8, tn: i64, termptrs: *i64, nterms: i64, tbl: *u8, offout: *i64, lenout: *i64) -> i64 |
| 501 | func dss_serve(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64 called by 5: dad_handlemainmainc_rendermain calls 25: dsv_now_usdsv_qparamdsv_scopedsv_atoindss_search_offss_tok_table+19 |
| 709 | func dsv_atoin(s: *u8, n: i64, okbox: *i64) -> i64 |
| 729 | func dsv_doc_serve(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64 |
| 798 | func dss_api_openapi(srv: *u8, out: *u8) -> i64 |
| 836 | func dss_api_search(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64 |
| 946 | func dss_api_suggest(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64 |
| 987 | func dss_api_doc(domain: *u8, req: *u8, req_n: i64, out: *u8) -> i64 |