Skip to main content

Graph

Struct Graph 

Source
pub struct Graph { /* private fields */ }

Implementations§

Source§

impl Graph

Source

pub fn used_bytes(&self) -> u64

Live graph + index logical bytes (ADR-0042, ADR-0202).

Source

pub fn accounted_bytes(&self) -> u64

Full walk of retained versions, adjacency, and the interner (test / rebuild_indexes oracle).

Source

pub fn recompute_used(&self)

Source

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.

Source

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

Source

pub fn degree_out(&self, id: NodeId) -> Vec<RelId>

Source

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).

Source

pub fn degree_in(&self, id: NodeId) -> Vec<RelId>

Source

pub fn neighbors(&self, id: NodeId, dir: Direction) -> Vec<RelId>

Source

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.

Source

pub fn neighbors_at(&self, id: NodeId, dir: Direction, ts: u64) -> Vec<RelId>

Source§

impl Graph

Source

pub fn apply_redo(&self, ops: Vec<RedoOp>, commit_ts: u64) -> Result<()>

Source§

impl Graph

Source

pub fn write_set_conflicts(&self, snapshot_ts: u64, ops: &[RedoOp]) -> bool

True when ops cannot commit on top of snapshot_ts (ADR-0015).

Source

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

Source

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

Source

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.

Source

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

Source

pub fn create_node( &self, labels: Vec<String>, properties: BTreeMap<String, Value>, ) -> Result<NodeId>

Source

pub fn create_rel( &self, start: NodeId, end: NodeId, rel_type: String, properties: BTreeMap<String, Value>, ) -> Result<RelId>

Source

pub fn set_property_node(&self, id: NodeId, key: &str, value: Value)

Source

pub fn set_property_rel(&self, id: RelId, key: &str, value: Value)

Source

pub fn merge_properties_node(&self, id: NodeId, map: &BTreeMap<String, Value>)

Source

pub fn delete_rel(&self, id: RelId)

Source

pub fn delete_node(&self, id: NodeId, detach: bool) -> Result<()>

Source§

impl Graph

Source

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).

Source

pub fn gc_versions(&self)

Source§

impl Graph

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

pub fn label_count_by_id(&self, lid: u32) -> u64

Graph::label_count for an already-resolved label token id.

Source

pub fn lookup_nodes( &self, labels: &[String], props: &BTreeMap<String, Value>, ) -> Option<Vec<NodeId>>

Source

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.

Source

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.

Source

pub fn lookup_string_contains_at( &self, labels: &[String], key: &str, needle: &str, ts: u64, ) -> Option<Vec<NodeId>>

Source

pub fn lookup_string_prefix_at( &self, labels: &[String], key: &str, prefix: &str, ts: u64, ) -> Option<Vec<NodeId>>

None unless a RANGE index names the (label, property). STARTS WITH reads that ordered map; without one the caller scans.

Source§

impl Graph

Source

pub fn add_labels(&self, id: NodeId, labels: &[String])

Source

pub fn remove_labels(&self, id: NodeId, labels: &[String])

Source§

impl Graph

Source

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).

Source

pub fn unpin_slot(&self, slot: usize)

Source

pub fn snapshot_pinned(&self) -> bool

True while any statement or explicit transaction holds a snapshot pin.

Source

pub fn gc_horizon(&self) -> u64

Lowest timestamp that may still be read. Dead iff xmax != 0 && xmax <= horizon.

Source§

impl Graph

Source

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.

Source

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

Source

pub fn dirty_node_ids(&self) -> HashSet<NodeId>

Node ids changed since the last clear_checkpoint_dirty (ADR-0022).

Source

pub fn dirty_rel_ids(&self) -> HashSet<RelId>

Relationship ids changed since the last clear_checkpoint_dirty.

Source

pub fn clear_checkpoint_dirty(&self)

Source

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.

Source

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.

Source

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.

Source

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

Source

pub fn named_indexes(&self) -> Vec<IndexDef>

Source

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.

Source

pub fn named_constraints(&self) -> Vec<ConstraintDef>

Source

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.

Source

pub fn named_index(&self, name: &str) -> Option<IndexDef>

Source

pub fn has_constraint(&self, name: &str) -> bool

By-name constraint probe, the constraint side of Self::named_index.

Source

pub fn named_index_by_schema( &self, label: &str, property: &str, ) -> Option<IndexDef>

Source

pub fn install_named_index(&self, def: IndexDef) -> Result<()>

Source§

impl Graph

Source

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

Source

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

pub fn restore_graph_type_spec(&self, spec: Option<&str>) -> Result<()>

Restore a Relate GraphData graph_type spec after snapshot load.

Source§

impl Graph

Source

pub fn namespace(&self) -> Namespace

Which fixed namespace of the store this graph is (ADR-0116 §1).

Source

pub fn commit_ts(&self) -> u64

Source

pub fn set_commit_ts(&self, ts: u64)

Source

