code wiki / _hdl_build / nx_dataset_export.nx

nx_dataset_export.nx

buildroot/runtime/_hdl_build/nx_dataset_export.nx

26382 B633 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_dataset_export.nx -- IMS Thrust D R2: BYTE-FAITHFUL multi-format dataset export. ONE source dataset -> THREE serializations (CSV / JSON / TSV) that are ROUND-TRIPPABLE: parse any of the three back and you recover the IDENTICAL records (same headers, same cells, byte-exact). This is the "dataset in lots of formats to download" half of the arc -- the data a chart visualises, offered for download in the format the consumer wants, with no lossy drift between them. REUSE-vs-NEW: the UXF family (nx_uxf_tsv_migrate / nx_canon_cid) models "one source -> ONE content- addressed CID for dedup/round-trip-to-CID" -- a DIFFERENT goal (it does not emit human-readable CSV/ JSON/TSV text files a browser can download). The CSV escaping RULES here follow RFC 4180 exactly as nx_chem_report_csv established (quote a field with , " CR LF; double internal "); the JSON string escaping follows RFC 8259 as json_emit established. We implement the 3 generic emitters + 3 parsers directly over a tiny generic ROW MODEL (no per-schema code) -- the gap those organs do not fill. ROW MODEL (NxDataset): nrows records, each with ncols string fields, in flat parallel arrays hdr_ptr[c]/hdr_len[c] -- the c-th column header cell_ptr[r*ncols+c]/cell_len[..] -- the field at (row r, col c) Fields are arbitrary bytes (may contain commas, quotes, tabs, newlines). PURE: no I/O here; the caller owns buffers (sys_mmap scratch only). license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_dataset_export.nx nx_figure_gate.nx nx_figures_page.nx

imports: nx_syscalls.nx

imported by: nx_figure_gate.nxnx_figures_page.nx

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

main sys_mmap dx_alloc sys_mmap ↻ dx_set_hdr dx_set_cell_z dx_set_cell dx_emit_csv dx_emit_csv_field dx_field_needs_quote dx_emit_json dx_emit_json_str dx_emit_tsv

structs

35struct NxDataset

consts

21const DX_MAGIC_4096: i64 = 4096
22const DX_MAGIC_1024: i64 = 1024
25const DX_OK: i64 = 0
26const DX_BAD_INPUT: i64 = 2910
27const DX_OVERFLOW: i64 = 2911
28const DX_PARSE: i64 = 2912
30const DX_MAXCOLS: i64 = 32
31const DX_MAXROWS: i64 = 256
32const DX_MAXCELLS: i64 = 8192 // DX_MAXROWS * DX_MAXCOLS ceiling guard

functions

46func dx_alloc(ds: *NxDataset, ncols: i64, nrows: i64) -> i64
62func dx_set_hdr(ds: *NxDataset, c: i64, s: *u8) -> i64
called by 3: mainmainmain
74func dx_set_cell(ds: *NxDataset, r: i64, c: i64, p: *u8, len: i64) -> i64
called by 2: dx_set_cell_zmain
87func dx_set_cell_z(ds: *NxDataset, r: i64, c: i64, s: *u8) -> i64
called by 3: mainmainmain calls 1: dx_set_cell
93func dx_cell_ptr(ds: *NxDataset, r: i64, c: i64) -> *u8 { return ds.cell_ptr[r * ds.ncols + c] as *u8 }
called by 2: mainmain
94func dx_cell_len(ds: *NxDataset, r: i64, c: i64) -> i64 { return ds.cell_len[r * ds.ncols + c] }
called by 2: mainmain
99func dx_bytes_eq(a: *u8, an: i64, b: *u8, bn: i64) -> i64
called by 1: dx_equal
110func dx_equal(a: *NxDataset, b: *NxDataset) -> i64
called by 1: main calls 1: dx_bytes_eq
136func dx_field_needs_quote(p: *u8, n: i64) -> i64
called by 1: dx_emit_csv_field
150func dx_emit_csv_field(out: *u8, off: i64, cap: i64, p: *u8, n: i64) -> i64
called by 1: dx_emit_csv calls 1: dx_field_needs_quote
183func dx_emit_csv(ds: *NxDataset, out: *u8, cap: i64) -> i64
called by 3: mainmainmain calls 1: dx_emit_csv_field
221func dx_parse_csv(src: *u8, n: i64, ds: *NxDataset) -> i64
called by 1: main calls 2: sys_mmapdx_alloc
328func dx_emit_tsv(ds: *NxDataset, out: *u8, cap: i64) -> i64
called by 3: mainmainmain
363func dx_parse_tsv(src: *u8, n: i64, ds: *NxDataset) -> i64
called by 1: main calls 2: sys_mmapdx_alloc
423func dx_emit_json_str(out: *u8, off: i64, cap: i64, p: *u8, n: i64) -> i64
called by 1: dx_emit_json
457func dx_emit_json(ds: *NxDataset, out: *u8, cap: i64) -> i64
called by 3: mainmainmain calls 1: dx_emit_json_str
493func dx_json_unescape_string(src: *u8, n: i64, i_io: *i64, outbuf: *u8) -> i64
called by 1: dx_parse_json
539func dx_parse_json(src: *u8, n: i64, ds: *NxDataset) -> i64
620func main() -> i64