code wiki / (root) / nx_galx_search_index.nx

nx_galx_search_index.nx

buildroot/runtime/nx_galx_search_index.nx

8023 B162 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic galx
docsdependenciesstructsconstsfunctions

about

nx_galx_search_index.nx -- SOVEREIGN search-index builder. For each ingested image it reads the PNG's metadata prefix, harvests the tEXt + uncompressed-iTXt VALUES (prompt / negative_prompt / model / sampler / ...), lowercases + sanitizes them into one searchable line "cid<TAB>text", and APPENDS it to knowledge/status/galx_search.tsv. The daemon's /api/list?q= substring-scans that file. FORK-PER-IMAGE so each PNG read's mmap is reclaimed on exit; each child does ONE atomic O_APPEND write (<4096 bytes) so any number of parallel workers can append to the same file with no merge step and no interleaving. Only a 256KB prefix is read (PNG tEXt/iTXt sit before the big IDAT) -> ~16x less NAS I/O than full read. Usage: nx_galx_search_index <start> <count>. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_galx_search_index.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

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

main si_atoi sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close si_p sys_write sys_exit sys_fork si_one sys_openat_rd ↻ sys_mmap ↻ sys_read ↻ sys_close ↻ si_extract si_be32 si_put si_low sys_openat_append sys_write ↻ sys_wait4 si_n nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap

structs

none

consts

11const SI_MAGIC_100000: i64 = 100000
12const SI_MAGIC_1000000000: i64 = 1000000000
13const SI_MAGIC_2048: i64 = 2048
15const SI_READ: i64 = 262144 // bytes of each PNG to scan (metadata is pre-IDAT)
16const SI_TEXTCAP: i64 = 3000 // cap searchable text so cid+tab+text+nl < 4096 (atomic append)
17const SI_OUT: *u8 = "knowledge/status/galx_search.tsv" as *u8

functions

19func si_p(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 calls 1: sys_write
24func si_n(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
25func si_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
26func si_be32(b: *u8, o: i64) -> i64 { return ((b[o] as i64)<<24)|((b[o+1] as i64)<<16)|((b[o+2] as i64)<<8)|(b[o+3] as i64) }
called by 1: si_extract
27func si_low(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } if c == 9 { return 32 } if c == 10 { return 32 } if c == 13 { return 32 } return c }
called by 1: si_put
30func si_put(out: *u8, o: i64, ch: i64) -> i64 { if o < SI_TEXTCAP { out[o] = si_low(ch) as u8; return o + 1 } return o }
called by 1: si_extract calls 1: si_low
33func si_extract(png: *u8, n: i64, out: *u8) -> i64
called by 1: si_one calls 2: si_be32si_put
93func si_one(cid: *u8, path: *u8) -> i64
117func main(argc: i64, argv: *i64) -> i64