Skip to main content

Module datafile

Module datafile 

Source
Expand description

Data file nodes: ordinal-based access to CSV, JSONL, and text files.

Each node loads the file once at construction time (the filename is a const parameter), builds an in-memory index, and serves fast ordinal lookups at cycle time. Ordinals wrap via modulo so every u64 input is valid.

The single-source nodes (csv_row, csv_row_count, jsonl_row, jsonl_row_count) use #[poly_const(setup, from = filename)]. The two two-source nodes (csv_field, jsonl_field) use multi-source #[poly_const(setup, from = (filename, column|path))] to build the per-ordinal value table at construction time.

The macro-emitted new() is infallible; the setup function panics with a formatted error on bad file content, and the build closure carries the panic upward so workload compile surfaces the diagnostic text. This matches polydat-nodesregex.rs compile_regex(...).expect("invalid regex") setup.

Structs§

CsvField
Read a specific column from a CSV row at a given ordinal.
CsvRow
Read an entire CSV row at a given ordinal as a comma-separated string.
CsvRowCount
Return the number of data rows in a CSV file (init-time constant).
JsonlField
Read a field from a JSONL line at a given ordinal.
JsonlRow
Read an entire JSONL line at a given ordinal as a JSON string.
JsonlRowCount
Return the number of lines in a JSONL file (init-time constant).

Functions§

set_data_base_dir
Set the base directory relative data-file paths resolve against (the workload’s own directory). Returns the previous value so the caller can restore it — compiles nest. The compile entry points bracket their (synchronous) body with this; concurrent compiles on different threads keep independent values.