pub struct Graph { /* private fields */ }Implementations§
Source§impl Graph
impl Graph
Sourcepub fn used_bytes(&self) -> u64
pub fn used_bytes(&self) -> u64
Live graph + index logical bytes (ADR-0042, ADR-0202).
Sourcepub fn accounted_bytes(&self) -> u64
pub fn accounted_bytes(&self) -> u64
Full walk of retained versions, adjacency, and the interner
(test / rebuild_indexes oracle).
pub fn recompute_used(&self)
Sourcepub fn estimate_redo_delta(&self, ops: &[RedoOp]) -> i64
pub fn estimate_redo_delta(&self, ops: &[RedoOp]) -> i64
Live-size delta of ops. Nodes are accounted under the charge in
force after ops; when that differs from the current charge (DDL in
the batch), every retained version — including ones ops tombstone —
is moved from the old charge to the new one. A delete keeps its
record until GC, so it adds nothing. A copy-on-write set adds the
new version.
Sourcepub fn enforce_adjacency_limits(
&self,
ops: &[RedoOp],
earlier: &[&[RedoOp]],
) -> Result<()>
pub fn enforce_adjacency_limits( &self, ops: &[RedoOp], earlier: &[&[RedoOp]], ) -> Result<()>
The adjacency tier’s structural limits (ADR-0599), the ones its
field widths state: a node holds at most [MAX_SPAN_TYPES] distinct
rel types in one direction (the span length’s u16), and one
direction’s arena at most u32::MAX stream bytes (the entry
offset’s u32). Enforced here, at admission, before the redo is
logged — the tier’s own mutation paths are infallible by design, so
the wall they must never hit is refused upstream. A delete never
breaches either: it founds a sealed entry only for a type the node
already holds, and its tombstone terms reclaim at the fold.
earlier are the ops of slots this group commit already accepted:
the type wall is per group, not per slot — two slots that each add
types under the bound must be refused when their combined types
cross it, so this slot’s creates are counted on top of the group’s.
Each earlier slot passed the same walk at its own admission, so the
combined walk never fails on the earlier batches alone.
Source§impl Graph
impl Graph
pub fn degree_out(&self, id: NodeId) -> Vec<RelId>
Sourcepub fn adj_len(&self, id: NodeId, dir: Direction) -> usize
pub fn adj_len(&self, id: NodeId, dir: Direction) -> usize
Adjacency length without allocation or type/overlay filtering — an approximate degree for choosing which side of an existence probe to walk (LABS-193).
pub fn degree_in(&self, id: NodeId) -> Vec<RelId>
pub fn neighbors(&self, id: NodeId, dir: Direction) -> Vec<RelId>
Sourcepub fn for_each_neighbor_at<T: AsRef<str>>(
&self,
id: NodeId,
dir: Direction,
ts: u64,
types: &[T],
f: impl FnMut(RelId),
)
pub fn for_each_neighbor_at<T: AsRef<str>>( &self, id: NodeId, dir: Direction, ts: u64, types: &[T], f: impl FnMut(RelId), )
Snapshot-visible neighbors. types is the name-keyed boundary
spelling: it resolves once, then the walk compares interned ids
(Self::try_for_each_neighbor_resolved_at). Hop ids are copied
out from under the store lock before the callback runs, so a
variable-length walk can re-enter this same store.
pub fn neighbors_at(&self, id: NodeId, dir: Direction, ts: u64) -> Vec<RelId>
Source§impl Graph
impl Graph
Sourcepub fn write_set_conflicts(&self, snapshot_ts: u64, ops: &[RedoOp]) -> bool
pub fn write_set_conflicts(&self, snapshot_ts: u64, ops: &[RedoOp]) -> bool
True when ops cannot commit on top of snapshot_ts (ADR-0015).
Sourcepub fn redo_conflicts_with_later(ops: &[RedoOp], later: &[RedoOp]) -> bool
pub fn redo_conflicts_with_later(ops: &[RedoOp], later: &[RedoOp]) -> bool
True when ops would conflict with a later unapplied redo list
(ADR-0015 / ADR-0019 group commit).
Source§impl Graph
impl Graph
Sourcepub fn range_indexed_node_properties(&self) -> Vec<(String, String)>
pub fn range_indexed_node_properties(&self) -> Vec<(String, String)>
The node (label, property) pairs the store’s RANGE indexes serve an
equality seek on, read from the typed catalog details
(IndexDetailSpec::range_seek_pairs) rather than re-parsed from the
rendered :Label(property) text: every component of a composite range
index is covered, a relationship index contributes no node pair, and a
comma-bearing property name stays one name.
Source§impl Graph
impl Graph
Sourcepub fn pattern_degree_tail(&self, label: &str, rel_type: &str) -> Option<u64>
pub fn pattern_degree_tail(&self, label: &str, rel_type: &str) -> Option<u64>
LABS-351: the tail of a (label, rel-type) out-degree distribution —
the conservative floor of the highest observed degree
(2^k for the highest non-empty bucket k), high-water across
deletes. None when nothing of that pair was ever written. This
is the estimate the mean degree cannot express: one 50k-degree
supernode in a 55-average label.
Sourcepub fn pattern_degree_tail_by_id(
&self,
label_id: u32,
type_id: u32,
) -> Option<u64>
pub fn pattern_degree_tail_by_id( &self, label_id: u32, type_id: u32, ) -> Option<u64>
Graph::pattern_degree_tail for already-resolved token ids.
Source§impl Graph
impl Graph
pub fn create_node( &self, labels: Vec<String>, properties: BTreeMap<String, Value>, ) -> Result<NodeId>
pub fn create_rel( &self, start: NodeId, end: NodeId, rel_type: String, properties: BTreeMap<String, Value>, ) -> Result<RelId>
pub fn set_property_node(&self, id: NodeId, key: &str, value: Value)
pub fn set_property_rel(&self, id: RelId, key: &str, value: Value)
pub fn merge_properties_node(&self, id: NodeId, map: &BTreeMap<String, Value>)
pub fn delete_rel(&self, id: RelId)
pub fn delete_node(&self, id: NodeId, detach: bool) -> Result<()>
Source§impl Graph
impl Graph
Sourcepub fn rebuild_indexes(&self)
pub fn rebuild_indexes(&self)
Rebuild the indexes from the live versions. Adjacency is left as it
is: writes and replayed redo keep it current, and
Graph::finish_restore builds it after a checkpoint load. The open
flow’s single post-replay site owns this rebuild — exactly once per
open, after the graph is final (snapshot plus replayed tail).
pub fn gc_versions(&self)
Source§impl Graph
impl Graph
Sourcepub fn pattern_label_rows(&self, label: &str) -> u64
pub fn pattern_label_rows(&self, label: &str) -> u64
Nodes stored under label. 0 when the label is absent.
The label index can hold stale ids, so this is an upper bound used
only to compare pattern costs — the same label-index estimate as
Self::label_count, which owns the one implementation, so this
pattern-stats spelling delegates to it.
Sourcepub fn pattern_equality_rows(
&self,
label: &str,
property: &str,
value: &Value,
) -> Option<u64>
pub fn pattern_equality_rows( &self, label: &str, property: &str, value: &Value, ) -> Option<u64>
Equality hits for a RANGE index on (label, property). None when
that index does not exist.
Sourcepub fn pattern_equality_rows_by_id(
&self,
lid: u32,
kid: u32,
value: &Value,
) -> Option<u64>
pub fn pattern_equality_rows_by_id( &self, lid: u32, kid: u32, value: &Value, ) -> Option<u64>
Graph::pattern_equality_rows for already-resolved token ids.
Sourcepub fn pattern_range_rows(
&self,
label: &str,
property: &str,
op: BinaryOp,
bound: &Value,
) -> Option<u64>
pub fn pattern_range_rows( &self, label: &str, property: &str, op: BinaryOp, bound: &Value, ) -> Option<u64>
Range-window hits for one comparison predicate on a RANGE index
over (label, property) (ADR-0486): the posting-length count the
one Graph::range_seek_cardinality answers — the same count the
executor’s seek cardinality reads, so the ladder’s price and the
runtime seek cannot drift, and the decline conditions are exactly
the seek’s (no index on the pair, no order key on the bound, or
unbounded temporal postings). op is one of the four comparison
ops — the planner’s recognizer gates the domain, = is
Graph::pattern_equality_rows’s. The count is an upper bound,
not snapshot-filtered. None is not zero hits.
Sourcepub fn pattern_contains_rows(
&self,
label: &str,
property: &str,
needle: &str,
) -> ContainsCount
pub fn pattern_contains_rows( &self, label: &str, property: &str, needle: &str, ) -> ContainsCount
CONTAINS candidates for the pattern-stats ladder (ADR-0218):
the exact count a TEXT index on (label, property) answers, and —
LABS-643 — without that index the bounded sampled estimate
carrying its whole-label scan rows, never None. The planner’s
CONTAINS level used to be measurable only through a TEXT index, so
a RANGE-only store fell back to whole-label rows (GBL SF0.1 q19:
Tag priced at its 16k label rows lost the seed to Place’s 1.4k,
and the walk rode 342k neighbor hops for a query whose needle
selects ~35 tags). The sampled form’s scan field is the one the
compound start estimate (ADR-0474) floors the seed’s walk with.
Source§impl Graph
impl Graph
Sourcepub fn label_count(&self, label: &str) -> u64
pub fn label_count(&self, label: &str) -> u64
Approximate number of nodes carrying label: the label-index set
size (ADR-0218). Plan-time estimate only — it is O(1), ignores
snapshot visibility, and counts every id the index holds; a label
the store has never interned is 0.
Sourcepub fn label_count_by_id(&self, lid: u32) -> u64
pub fn label_count_by_id(&self, lid: u32) -> u64
Graph::label_count for an already-resolved label token id.
pub fn lookup_nodes( &self, labels: &[String], props: &BTreeMap<String, Value>, ) -> Option<Vec<NodeId>>
Sourcepub fn lookup_nodes_at(
&self,
labels: &[String],
props: &BTreeMap<String, Value>,
ts: u64,
) -> Option<Vec<NodeId>>
pub fn lookup_nodes_at( &self, labels: &[String], props: &BTreeMap<String, Value>, ts: u64, ) -> Option<Vec<NodeId>>
The label/property candidate lookup at ts, ascending and
deduplicated: None only for the both-empty Unindexed arm —
the shape the caller scans for instead — a non-empty seek is
always served.
Sourcepub fn lookup_nodes_upto_at(
&self,
labels: &[String],
props: &BTreeMap<String, Value>,
ts: u64,
cap: Option<usize>,
) -> Option<Vec<NodeId>>
pub fn lookup_nodes_upto_at( &self, labels: &[String], props: &BTreeMap<String, Value>, ts: u64, cap: Option<usize>, ) -> Option<Vec<NodeId>>
Graph::lookup_nodes_at for a caller that only needs to know
whether more than cap nodes match: a residual scan stops once it
has cap + 1 matches. An answer of at most cap ids is complete,
ascending and deduplicated; a longer one is an arbitrary
cap + 1-id subset of the matches, meaningful only by its length.
Index-served arms answer in full (their postings already exist);
None is the both-empty Unindexed arm, as for the uncapped form.
pub fn lookup_string_contains_at( &self, labels: &[String], key: &str, needle: &str, ts: u64, ) -> Option<Vec<NodeId>>
Source§impl Graph
impl Graph
pub fn add_labels(&self, id: NodeId, labels: &[String])
pub fn remove_labels(&self, id: NodeId, labels: &[String])
Source§impl Graph
impl Graph
Sourcepub fn pin_now(&self) -> Result<SnapshotPin<'_>>
pub fn pin_now(&self) -> Result<SnapshotPin<'_>>
Pin commit_ts so GC cannot drop versions this statement still sees.
The slot protocol is lock-free (ADR-0038). When every slot is
occupied the wait is bounded: the array is retried a fixed number of
times and then acquisition fails with a typed
Error::Execution("snapshot pin: …") instead of spinning forever
(ADR-0111).
pub fn unpin_slot(&self, slot: usize)
Sourcepub fn snapshot_pinned(&self) -> bool
pub fn snapshot_pinned(&self) -> bool
True while any statement or explicit transaction holds a snapshot pin.
Sourcepub fn gc_horizon(&self) -> u64
pub fn gc_horizon(&self) -> u64
Lowest timestamp that may still be read. Dead iff xmax != 0 && xmax <= horizon.
Source§impl Graph
impl Graph
Sourcepub fn validate_redo_applicability(
&self,
ops: &[RedoOp],
commit_ts: u64,
) -> Result<()>
pub fn validate_redo_applicability( &self, ops: &[RedoOp], commit_ts: u64, ) -> Result<()>
Read-only ordered applicability check for a record against a stable graph. The caller serializes it with writers.
Sourcepub fn validate_redo_group_applicability<'a>(
&self,
records: impl IntoIterator<Item = (&'a [RedoOp], u64)>,
) -> Result<()>
pub fn validate_redo_group_applicability<'a>( &self, records: impl IntoIterator<Item = (&'a [RedoOp], u64)>, ) -> Result<()>
Validate independent records in commit order against one touched-state view, without copying any of the group’s property payloads.
Source§impl Graph
impl Graph
Sourcepub fn dirty_node_ids(&self) -> HashSet<NodeId>
pub fn dirty_node_ids(&self) -> HashSet<NodeId>
Node ids changed since the last clear_checkpoint_dirty (ADR-0022).
Sourcepub fn dirty_rel_ids(&self) -> HashSet<RelId>
pub fn dirty_rel_ids(&self) -> HashSet<RelId>
Relationship ids changed since the last clear_checkpoint_dirty.
pub fn clear_checkpoint_dirty(&self)
Sourcepub fn node_checkpoint_bytes(&self, id: NodeId, ts: u64) -> Result<Option<u64>>
pub fn node_checkpoint_bytes(&self, id: NodeId, ts: u64) -> Result<Option<u64>>
Variable checkpoint payload of the node visible at ts: label bytes
plus tagged property JSON. The Parquet codec adds its Int64 column
width. Borrows compact properties; does not build the property map.
Sourcepub fn rel_checkpoint_bytes(&self, id: RelId, ts: u64) -> Result<Option<u64>>
pub fn rel_checkpoint_bytes(&self, id: RelId, ts: u64) -> Result<Option<u64>>
Variable checkpoint payload of the relationship visible at ts:
type-name bytes plus tagged property JSON. The Parquet codec adds
its Int64 column width.
Sourcepub fn load_checkpoint_node(&self, node: Node) -> Result<()>
pub fn load_checkpoint_node(&self, node: Node) -> Result<()>
Restore a node from a checkpoint (visible at commit_ts). Loading an
id again replaces its row; the later row wins. Only valid on a graph
being restored, before any write: an open write is Error::Storage.
The label index is built by Graph::finish_restore after the load.
Sourcepub fn load_checkpoint_rel(&self, rel: Relationship) -> Result<()>
pub fn load_checkpoint_rel(&self, rel: Relationship) -> Result<()>
Restore a relationship from a checkpoint. Loading an id again
replaces its row, endpoints and type included; the later row wins.
Only valid on a graph being restored, before any write: an open
write is Error::Storage. Adjacency is built from the restored rows
by Graph::finish_restore after the load.
Source§impl Graph
impl Graph
pub fn named_indexes(&self) -> Vec<IndexDef>
Sourcepub fn schema_snapshot(&self) -> SchemaSnapshot
pub fn schema_snapshot(&self) -> SchemaSnapshot
Capture named indexes, constraints and their SHOW metadata at one
admission boundary. Embedded callers hold the publication read guard
across this call and pin_now; direct callers must serialize with
their own graph writers in the same way.
pub fn named_constraints(&self) -> Vec<ConstraintDef>
Sourcepub fn install_named_constraint(&self, def: ConstraintDef) -> Result<()>
pub fn install_named_constraint(&self, def: ConstraintDef) -> Result<()>
Install one catalog constraint row. Restore paths only: this mutates
the catalog WITHOUT the maintained constraint-key map (ADR-0439), so
the caller must finish with rebuild_indexes / finish_restore,
which builds the map from the catalog ∪ the theater’s derived set.
Calling it on a live graph would leave a uniqueness constraint the
admission probe cannot see.
pub fn named_index(&self, name: &str) -> Option<IndexDef>
Sourcepub fn has_constraint(&self, name: &str) -> bool
pub fn has_constraint(&self, name: &str) -> bool
By-name constraint probe, the constraint side of Self::named_index.
pub fn named_index_by_schema( &self, label: &str, property: &str, ) -> Option<IndexDef>
pub fn install_named_index(&self, def: IndexDef) -> Result<()>
Source§impl Graph
impl Graph
Sourcepub fn pattern_engine(&self) -> PatternEngine
pub fn pattern_engine(&self) -> PatternEngine
The store-level pattern-engine switch (ADR-0519) the kernel
rungs’ routing reads: PatternEngine::Auto on every store
opened without the diagnostic variable. Public since LABS-1117:
the EXPLAIN tree stamps it on every MATCH operator, so the one
static rung fact travels with the plan.
Source§impl Graph
impl Graph
Sourcepub fn graph_type_spec(&self) -> Result<Option<String>>
pub fn graph_type_spec(&self) -> Result<Option<String>>
CIP-176 spec string for the JSON snapshot codec (ADR-0050). A deserialized default value the canonical renderer cannot render is the storage-corruption error family the checkpoint path uses for the same persisted bytes (typed, never a panic).
Source§impl Graph
impl Graph
Sourcepub fn namespace(&self) -> Namespace
pub fn namespace(&self) -> Namespace
Which fixed namespace of the store this graph is (ADR-0116 §1).
pub fn commit_ts(&self) -> u64
pub fn set_commit_ts(&self, ts: u64)
pub fn next_node_id(&self) -> NodeId
pub fn set_next_node_id(&self, id: NodeId)
pub fn next_rel_id(&self) -> RelId
pub fn set_next_rel_id(&self, id: RelId)
Sourcepub fn begin_write(&self) -> Result<()>
pub fn begin_write(&self) -> Result<()>
Begin a write statement: versions get xmin = commit_ts+1 until publish.
Returns Execution if the next timestamp is the unsupported sentinel.
Sourcepub fn begin_write_at(&self, write_ts: u64) -> Result<()>
pub fn begin_write_at(&self, write_ts: u64) -> Result<()>
Begin a write with an explicit txn id (ADR-0015 optimistic snapshot).
Returns Execution if write_ts is the unsupported sentinel.
pub fn pending_commit_ts(&self) -> u64
pub fn take_redo(&self) -> Vec<RedoOp>
Sourcepub fn commit_write(&self)
pub fn commit_write(&self)
Publish after WAL fsync.
pub fn abort_write(&self)
pub fn reset_stats(&self)
pub fn node_at(&self, id: NodeId, ts: u64) -> Option<Node>
Sourcepub fn node_labels_at(&self, id: NodeId, ts: u64) -> Option<Vec<String>>
pub fn node_labels_at(&self, id: NodeId, ts: u64) -> Option<Vec<String>>
Label-only view of a node — no property-map materialization (ADR-0033).
Callers that only need labels avoid node_at, which builds the full
property map per node (the profile-hot CompactProps::to_map path).
pub fn rel_at(&self, id: RelId, ts: u64) -> Option<Relationship>
Sourcepub fn rel_ends_at(&self, id: RelId, ts: u64) -> Option<(NodeId, NodeId)>
pub fn rel_ends_at(&self, id: RelId, ts: u64) -> Option<(NodeId, NodeId)>
Endpoints only — expand / BFS must not materialize property maps (ADR-0033).