Expand description
mushroomdb import: bulk load of a nodes CSV and a relationships CSV.
The header conventions are the widely used bulk-import ones:
- nodes:
:ID(the node key),:LABEL, then property columns; - relationships:
:START_ID,:END_ID,:TYPE, then property columns; - a property column may carry a type suffix:
age:int,weight:float,active:boolean,tags:string[]. No suffix means a string.
The data flows through the engine’s ordinary batch path
(GraphDb::ingest for nodes, GraphDb::write_batch for edges), one
WAL frame and one fsync per batch, so everything the engine guarantees about
a committed batch holds here. What the import adds is what it leaves out:
no auto-declared foreign-key rules (AutoFk::Off), no per-row dedupe round
trips beyond one key lookup, and a single snapshot at the end.
§Rules
The import never declares a rule. Rules the store already has fire on each
batch exactly as they do for any other write, so the final store is the one
incremental ingest of the same rows produces. The fast route is to import
into a store with no rules and declare them afterwards: create_rule
backfills in one pass, and the differential test in
crates/cli/tests/csv_import.rs pins that the two routes derive the same
edges.
§Crash safety
Every batch is one atomic WAL frame, so an import killed part-way leaves a store that opens, holding every batch that committed and none of the one in flight. Derived (rule-owned) edges are not in the WAL; they are rebuilt on open from the base data, so an interrupted import loses no base data and the derived edges are whatever the committed base data derives. The snapshot that ends a successful import is written last; an import that dies before it simply has a longer WAL to replay. The import is not all-or-nothing: batches committed before an error or a crash stay.
Structs§
- Batch
Progress - One committed batch, reported to the callback of
run_import_with_progress. - Column
Type - A property column’s declared type: a scalar, or an array of it.
- Import
Inputs - The files one import reads. Any of them may be absent; at least one is
needed. They load in this order: nodes (CSV, then JSONL), edges (CSV, then
JSONL), rules. A JSONL path of
-reads standard input. - Import
Options - Options for
run_import. - Import
Report - What an import did.
- Node
Schema - A parsed nodes-file header.
- Prop
Column - One property column of a header.
- RelSchema
- A parsed relationships-file header.
Enums§
- Scalar
Type - The scalar type of a property column.
Constants§
- DEFAULT_
BATCH_ SIZE - Default rows per committed batch.
- JSONL_
PROPS_ FIELD - The property of a
nodes.jsonlline that holds the properties whose names the line itself uses (key,label, and this one).
Functions§
- check_
quoting - Check that every quote in
inputfollows RFC 4180: a quoted field opens at the start of a field,""is a literal quote inside it, and the closing quote is followed by a delimiter or a line end. Returns the message, with its line, for the first violation. - format_
import - The summary
mushroomdb importprints. - import_
inputs_ into import_intofor every kind of input file.- import_
into - The import itself, on a store the caller holds open and takes the snapshot
of:
run_import_with_progressis this plus the open and the snapshot. Public so a test can read the store while the importing handle is live. - json_
to_ exact_ value - A JSON value as a stored
Value, keeping a float a float. - parse_
node_ header - Parse a nodes-file header. Needs exactly one
:IDand one:LABEL. - parse_
node_ row - Parse one node row into its label and property map, key included under
schema.key_field. An empty property cell is an absent property. - parse_
rel_ header - Parse a relationships-file header. Needs exactly one each of
:START_ID,:END_IDand:TYPE. - parse_
rel_ row - Parse one relationship row into
(type, start, end). - run_
import - Import
nodes_csvand thenrels_csvinto the store atdb_dir(created if absent). At least one file is required. - run_
import_ inputs - Import every file of
inputsinto the store atdb_dir(created if absent), then take one snapshot. - run_
import_ with_ progress run_import, callingon_batchafter every batch that committed.