pub fn next_node_id(&self) -> NodeId

Source

pub fn set_next_node_id(&self, id: NodeId)

Source

pub fn next_rel_id(&self) -> RelId

Source

pub fn set_next_rel_id(&self, id: RelId)

Source

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.

Source

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.

Source

pub fn pending_commit_ts(&self) -> u64

Source

pub fn take_redo(&self) -> Vec<RedoOp>

Source

pub fn commit_write(&self)

Publish after WAL fsync.

Source

pub fn abort_write(&self)

Source

pub fn reset_stats(&self)

Source

pub fn node_at(&self, id: NodeId, ts: u64) -> Option<Node>

Source

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).

Source

pub fn rel_at(&self, id: RelId, ts: u64) -> Option<Relationship>

Source

pub fn rel_ends_at(&self, id: RelId, ts: u64) -> Option<(NodeId, NodeId)>

Endpoints only — expand / BFS must not materialize property maps (ADR-0033).

Source

pub fn node_stub_at(&self, id: NodeId, ts: u64) -> Option<Node>

Source

pub fn rel_stub_at(&self, id: RelId, ts: u64) -> Option<Relationship>

Source

pub fn node_prop_at(&self, id: NodeId, ts: u64, key: &str) -> Option<Value>

Source

pub fn rel_prop_at(&self, id: RelId, ts: u64, key: &str) -> Option<Value>

Source

pub fn node_prop_keys_at(&self, id: NodeId, ts: u64) -> Vec<String>

Source

pub fn rel_prop_keys_at(&self, id: RelId, ts: u64) -> Vec<String>

Source

pub fn node(&self, id: NodeId) -> Option<Node>

Source

pub fn rel(&self, id: RelId) -> Option<Relationship>

Source

pub fn node_exists(&self, id: NodeId) -> bool

Source

pub fn rel_exists(&self, id: RelId) -> bool

Source

pub fn live_node_count(&self) -> usize

Source

pub fn node_value(&self, id: NodeId) -> Value

Source

pub fn rel_value(&self, id: RelId) -> Value

Source

pub fn pull_identity_get( &self, source: &str, kind: PullKind, remote_id: &str, ) -> Option<i64>

Source

pub fn pull_identity_put( &self, source: String, kind: PullKind, remote_id: String, local_id: i64, )

Source

pub fn drop_pull_identity(&self, kind: PullKind, local_id: i64)

Source§

impl Graph

Source

pub fn all_rel_ids(&self) -> Vec<RelId>

Source

pub fn all_rel_ids_at(&self, ts: u64) -> Vec<RelId>

Source

pub fn all_node_ids(&self) -> Vec<NodeId>

Source

pub fn all_node_ids_at(&self, ts: u64) -> Vec<NodeId>

Trait Implementations§

Source§

impl Debug for Graph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Graph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl GraphExport for Graph

Source§

fn commit_ts(&self) -> u64

Source§

fn next_node_id(&self) -> i64

Source§

fn next_rel_id(&self) -> i64

Source§

fn live_node_count(&self) -> usize

Source§

fn dirty_node_ids(&self) -> HashSet<NodeId>

Source§

fn dirty_rel_ids(&self) -> HashSet<RelId>

Source§

fn all_node_ids_at(&self, ts: u64) -> Vec<NodeId>

Source§

fn all_rel_ids_at(&self, ts: u64) -> Vec<RelId>

Source§

fn node_at(&self, id: NodeId, ts: u64) -> Option<Node>

Source§

fn rel_at(&self, id: RelId, ts: u64) -> Option<Relationship>

Source§

fn node_checkpoint_bytes(&self, id: NodeId, ts: u64) -> Result<Option<u64>>

Source§

fn rel_checkpoint_bytes(&self, id: RelId, ts: u64) -> Result<Option<u64>>

Source§

fn named_indexes(&self) -> Vec<IndexDef>

Source§

fn named_constraints(&self) -> Vec<ConstraintDef>

Source§

fn checkpoint_theater_for_write(&self) -> Result<CheckpointTheater>

Source§

fn graph_type_spec(&self) -> Result<Option<String>>

Source§

fn clear_checkpoint_dirty(&self)

Source§

fn catalog_ddl(&self) -> Vec<String>

SHOW-style catalog DDL the schema mirror writes beside a checkpoint.
Source§

impl GraphImport for Graph

Source§

impl TokenResolver for Graph

The store’s token resolver (ADR-0541): the facade hands the graph to the planner beside its statistics, so plan-time resolution reads the same interner execution does.

Source§

fn resolve(&self, name: &str) -> Token

Auto Trait Implementations§

§

impl !Freeze for Graph

§

impl !RefUnwindSafe for Graph

§

impl !UnwindSafe for Graph

§

impl Forget for Graph

§

impl Move for Graph

§

impl Send for Graph

§

impl Sync for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin for Graph

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SnapshotGraph for T
where T: GraphImport + Default,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V