Storage Backends
Choose two independent components: a backend persists keys and bytes; a serializer encodes property payloads. Changing either choice for a new database does not convert an existing directory. Use The Property Graph for the entity model and Serializers for value types and codec trade-offs.
Backend Selection Summary
Backend / registry name |
Install extra |
When to consider it |
Main qualification |
|---|---|---|---|
|
|
Embedded transactions and coherent current-graph snapshots |
Provision sufficient |
|
|
Modest local graphs and straightforward embedded use |
GestaltDB’s multi-database layout has no graph-wide transaction/snapshot. |
|
|
RocksDB bulk ingestion and append-heavy workloads |
Default mode is nontransactional; native columnar writes need the appropriate input/runtime path. |
|
|
Explicit transactions and current snapshots on a capable PyRex runtime |
No native columnar writer on the current TransactionDB path. |
Install all built-in backends with gestaltdb[backends]. Add codec extras
independently, for example gestaltdb[lmdb,msgpack] or
gestaltdb[leveldb,protobuf]. Pickle and JSON need no serializer extra. A base
install contains no embedded backend.
Parameterless GraphDB.create(path) retains the pyrex backend default and
requires the rocksdb extra. It never silently falls back to another backend.
Selected dependencies are checked before creating/replacing storage. Python must
be within the package’s supported range (3.10–3.13); backend wheels and local build
tooling are additional installation constraints (Installation).
Create and reopen a self-describing database
Standalone runnable example. Requires gestaltdb[lmdb]. Prefer this
manifest-backed path when GestaltDB owns the database directory.
Standalone example. Choose the capability-qualified installation tab below.
The map_size option specifically configures LMDB; serializer choice is independent. Use the portable quickstart for other backend setups.
1python -m pip install "gestaltdb[lmdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 path = f"{root}/graph"
6 with GraphDB.create(
7 path, backend='lmdb', serializer='json',
8 backend_options={"map_size": 2**30},
9 indexed_node_properties=["name"],
10 ) as graph:
11 graph.put_node(Node("drug-1", labels=["Drug"], properties={"name": "Aspirin"}))
12
13 with GraphDB.open(path) as reopened:
14 assert reopened.manifest["backend"]["name"] == 'lmdb'
15 assert reopened.manifest["serializer"]["name"] == 'json'
16 assert [n.get_id for n in reopened.nodes_by_property("name", "Aspirin")] == ["drug-1"]
1python -m pip install "gestaltdb[lmdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 path = f"{root}/graph"
6 with GraphDB.create(
7 path, backend='lmdb', serializer='pickle',
8 backend_options={"map_size": 2**30},
9 indexed_node_properties=["name"],
10 ) as graph:
11 graph.put_node(Node("drug-1", labels=["Drug"], properties={"name": "Aspirin"}))
12
13 with GraphDB.open(path) as reopened:
14 assert reopened.manifest["backend"]["name"] == 'lmdb'
15 assert reopened.manifest["serializer"]["name"] == 'pickle'
16 assert [n.get_id for n in reopened.nodes_by_property("name", "Aspirin")] == ["drug-1"]
1python -m pip install "gestaltdb[lmdb,msgpack]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 path = f"{root}/graph"
6 with GraphDB.create(
7 path, backend='lmdb', serializer='messagepack',
8 backend_options={"map_size": 2**30},
9 indexed_node_properties=["name"],
10 ) as graph:
11 graph.put_node(Node("drug-1", labels=["Drug"], properties={"name": "Aspirin"}))
12
13 with GraphDB.open(path) as reopened:
14 assert reopened.manifest["backend"]["name"] == 'lmdb'
15 assert reopened.manifest["serializer"]["name"] == 'messagepack'
16 assert [n.get_id for n in reopened.nodes_by_property("name", "Aspirin")] == ["drug-1"]
1python -m pip install "gestaltdb[lmdb,protobuf]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 path = f"{root}/graph"
6 with GraphDB.create(
7 path, backend='lmdb', serializer='protobuf',
8 backend_options={"map_size": 2**30},
9 indexed_node_properties=["name"],
10 ) as graph:
11 graph.put_node(Node("drug-1", labels=["Drug"], properties={"name": "Aspirin"}))
12
13 with GraphDB.open(path) as reopened:
14 assert reopened.manifest["backend"]["name"] == 'lmdb'
15 assert reopened.manifest["serializer"]["name"] == 'protobuf'
16 assert [n.get_id for n in reopened.nodes_by_property("name", "Aspirin")] == ["drug-1"]
create writes gestaltdb_manifest.json with backend/serializer choices and
configuration. open restores those choices and the configured property-index
metadata; it is not a way to pick a different decoder for the same stored bytes.
It requires a manifest. A nonempty target directory is rejected by create
unless overwrite=True is explicitly supplied; overwrite replaces storage,
so never add it just to make a repeated notebook cell succeed.
For persistent applications, replace the temporary example path with an application-owned directory. Close the old handle before reopening it. A context manager closes the handle; it is not an implicit transaction around everything inside the block.
Direct store construction
Use direct construction when an application explicitly manages its store and
codec. It does not automatically create a filesystem manifest. Reopen with the
same compatible configuration, or explicitly write a manifest with
graph.save_manifest(path) before switching to GraphDB.open.
Standalone runnable example. Requires gestaltdb[leveldb,msgpack].
Standalone example. Choose the capability-qualified installation tab below.
Direct construction still needs matching classes and extras. JSON is omitted because this payload contains raw bytes.
1python -m pip install "gestaltdb[leveldb,msgpack]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3from gestaltdb.kvstores import LevelDBStore
4from gestaltdb.serializers import MessagePackSerializer
5
6with TemporaryDirectory() as root:
7 graph = GraphDB(LevelDBStore(path=f"{root}/graph"), MessagePackSerializer())
8 try:
9 graph.put_node(Node("sample-1", properties={"raw": b"abc"}))
10 assert graph.get_node("sample-1").properties["raw"] == b"abc"
11 finally:
12 graph.close()
1python -m pip install "gestaltdb[leveldb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3from gestaltdb.kvstores import LevelDBStore
4from gestaltdb.serializers import PickleSerializer
5
6with TemporaryDirectory() as root:
7 graph = GraphDB(LevelDBStore(path=f"{root}/graph"), PickleSerializer())
8 try:
9 graph.put_node(Node("sample-1", properties={"raw": b"abc"}))
10 assert graph.get_node("sample-1").properties["raw"] == b"abc"
11 finally:
12 graph.close()
1python -m pip install "gestaltdb[leveldb,protobuf]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3from gestaltdb.kvstores import LevelDBStore
4from gestaltdb.serializers import ProtobufSerializer
5
6with TemporaryDirectory() as root:
7 graph = GraphDB(LevelDBStore(path=f"{root}/graph"), ProtobufSerializer())
8 try:
9 graph.put_node(Node("sample-1", properties={"raw": b"abc"}))
10 assert graph.get_node("sample-1").properties["raw"] == b"abc"
11 finally:
12 graph.close()
1python -m pip install "gestaltdb[lmdb,msgpack]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3from gestaltdb.kvstores import LMDBStore
4from gestaltdb.serializers import MessagePackSerializer
5
6with TemporaryDirectory() as root:
7 graph = GraphDB(LMDBStore(path=f"{root}/graph"), MessagePackSerializer())
8 try:
9 graph.put_node(Node("sample-1", properties={"raw": b"abc"}))
10 assert graph.get_node("sample-1").properties["raw"] == b"abc"
11 finally:
12 graph.close()
1python -m pip install "gestaltdb[lmdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3from gestaltdb.kvstores import LMDBStore
4from gestaltdb.serializers import PickleSerializer
5
6with TemporaryDirectory() as root:
7 graph = GraphDB(LMDBStore(path=f"{root}/graph"), PickleSerializer())
8 try:
9 graph.put_node(Node("sample-1", properties={"raw": b"abc"}))
10 assert graph.get_node("sample-1").properties["raw"] == b"abc"
11 finally:
12 graph.close()
1python -m pip install "gestaltdb[lmdb,protobuf]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3from gestaltdb.kvstores import LMDBStore
4from gestaltdb.serializers import ProtobufSerializer
5
6with TemporaryDirectory() as root:
7 graph = GraphDB(LMDBStore(path=f"{root}/graph"), ProtobufSerializer())
8 try:
9 graph.put_node(Node("sample-1", properties={"raw": b"abc"}))
10 assert graph.get_node("sample-1").properties["raw"] == b"abc"
11 finally:
12 graph.close()
1python -m pip install "gestaltdb[msgpack,rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3from gestaltdb.kvstores import PyRexStore
4from gestaltdb.serializers import MessagePackSerializer
5
6with TemporaryDirectory() as root:
7 graph = GraphDB(PyRexStore(path=f"{root}/graph"), MessagePackSerializer())
8 try:
9 graph.put_node(Node("sample-1", properties={"raw": b"abc"}))
10 assert graph.get_node("sample-1").properties["raw"] == b"abc"
11 finally:
12 graph.close()
1python -m pip install "gestaltdb[rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3from gestaltdb.kvstores import PyRexStore
4from gestaltdb.serializers import PickleSerializer
5
6with TemporaryDirectory() as root:
7 graph = GraphDB(PyRexStore(path=f"{root}/graph"), PickleSerializer())
8 try:
9 graph.put_node(Node("sample-1", properties={"raw": b"abc"}))
10 assert graph.get_node("sample-1").properties["raw"] == b"abc"
11 finally:
12 graph.close()
1python -m pip install "gestaltdb[protobuf,rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3from gestaltdb.kvstores import PyRexStore
4from gestaltdb.serializers import ProtobufSerializer
5
6with TemporaryDirectory() as root:
7 graph = GraphDB(PyRexStore(path=f"{root}/graph"), ProtobufSerializer())
8 try:
9 graph.put_node(Node("sample-1", properties={"raw": b"abc"}))
10 assert graph.get_node("sample-1").properties["raw"] == b"abc"
11 finally:
12 graph.close()
Backend options and ingestion
LMDB Backend
Choose map_size for the intended database size. The same environment contains
named node/edge/adjacency/index/metadata databases. Native PyRex columnar writing
is not an LMDB capability.
LevelDB Backend
The plyvel dependency may need a compatible wheel or local LevelDB build
tooling. Columnar ingestion uses portable writes rather than PyRex’s native writer.
RocksDB Backend
parallelism, max_background_jobs, write_buffer_size and
bloom_bits_per_key are backend tuning options. Keep disable_wal=False for
durable writes; disabling WAL is only appropriate for explicitly
disposable/reloadable experiments, not a safe default.
Select transactional PyRex at creation with
backend="pyrex", backend_options={"transactional": True}. The manifest
retains that mode for open. Runtime capabilities remain explicit.
For structured JSON-compatible Arrow/Polars columns, entity-column ingestion can avoid Python row-wise payload construction on eligible native paths. Serialized payload ingestion accepts already encoded values. Neither API implies that every codec/backend gets the same fast path. Columnar edge ingestion is append-only. See Runnable API Workflows and Performance and Benchmarks for setup and measurements.
Indexes
Labels and relationship types are indexed automatically. Node/edge property indexes are explicit; their creation also provides composite and range lookup support. Current index definitions persist in backend metadata.
MAINTAIN keeps configured indexes current during ingestion. DEFER leaves
affected secondary indexes stale and requires rebuild_deferred_indexes();
high-level DEFER_REBUILD performs that rebuild before returning. Moving index
work out of the write window is not a guarantee of lower total ingest time.
See Property-Graph Filtering and Indexes for exact/range/ID/count APIs and freshness rules.
All backends enforce a 511-byte final encoded index key limit before backend I/O. URL-safe-base64 components expand input, so an ID/value below 511 raw bytes can still exceed the final limit. Oversized keys are rejected, not truncated. .. _backend-index-interface:
Low-level sorted-index primitives are backend interfaces; prefer graph-level lookups and index services in application code.
Transactions
Mode |
|
|
|---|---|---|
LMDB |
Supported across named databases |
Pinned, verifiable MVCC state |
LevelDB layout |
Unsupported |
Unsupported |
Plain PyRex |
Unsupported |
Unsupported |
Transactional PyRex |
Supported when the runtime exposes transactions |
Pinned when transaction snapshots are available; verifiable provenance requires PyRex >=0.7.0 |
Current RocksDB extras require pyrex-rocksdb>=0.7.1. The older 0.7.0 boundary
above explains snapshot capability, not permission to install an older dependency.
Explicit unsupported transaction/snapshot requests raise rather than downgrade to
a best-effort guarantee.
Standalone runnable example. Requires gestaltdb[lmdb]. Use the yielded
tx handle for every operation in the transaction. Clean exit commits;
an exception leaving the transaction rolls back.
Standalone example. Choose the capability-qualified installation tab below.
Rollback requires a transaction-capable backend; ordinary LevelDB/plain PyRex are not equivalent.
1python -m pip install "gestaltdb[lmdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='json') as graph:
6 with graph.transaction() as tx:
7 tx.put_nodes([Node("drug-1", labels=["Drug"]), Node("protein-1")])
8 try:
9 with graph.transaction() as tx:
10 tx.put_node(Node("discarded", labels=["Drug"]))
11 raise RuntimeError("abort this transaction")
12 except RuntimeError:
13 pass
14 assert graph.get_node("drug-1") is not None
15 assert graph.get_node("discarded") is None
16 assert [n.get_id for n in graph.nodes_by_label("Drug")] == ["drug-1"]
1python -m pip install "gestaltdb[lmdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='pickle') as graph:
6 with graph.transaction() as tx:
7 tx.put_nodes([Node("drug-1", labels=["Drug"]), Node("protein-1")])
8 try:
9 with graph.transaction() as tx:
10 tx.put_node(Node("discarded", labels=["Drug"]))
11 raise RuntimeError("abort this transaction")
12 except RuntimeError:
13 pass
14 assert graph.get_node("drug-1") is not None
15 assert graph.get_node("discarded") is None
16 assert [n.get_id for n in graph.nodes_by_label("Drug")] == ["drug-1"]
1python -m pip install "gestaltdb[lmdb,msgpack]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='messagepack') as graph:
6 with graph.transaction() as tx:
7 tx.put_nodes([Node("drug-1", labels=["Drug"]), Node("protein-1")])
8 try:
9 with graph.transaction() as tx:
10 tx.put_node(Node("discarded", labels=["Drug"]))
11 raise RuntimeError("abort this transaction")
12 except RuntimeError:
13 pass
14 assert graph.get_node("drug-1") is not None
15 assert graph.get_node("discarded") is None
16 assert [n.get_id for n in graph.nodes_by_label("Drug")] == ["drug-1"]
1python -m pip install "gestaltdb[lmdb,protobuf]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='protobuf') as graph:
6 with graph.transaction() as tx:
7 tx.put_nodes([Node("drug-1", labels=["Drug"]), Node("protein-1")])
8 try:
9 with graph.transaction() as tx:
10 tx.put_node(Node("discarded", labels=["Drug"]))
11 raise RuntimeError("abort this transaction")
12 except RuntimeError:
13 pass
14 assert graph.get_node("drug-1") is not None
15 assert graph.get_node("discarded") is None
16 assert [n.get_id for n in graph.nodes_by_label("Drug")] == ["drug-1"]
1python -m pip install "gestaltdb[rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', backend_options={"transactional": True}, serializer='json') as graph:
6 with graph.transaction() as tx:
7 tx.put_nodes([Node("drug-1", labels=["Drug"]), Node("protein-1")])
8 try:
9 with graph.transaction() as tx:
10 tx.put_node(Node("discarded", labels=["Drug"]))
11 raise RuntimeError("abort this transaction")
12 except RuntimeError:
13 pass
14 assert graph.get_node("drug-1") is not None
15 assert graph.get_node("discarded") is None
16 assert [n.get_id for n in graph.nodes_by_label("Drug")] == ["drug-1"]
1python -m pip install "gestaltdb[rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', backend_options={"transactional": True}, serializer='pickle') as graph:
6 with graph.transaction() as tx:
7 tx.put_nodes([Node("drug-1", labels=["Drug"]), Node("protein-1")])
8 try:
9 with graph.transaction() as tx:
10 tx.put_node(Node("discarded", labels=["Drug"]))
11 raise RuntimeError("abort this transaction")
12 except RuntimeError:
13 pass
14 assert graph.get_node("drug-1") is not None
15 assert graph.get_node("discarded") is None
16 assert [n.get_id for n in graph.nodes_by_label("Drug")] == ["drug-1"]
1python -m pip install "gestaltdb[msgpack,rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', backend_options={"transactional": True}, serializer='messagepack') as graph:
6 with graph.transaction() as tx:
7 tx.put_nodes([Node("drug-1", labels=["Drug"]), Node("protein-1")])
8 try:
9 with graph.transaction() as tx:
10 tx.put_node(Node("discarded", labels=["Drug"]))
11 raise RuntimeError("abort this transaction")
12 except RuntimeError:
13 pass
14 assert graph.get_node("drug-1") is not None
15 assert graph.get_node("discarded") is None
16 assert [n.get_id for n in graph.nodes_by_label("Drug")] == ["drug-1"]
1python -m pip install "gestaltdb[protobuf,rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', backend_options={"transactional": True}, serializer='protobuf') as graph:
6 with graph.transaction() as tx:
7 tx.put_nodes([Node("drug-1", labels=["Drug"]), Node("protein-1")])
8 try:
9 with graph.transaction() as tx:
10 tx.put_node(Node("discarded", labels=["Drug"]))
11 raise RuntimeError("abort this transaction")
12 except RuntimeError:
13 pass
14 assert graph.get_node("drug-1") is not None
15 assert graph.get_node("discarded") is None
16 assert [n.get_id for n in graph.nodes_by_label("Drug")] == ["drug-1"]
The context manager on GraphDB itself only owns handle lifetime. Do not infer
atomic read/modify/write behavior from separate calls, or cross-family atomicity
from a bulk-ingestion call. Use an explicit supported transaction for the required
scope. Individual APIs retain their own documented transaction boundaries.
Mutable Read Snapshots
A current read view binds records, adjacency, indexes and metadata to one backend
snapshot. It differs from a live read-only repository and from a historical
temporal read view. Standalone runnable example, requiring gestaltdb[lmdb]:
Standalone example. Choose the capability-qualified installation tab below.
This pinned-current-read example requires verifiable snapshot capability. Transactional PyRex uses the supported runtime floor, not plain PyRex.
1python -m pip install "gestaltdb[lmdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='json') as graph:
6 graph.put_node(Node("drug-1", properties={"revision": 1}))
7 with graph.current_read_view(require_verifiable=True) as view:
8 graph.put_node(Node("drug-1", properties={"revision": 2}))
9 assert view.nodes.get("drug-1").properties["revision"] == 1
10 assert view.provenance is not None
11 assert graph.get_node("drug-1").properties["revision"] == 2
1python -m pip install "gestaltdb[lmdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='pickle') as graph:
6 graph.put_node(Node("drug-1", properties={"revision": 1}))
7 with graph.current_read_view(require_verifiable=True) as view:
8 graph.put_node(Node("drug-1", properties={"revision": 2}))
9 assert view.nodes.get("drug-1").properties["revision"] == 1
10 assert view.provenance is not None
11 assert graph.get_node("drug-1").properties["revision"] == 2
1python -m pip install "gestaltdb[lmdb,msgpack]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='messagepack') as graph:
6 graph.put_node(Node("drug-1", properties={"revision": 1}))
7 with graph.current_read_view(require_verifiable=True) as view:
8 graph.put_node(Node("drug-1", properties={"revision": 2}))
9 assert view.nodes.get("drug-1").properties["revision"] == 1
10 assert view.provenance is not None
11 assert graph.get_node("drug-1").properties["revision"] == 2
1python -m pip install "gestaltdb[lmdb,protobuf]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='protobuf') as graph:
6 graph.put_node(Node("drug-1", properties={"revision": 1}))
7 with graph.current_read_view(require_verifiable=True) as view:
8 graph.put_node(Node("drug-1", properties={"revision": 2}))
9 assert view.nodes.get("drug-1").properties["revision"] == 1
10 assert view.provenance is not None
11 assert graph.get_node("drug-1").properties["revision"] == 2
1python -m pip install "gestaltdb[rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', backend_options={"transactional": True}, serializer='json') as graph:
6 graph.put_node(Node("drug-1", properties={"revision": 1}))
7 with graph.current_read_view(require_verifiable=True) as view:
8 graph.put_node(Node("drug-1", properties={"revision": 2}))
9 assert view.nodes.get("drug-1").properties["revision"] == 1
10 assert view.provenance is not None
11 assert graph.get_node("drug-1").properties["revision"] == 2
1python -m pip install "gestaltdb[rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', backend_options={"transactional": True}, serializer='pickle') as graph:
6 graph.put_node(Node("drug-1", properties={"revision": 1}))
7 with graph.current_read_view(require_verifiable=True) as view:
8 graph.put_node(Node("drug-1", properties={"revision": 2}))
9 assert view.nodes.get("drug-1").properties["revision"] == 1
10 assert view.provenance is not None
11 assert graph.get_node("drug-1").properties["revision"] == 2
1python -m pip install "gestaltdb[msgpack,rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', backend_options={"transactional": True}, serializer='messagepack') as graph:
6 graph.put_node(Node("drug-1", properties={"revision": 1}))
7 with graph.current_read_view(require_verifiable=True) as view:
8 graph.put_node(Node("drug-1", properties={"revision": 2}))
9 assert view.nodes.get("drug-1").properties["revision"] == 1
10 assert view.provenance is not None
11 assert graph.get_node("drug-1").properties["revision"] == 2
1python -m pip install "gestaltdb[protobuf,rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', backend_options={"transactional": True}, serializer='protobuf') as graph:
6 graph.put_node(Node("drug-1", properties={"revision": 1}))
7 with graph.current_read_view(require_verifiable=True) as view:
8 graph.put_node(Node("drug-1", properties={"revision": 2}))
9 assert view.nodes.get("drug-1").properties["revision"] == 1
10 assert view.provenance is not None
11 assert graph.get_node("drug-1").properties["revision"] == 2
Verifiable provenance includes a snapshot sequence and full-state digest;
capturing it therefore scans the store. capture_provenance=False avoids that
digest when a caller needs only a pinned read, not a verifiable provenance record.
Do not retain view readers after the view closes.
Unqualified read-only Cypher automatically pins reads on capable backends without
capturing the full-state digest. read_snapshot=True explicitly requires a
snapshot; False opts out. High-level non-temporal sampler builds automatically
use verifiable snapshots where available; read_snapshot=True requires that
stronger build guarantee. Unsupported requests fail before building. Memmap
loading of a built sampler artifact is separate from these database snapshots.
Temporal publication and coordination
Temporal history is not the same as mutable graph transactions. LMDB and transactional PyRex can publish version records and visibility markers in one transaction. LevelDB/plain PyRex publish the marker last; interrupted unmarked artifacts stay invisible, and recovery is explicit. Cooperating filesystem-backed temporal writers are serialized across handles/processes with file locks.
Those locks do not turn all ordinary mutable operations into globally serialized
transactions or protect against arbitrary external storage modification. See
Temporal history and service reference and Compatibility, Migration, and Recovery for writer coordination,
orphan recovery, index rebuilding and deprecated TimeIndexedEdge migration.
Do not delete canonical history to repair a derived index.
Measurements and next steps
Backend choice is workload-dependent. Account for codec work, index maintenance, ingestion, snapshot construction and steady-state reads separately. Historical numbers formerly embedded in this page remain in Historical Storage Backend Measurements; they are not fresh v0.17.0 measurements or a universal backend ranking. Use Performance and Benchmarks to reproduce relevant workloads.
Cleanup
Close graph handles with a context manager or try/finally as shown above.
Close transaction/read-view scopes before the parent handle and do not reuse
borrowed readers afterward. Back up and quiesce the database before migration
or recovery; closing a handle is not a migration or backup procedure.