pub struct ExecGraph<'a> { /* private fields */ }Expand description
Read view of committed graph plus optional overlay (ADR-0016).
Implementations§
Source§impl ExecGraph<'_>
impl ExecGraph<'_>
pub fn neighbors(&self, id: NodeId, dir: Direction) -> Vec<RelId>
Sourcepub fn for_each_neighbor(
&self,
id: NodeId,
dir: Direction,
types: &[String],
f: impl FnMut(RelId),
)
pub fn for_each_neighbor( &self, id: NodeId, dir: Direction, types: &[String], f: impl FnMut(RelId), )
Overlay-visible neighbors without cloning the base adjacency Vec.
The name-keyed boundary spelling: the pattern’s types resolve once
here, then Self::for_each_neighbor_resolved compares ids.
Sourcepub fn adj_len(&self, id: NodeId, dir: Direction) -> usize
pub fn adj_len(&self, id: NodeId, dir: Direction) -> usize
Approximate adjacency degree (see [Graph::adj_len]) — side
selection for existence probes (LABS-193). Base delegation only:
deliberately not snapshot-filtered (reads.rs’s prologue contract).
Sourcepub fn try_find_neighbor<E>(
&self,
id: NodeId,
dir: Direction,
types: &[String],
f: impl FnMut(RelId) -> Result<bool, E>,
) -> Result<Option<RelId>, E>
pub fn try_find_neighbor<E>( &self, id: NodeId, dir: Direction, types: &[String], f: impl FnMut(RelId) -> Result<bool, E>, ) -> Result<Option<RelId>, E>
The first neighbor of id (in dir, of types) for which f
returns true, stopping the walk there — the early-exit idiom for
existence probes (LABS-193). No match: Ok(None). The name-keyed
boundary spelling: resolves once, then delegates to
Self::try_find_neighbor_resolved.
Source§impl ExecGraph<'_>
The catalog facts of a view (ADR-0363 decision 5): the committed catalog
or interner plus the names the view’s write overlay named. The overlay’s
redo log is its write record — no second name set — read through
RedoOp::catalog_names, so a label, type or key a transaction just
wrote is known before the commit publishes it.
impl ExecGraph<'_>
The catalog facts of a view (ADR-0363 decision 5): the committed catalog
or interner plus the names the view’s write overlay named. The overlay’s
redo log is its write record — no second name set — read through
RedoOp::catalog_names, so a label, type or key a transaction just
wrote is known before the commit publishes it.
Sourcepub fn has_label(&self, label: &str) -> bool
pub fn has_label(&self, label: &str) -> bool
Whether this view’s catalog knows label: the committed catalog or a
label any scratch write named. The committed contract is monotone (a
label outlives its last node); the scratch side keeps it: a create or
label change counts even if a later write removed it.
Sourcepub fn has_rel_type(&self, rel_type: &str) -> bool
pub fn has_rel_type(&self, rel_type: &str) -> bool
Whether this view’s catalog knows relationship type rel_type; the
label contract applies unchanged.
Sourcepub fn has_property_key(&self, key: &str) -> bool
pub fn has_property_key(&self, key: &str) -> bool
Whether this view’s interner knows property key key: the committed
interner or a property key any scratch write named. A hit still only
suppresses a warning; a miss is a true miss.
Source§impl<'a> ExecGraph<'a>
impl<'a> ExecGraph<'a>
Sourcepub fn index_facts(&self) -> Result<Vec<IndexFacts>>
pub fn index_facts(&self) -> Result<Vec<IndexFacts>>
The typed facts of every named index, resolved through the one
IndexFacts precedence (detail, then backing constraint, then
the legacy encoding) in the catalog’s name order — the snapshot a
statement-scoped index reader (the 03N95 dynamic-property
detector) reads instead of re-spelling the chain over raw
IndexDef rows.
pub fn named_indexes(&self) -> Vec<IndexDef>
pub fn named_index(&self, name: &str) -> Option<IndexDef>
Sourcepub fn named_constraint(&self, name: &str) -> Option<ConstraintDef>
pub fn named_constraint(&self, name: &str) -> Option<ConstraintDef>
The named constraint of that name — the ExecGraph::named_index
twin, so a by-name existence probe reads one accessor instead of
materializing the whole list and scanning it at each site.
pub fn named_index_by_schema( &self, label: &str, property: &str, ) -> Option<IndexDef>
pub fn named_constraints(&self) -> Vec<ConstraintDef>
Sourcepub fn create_named_index(
&self,
name: String,
label: String,
property: String,
) -> Result<()>
pub fn create_named_index( &self, name: String, label: String, property: String, ) -> Result<()>
Index DDL: create a standalone index, counted in
QueryStats::indexes_added (ADR-0309).
Sourcepub fn drop_named_index(&self, name: String) -> Result<()>
pub fn drop_named_index(&self, name: String) -> Result<()>
Index DDL: drop a standalone index, counted in
QueryStats::indexes_removed (ADR-0309).
pub fn create_named_constraint(&self, def: ConstraintDef) -> Result<()>
pub fn drop_named_constraint(&self, name: String) -> Result<()>
Source§impl ExecGraph<'_>
impl ExecGraph<'_>
pub fn node(&self, id: NodeId) -> Option<Node>
Sourcepub fn node_exists(&self, id: NodeId) -> bool
pub fn node_exists(&self, id: NodeId) -> bool
Existence check without materializing the node. The profiled hot path
(node clones the full Node — labels + property map) makes this the
common-case read in a write statement; callers that only need to know
a node is present must not pay for its properties.
Sourcepub fn node_labels(&self, id: NodeId) -> Option<Vec<String>>
pub fn node_labels(&self, id: NodeId) -> Option<Vec<String>>
Label ids without materializing properties. Returns owned label strings; callers that only compare labels pay no property map clone.
pub fn rel(&self, id: RelId) -> Option<Relationship>
pub fn rel_ends(&self, id: RelId) -> Option<(NodeId, NodeId)>
pub fn hop(&self, current: NodeId, rid: RelId, dir: Direction) -> Option<NodeId>
Sourcepub fn label_count(&self, label: &str) -> u64
pub fn label_count(&self, label: &str) -> u64
Plan-time label cardinality estimate (ADR-0218), forwarded for the exec layer’s pattern-start estimates (ADR-0351).
Sourcepub fn rel_exists(&self, id: RelId) -> bool
pub fn rel_exists(&self, id: RelId) -> bool
Existence check without materializing the relationship.
The type name shared (Arc<str> — one refcount bump off the
store’s interned name; the batch record’s copy is the only
allocation, and only when the rel is scratch). The selector’s
per-walk type reads ride this, never the String clone.
Sourcepub fn rel_type(&self, id: RelId) -> Option<String>
pub fn rel_type(&self, id: RelId) -> Option<String>
Type name without materializing the relationship’s property map.
pub fn node_stub(&self, id: NodeId) -> Option<Node>
pub fn rel_stub(&self, id: RelId) -> Option<Relationship>
pub fn node_prop(&self, id: NodeId, key: &str) -> Option<Value>
pub fn rel_prop(&self, id: RelId, key: &str) -> Option<Value>
pub fn node_prop_keys(&self, id: NodeId) -> Vec<String>
pub fn rel_prop_keys(&self, id: RelId) -> Vec<String>
Source§impl<'a> ExecGraph<'a>
impl<'a> ExecGraph<'a>
Sourcepub fn lookup_nodes(
&self,
labels: &[String],
props: &BTreeMap<String, Value>,
) -> Option<Vec<NodeId>>
pub fn lookup_nodes( &self, labels: &[String], props: &BTreeMap<String, Value>, ) -> Option<Vec<NodeId>>
The label/property candidate lookup at the snapshot, ascending
and deduplicated: None only when both labels and props are
empty — the shape the caller scans for instead — a non-empty
seek is always served.
Sourcepub fn lookup_nodes_upto(
&self,
labels: &[String],
props: &BTreeMap<String, Value>,
cap: Option<usize>,
) -> Option<Vec<NodeId>>
pub fn lookup_nodes_upto( &self, labels: &[String], props: &BTreeMap<String, Value>, cap: Option<usize>, ) -> Option<Vec<NodeId>>
ExecGraph::lookup_nodes for a caller that only needs to know
whether more than cap nodes match (Graph::lookup_nodes_upto_at
carries the contract: at most cap ids is the complete answer, a
longer one only its length). A view with write scratch answers in
full: a truncated base subset could lose members to the scratch’s
deletions and read as complete.
Sourcepub fn lookup_string_contains(
&self,
labels: &[String],
key: &str,
needle: &str,
) -> Option<Vec<NodeId>>
pub fn lookup_string_contains( &self, labels: &[String], key: &str, needle: &str, ) -> Option<Vec<NodeId>>
None when the base index cannot serve the needle (the gram index
rejects empty needles): the caller falls back to a full scan, exactly
like the lookup_nodes path, rather than matching nothing.
Source§impl ExecGraph<'_>
impl ExecGraph<'_>
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 add_labels(&self, id: NodeId, labels: &[String])
pub fn remove_labels(&self, id: NodeId, labels: &[String])
Sourcepub fn set_labels(&self, id: NodeId, labels: &[String])
pub fn set_labels(&self, id: NodeId, labels: &[String])
CIP-162 overwrite semantics, spelled once beside the primitives it
composes: the node’s labels become exactly labels — the ones it
carries but the list omits leave ([remove_labels]), then the
list’s labels arrive ([add_labels]). Each half keeps its own
accounting and redo, so the overwrite is their compose, not a third
label-write path.
pub fn set_property_node(&self, id: NodeId, key: &str, value: Value)
pub fn set_property_rel(&self, id: RelId, key: &str, value: Value)
Sourcepub fn merge_properties_node(&self, id: NodeId, map: &BTreeMap<String, Value>)
pub fn merge_properties_node(&self, id: NodeId, map: &BTreeMap<String, Value>)
SET n += map: per-key merge through the set verb (an existing
key keeps its position, a new one is added) — the node and
relationship forms are the same loop over their set verbs.
Sourcepub fn merge_properties_rel(&self, id: RelId, map: &BTreeMap<String, Value>)
pub fn merge_properties_rel(&self, id: RelId, map: &BTreeMap<String, Value>)
The relationship form of Self::merge_properties_node.
pub fn replace_properties_node(&self, id: NodeId, map: BTreeMap<String, Value>)
pub fn replace_properties_rel(&self, id: RelId, map: BTreeMap<String, Value>)
pub fn delete_rel(&self, id: RelId)
pub fn delete_node(&self, id: NodeId, detach: bool) -> Result<()>
Source§impl<'a> ExecGraph<'a>
impl<'a> ExecGraph<'a>
Sourcepub fn read(base: &'a Graph) -> Self
pub fn read(base: &'a Graph) -> Self
Schema-less read view of the committed graph. show_schema falls back
to the live committed theater (under its lock); use
Self::with_schema when a pinned admission snapshot is
required. This is the constructor for tests and callers that never
consult committed SHOW metadata.
Sourcepub fn read_at(base: &'a Graph, snapshot_ts: u64) -> Self
pub fn read_at(base: &'a Graph, snapshot_ts: u64) -> Self
read at an explicit snapshot timestamp; same schema-less invariant.
Sourcepub fn with_schema(self, schema: &'a SchemaSnapshot) -> Self
pub fn with_schema(self, schema: &'a SchemaSnapshot) -> Self
Pin a schema snapshot on a view (combinator mirroring
Self::with_cancel): ExecGraph::read_at(base, ts).with_schema(schema).
Sourcepub fn write(base: &'a Graph, scratch: &'a RefCell<WriteScratch>) -> Self
pub fn write(base: &'a Graph, scratch: &'a RefCell<WriteScratch>) -> Self
Schema-less write view of the committed graph plus overlay.
show_schema/validate_constraints fall back to the live committed
theater, reached in two regimes: the autocommit path reaches it
while holding the publication read guard, and ADR-0210 batched
statements (CALL { … } IN TRANSACTIONS) reach it unguarded —
pinned on the graph version but racing a concurrent schema change.
A caller that needs a pinned admission adds it with
Self::with_schema.
Sourcepub fn with_cancel(self, cancel: Option<&'a CancelToken>) -> Self
pub fn with_cancel(self, cancel: Option<&'a CancelToken>) -> Self
Attach a cooperative cancellation flag to this view (ADR-0111). Construction sites that do not thread a token leave the view uncancellable, which preserves the existing behavior.
Sourcepub fn with_ontology_document(self, document: Option<&'a str>) -> Self
pub fn with_ontology_document(self, document: Option<&'a str>) -> Self
Attach the ontology document the calling transaction sees
(ADR-0121 §3, ADR-0227): the facade’s admission-time capture for
auto-commit statements, the begin-time capture for explicit
transactions. Per-admission state on the view, like
Self::with_cancel (ADR-0111); the db.ontology.get /
db.ontology.apply procedure arms read it through
Self::ontology_document. A view without one behaves as if the
store holds no ontology, which preserves test/diagnostic behavior.
pub fn stats(&self) -> QueryStats
pub fn procedure(&self, name: &str) -> Option<Procedure>
Sourcepub fn node_value(&self, id: NodeId) -> Value
pub fn node_value(&self, id: NodeId) -> Value
Materialize a node as a Value for result rows and entity builtins
(startNode()/endNode()). Falls back to the virtual-node side
table (virtual_nodes, CIP-257) when the store/overlay lookup
misses, so endpoints of synthesized visualization relationships
resolve without a store backing. This is the one graph-level lookup
shared by the entity builtins and the visualization rows. Unlike
Self::node, which write paths use and which must keep missing on
virtual ids (CIP-257 “Write behavior on virtual entities”), this
read-path materialization is the only place the fallback is
consulted.
pub fn rel_value(&self, id: RelId) -> Value
pub fn is_deleted_node(&self, id: NodeId) -> bool
pub fn is_deleted_rel(&self, id: RelId) -> bool
Sourcepub fn all_node_ids(&self) -> Vec<NodeId>
pub fn all_node_ids(&self) -> Vec<NodeId>
Every live node id, ascending: the snapshot’s ids minus the scratch’s
deletions plus its creations (ADR-0173). A copy-on-write entry was
read from the snapshot, so it is a snapshot id already, and a delete
drops the id from created_nodes. The two sets meet only if an
allocator handed out a committed id; dedup keeps that to one entry.
Sourcepub fn all_rel_ids(&self) -> Vec<RelId>
pub fn all_rel_ids(&self) -> Vec<RelId>
Every live relationship id, ascending; built like
Self::all_node_ids from deleted_rels and created_rels.