Documentation
¶
Overview ¶
Example 04_persistence — opens a WAL, performs a few transactions that include both node and edge labels, attaches typed properties directly on the in-memory graph, then takes a v2 snapshot (CSR + labels.bin + properties.bin) and demonstrates that labels and typed properties survive a restart. The flow mirrors what a production durability path looks like:
- Transactions append framed ops to the WAL and apply them to the in-memory LPG.
- Typed properties (currently not WAL-logged) are set directly on the graph.
- snapshot.WriteSnapshotFull persists the CSR view, labels.bin, and properties.bin atomically alongside the WAL.
- The process "restarts" — every in-memory reference is dropped and recovery.Open rebuilds the graph from disk. The WAL replay re-populates the mapper; labels.bin re-attaches the snapshot-time label set; properties.bin re-attaches the snapshot-time typed property set.
Sample output: run `go run ./examples/04_persistence` and capture the stdout — the output is deterministic for the inputs hard-coded above and serves as the regression baseline a future change should preserve. The example persists to a directory created with os.MkdirTemp; that path is intentionally kept out of stdout so the output stays stable across runs.