code wiki / (root) / nx_ingest_bulk_test.nx

nx_ingest_bulk_test.nx source

↩ module page · 86 lines · 3691 B

1// nx_ingest_bulk_test.nx -- bulk ingest smoke against gbif_bulk/. 2// 3// Drives the SAME nx_ingest_batch_run over a different fixture dir 4// (../../nishi-library/fixtures/gbif_bulk/) writing to 5// ingested_bulk.jsonl. Exercises the envelope-unwrap path 6// ({offset, limit, results: [...]} -> emit each inner OBJECT). 7// 8// Per cardinal feedback-build-the-system-not-manual-output: 9// same SYSTEM, more fixtures, more rows. Zero per-call config. 10 11import "syscalls.nx" 12import "nx_ingest_batch.nx" 13 14const NX_TEST_NOW_UNIX: i64 = 1747436400 15 16func make_dir_path(out: *u8) -> i64 { 17 // "../../nishi-library/fixtures/gbif_bulk/single" (45 bytes) 18 // Single-page subdir: shell wrapper rotates one page in at a 19 // time to keep the parser arena bounded per-invocation. 20 out[0] = 0x2E; out[1] = 0x2E; out[2] = 0x2F 21 out[3] = 0x2E; out[4] = 0x2E; out[5] = 0x2F 22 out[6] = 0x6E; out[7] = 0x69; out[8] = 0x73; out[9] = 0x68 23 out[10] = 0x69; out[11] = 0x2D; out[12] = 0x6C; out[13] = 0x69 24 out[14] = 0x62; out[15] = 0x72; out[16] = 0x61; out[17] = 0x72 25 out[18] = 0x79; out[19] = 0x2F 26 out[20] = 0x66; out[21] = 0x69; out[22] = 0x78; out[23] = 0x74 27 out[24] = 0x75; out[25] = 0x72; out[26] = 0x65; out[27] = 0x73 28 out[28] = 0x2F 29 out[29] = 0x67; out[30] = 0x62; out[31] = 0x69; out[32] = 0x66 30 out[33] = 0x5F; out[34] = 0x62; out[35] = 0x75; out[36] = 0x6C 31 out[37] = 0x6B 32 out[38] = 0x2F 33 out[39] = 0x73; out[40] = 0x69; out[41] = 0x6E; out[42] = 0x67 34 out[43] = 0x6C; out[44] = 0x65 // "single" 35 out[45] = 0 36 return 45 37} 38 39func make_out_path(out: *u8) -> i64 { 40 // "../../nishi-library/fixtures/gbif_bulk/single/page.jsonl" 41 out[0] = 0x2E; out[1] = 0x2E; out[2] = 0x2F 42 out[3] = 0x2E; out[4] = 0x2E; out[5] = 0x2F 43 out[6] = 0x6E; out[7] = 0x69; out[8] = 0x73; out[9] = 0x68 44 out[10] = 0x69; out[11] = 0x2D; out[12] = 0x6C; out[13] = 0x69 45 out[14] = 0x62; out[15] = 0x72; out[16] = 0x61; out[17] = 0x72 46 out[18] = 0x79; out[19] = 0x2F 47 out[20] = 0x66; out[21] = 0x69; out[22] = 0x78; out[23] = 0x74 48 out[24] = 0x75; out[25] = 0x72; out[26] = 0x65; out[27] = 0x73 49 out[28] = 0x2F 50 out[29] = 0x67; out[30] = 0x62; out[31] = 0x69; out[32] = 0x66 51 out[33] = 0x5F; out[34] = 0x62; out[35] = 0x75; out[36] = 0x6C 52 out[37] = 0x6B 53 out[38] = 0x2F 54 out[39] = 0x73; out[40] = 0x69; out[41] = 0x6E; out[42] = 0x67 55 out[43] = 0x6C; out[44] = 0x65 // "single" 56 out[45] = 0x2F 57 out[46] = 0x70; out[47] = 0x61; out[48] = 0x67; out[49] = 0x65 // "page" 58 out[50] = 0x2E; out[51] = 0x6A; out[52] = 0x73; out[53] = 0x6F // ".jso" 59 out[54] = 0x6E; out[55] = 0x6C // "nl" 60 out[56] = 0 61 return 56 62} 63 64func main() -> i64 { 65 let dpath: *u8 = sys_mmap(64) 66 let dlen: i64 = make_dir_path(dpath) 67 let opath: *u8 = sys_mmap(64) 68 make_out_path(opath) 69 70 let sfx: *u8 = sys_mmap(4); sfx[0] = 0 71 72 let rep_raw: *u8 = sys_mmap(NX_INGEST_REPORT_BYTES) 73 let rep: *NxIngestReport = rep_raw as *NxIngestReport 74 75 let v: i64 = nx_ingest_batch_run( 76 dpath, dlen, sfx, 0, opath, rep, NX_TEST_NOW_UNIX) 77 78 if v != NX_INGEST_OK { return __syscall(93, 1, 0, 0, 0, 0, 0) } 79 if rep.verdict != NX_INGEST_OK { return __syscall(93, 2, 0, 0, 0, 0, 0) } 80 if rep.files_matched < 1 { return __syscall(93, 3, 0, 0, 0, 0, 0) } 81 if rep.parses_failed != 0 { return __syscall(93, 4, 0, 0, 0, 0, 0) } 82 // One GBIF page has 1000 results; envelope unwrap MUST fire. 83 if rep.rows_emitted < 500 { return __syscall(93, 5, 0, 0, 0, 0, 0) } 84 85 return 0 86}