Skip to main content

Crate sparrowdb

Crate sparrowdb 

Source
Expand description

SparrowDB — top-level public API.

§Transaction model (Phase 5 — SWMR)

  • Single Writer: at most one WriteTx may be active at a time. GraphDb::begin_write returns Error::WriterBusy if a writer is already open.

  • Multiple Readers: any number of ReadTx handles may coexist with an active writer. Each reader pins the committed txn_id at open time and sees only data committed at or before that snapshot.

§Snapshot isolation for set_node_col

Property updates (set_node_col) are recorded in an in-memory version chain keyed by (NodeId, col_id). Each entry is a (txn_id, Value) pair. When a ReadTx reads a property it first consults the version chain and returns the most-recent value with txn_id <= snapshot_txn_id, falling back to the on-disk value written by create_node if no such entry exists.

§Quick start

use sparrowdb::GraphDb;
let db = GraphDb::open(std::path::Path::new("/tmp/my.sparrow")).unwrap();
db.checkpoint().unwrap();
db.optimize().unwrap();

Re-exports§

pub use export::EdgeDump;
pub use export::GraphDump;
pub use export::NodeDump;

Modules§

export
Graph export / import tooling for cross-version migration (SPA-XXX).

Structs§

DbStats
Storage-size snapshot returned by GraphDb::stats (SPA-171).
EdgeId
Opaque 64-bit edge identifier. Edge identifier: monotonic u64 sourced from the active metapage.
GraphDb
The top-level SparrowDB handle.
NodeId
Opaque 64-bit node identifier. Node identifier: upper 16 bits = label_id, lower 48 bits = slot_id.
QueryResult
Query result returned by GraphDb::execute and [GraphDb::execute_write]. Contains column names and rows of scalar Value cells. Final materialized query result.
ReadTx
A read-only snapshot transaction.
WriteTx
A write transaction.

Enums§

Error
Error type returned by all SparrowDB operations. All errors that SparrowDB can return.
Value
Scalar value type used in query results and node property reads/writes. A typed property value.

Functions§

cypher_escape_string
Escape a Rust &str so it can be safely interpolated inside a single-quoted Cypher string literal.
fnv1a_col_id
Derive a stable u32 column ID from a property key name.
migrate_wal
Migrate WAL segments from legacy v21 (CRC32 IEEE) to v2 (CRC32C Castagnoli).
open
Convenience wrapper — equivalent to GraphDb::open.

Type Aliases§

Result
Convenience alias: std::result::Result<T, sparrowdb::Error>. Crate-wide result type.
SparrowDB
Legacy alias kept for backward compatibility with Phase 0 tests.