Skip to main content

InMemoryGraph

Struct InMemoryGraph 

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

Implementations§

Source§

impl InMemoryGraph

Source

pub fn new() -> Self

Source

pub fn with_capacity_hint(nodes: usize, relationships: usize) -> Self

Source

pub fn contains_node(&self, node_id: NodeId) -> bool

Source

pub fn contains_relationship(&self, rel_id: RelationshipId) -> bool

Source

pub fn set_mutation_recorder( &mut self, recorder: Option<Arc<dyn MutationRecorder>>, )

Install (or clear) the mutation recorder. Passing None detaches any currently-installed recorder. The recorder observes every committed mutation after it has been applied.

Source

pub fn mutation_recorder(&self) -> Option<&Arc<dyn MutationRecorder>>

Handle to the currently-installed recorder, if any.

Source

pub fn graph_stats(&self) -> GraphStats

Snapshot of cardinality stats. Cheap: derived from already-tracked nodes_by_label / relationships_by_type lengths and the active property-index buckets. The cost model uses this to populate estimated_rows on plan-tree nodes.

Source§

impl InMemoryGraph

Source

pub fn snapshot_payload(&self) -> SnapshotPayload

Return the portable graph-state payload. Callers downstream of lora-store (typically lora-database) feed this into lora-snapshot for byte-level encoding.

Source

pub fn load_snapshot_payload( &mut self, payload: SnapshotPayload, ) -> Result<SnapshotMeta, SnapshotError>

Replace the graph from a portable graph-state payload, preserving the currently installed mutation recorder across the swap.

Trait Implementations§

Source§

impl BorrowedGraphStorage for InMemoryGraph

Source§

fn node_ref(&self, id: NodeId) -> Option<&NodeRecord>

Source§

fn relationship_ref(&self, id: RelationshipId) -> Option<&RelationshipRecord>

Source§

fn node_refs(&self) -> Box<dyn Iterator<Item = &NodeRecord> + '_>

Source§

fn node_refs_by_label( &self, label: &str, ) -> Box<dyn Iterator<Item = &NodeRecord> + '_>

Source§

fn relationship_refs( &self, ) -> Box<dyn Iterator<Item = &RelationshipRecord> + '_>

Source§

fn relationship_refs_by_type( &self, rel_type: &str, ) -> Box<dyn Iterator<Item = &RelationshipRecord> + '_>

Source§

impl Clone for InMemoryGraph

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InMemoryGraph

Source§

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

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

impl Default for InMemoryGraph

Source§

fn default() -> InMemoryGraph

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

impl GraphStorage for InMemoryGraph

Source§

fn list_indexes(&self) -> Vec<IndexDefinition>

Source§

fn get_index(&self, name: &str) -> Option<IndexDefinition>

Run a FULLTEXT index query against the named index. Returns (entity_id, score) pairs sorted descending by score. Backends without fulltext support return an empty vector; the caller is expected to have validated that the index exists via the catalog first.
Run a VECTOR index query against the named index. Returns unsorted (entity_id, score) pairs; the caller sorts by score descending and truncates to top-k. Backends without vector support return an empty vector. The caller has already validated that the index exists via the catalog and that the query vector matches the configured dimensions. Read more
Source§

fn list_constraints(&self) -> Vec<ConstraintDefinition>

List explicitly-declared constraints. Backends without a constraint catalog return the empty vector.
Source§

fn get_constraint(&self, name: &str) -> Option<ConstraintDefinition>

Source§

fn check_node_create_against_constraints( &self, labels: &[String], properties: &Properties, ) -> Result<(), String>

Mutation-time pre-check: would creating a node with these labels and properties violate any registered constraint? Default returns Ok(()) so backends without a constraint catalog pay nothing. The in-memory backend overrides this and the call is virtually free when the catalog is empty.
Source§

fn check_relationship_create_against_constraints( &self, rel_type: &str, properties: &Properties, ) -> Result<(), String>

Mutation-time pre-check for CREATE ()-[r:TYPE { ... }]->().
Source§

fn check_node_set_property_against_constraints( &self, node_id: NodeId, key: &str, value: &PropertyValue, ) -> Result<(), String>

Mutation-time pre-check: would setting key = value on this node violate any registered constraint? Default Ok(()).
Source§

fn check_node_remove_property_against_constraints( &self, node_id: NodeId, key: &str, ) -> Result<(), String>

Mutation-time pre-check: would removing key on this node violate an existence / key constraint? Default Ok(()).
Source§

fn check_node_replace_properties_against_constraints( &self, node_id: NodeId, properties: &Properties, ) -> Result<(), String>

Mutation-time pre-check: would replacing all properties on this node leave it in violation of any registered constraint? Default Ok(()).
Source§

fn check_relationship_set_property_against_constraints( &self, rel_id: RelationshipId, key: &str, value: &PropertyValue, ) -> Result<(), String>

Mutation-time pre-check: equivalent for relationship property writes.
Source§

fn check_relationship_remove_property_against_constraints( &self, rel_id: RelationshipId, key: &str, ) -> Result<(), String>

Source§

fn check_relationship_replace_properties_against_constraints( &self, rel_id: RelationshipId, properties: &Properties, ) -> Result<(), String>

Mutation-time pre-check: would replacing all properties on this relationship leave it in violation of any registered constraint? Default Ok(()).
Source§

fn check_node_add_label_against_constraints( &self, node_id: NodeId, label: &str, ) -> Result<(), String>

Mutation-time pre-check: would adding label to this node activate a constraint the node currently violates?
Source§

fn graph_stats(&self) -> GraphStats

Cardinality snapshot used by the cost model. Backends without per-label / per-type indexes return GraphStats::default(), which the planner treats as “no information available”.
Source§

fn node_text_candidates( &self, label: &str, property: &str, query: &str, ) -> Option<Vec<NodeId>>

Trigram-index candidates for query on label.property. Read more
Source§

fn node_range_candidates( &self, label: &str, property: &str, lo: Option<&PropertyValue>, hi: Option<&PropertyValue>, ) -> Option<Vec<NodeId>>

Sorted-index candidates for a [lo, hi] range on label.property. Both bounds are inclusive at this layer; the caller refilters with the precise predicate inclusivity (> vs >=, < vs <=). Read more
Source§

fn node_point_within_bbox( &self, label: &str, property: &str, ll: (f64, f64), ur: (f64, f64), ) -> Option<Vec<NodeId>>

Spatial-index candidates inside the closed [ll, ur] 2D bounding box. The executor refilters every id with the precise predicate, including the z-coordinate when the indexed point is 3D.
Source§

fn node_point_within_distance( &self, label: &str, property: &str, center: (f64, f64), max_distance: f64, ) -> Option<Vec<NodeId>>

Spatial-index candidates within max_distance of (x, y). The candidate set is conservative — the actual great-circle / cartesian distance check is the executor’s responsibility.
Source§

fn relationship_text_candidates( &self, rel_type: &str, property: &str, query: &str, ) -> Option<Vec<RelationshipId>>

Trigram-index candidates for relationships of rel_type whose property value matches query (substring/prefix/suffix). Mirror of Self::node_text_candidates for relationship-target indexes.
Source§

fn relationship_range_candidates( &self, rel_type: &str, property: &str, lo: Option<&PropertyValue>, hi: Option<&PropertyValue>, ) -> Option<Vec<RelationshipId>>

Sorted-index candidates for relationships of rel_type on the closed [lo, hi] range. Mirror of Self::node_range_candidates.
Source§

fn relationship_point_within_bbox( &self, rel_type: &str, property: &str, ll: (f64, f64), ur: (f64, f64), ) -> Option<Vec<RelationshipId>>

Spatial-index candidates inside the closed [ll, ur] 2D bounding box, scoped to relationships of rel_type. Mirror of Self::node_point_within_bbox.
Source§

fn relationship_point_within_distance( &self, rel_type: &str, property: &str, center: (f64, f64), max_distance: f64, ) -> Option<Vec<RelationshipId>>

Spatial-index candidates within max_distance of (x, y), scoped to relationships of rel_type. Mirror of Self::node_point_within_distance.
Source§

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

Cheap existence check. Should not clone or materialize the record.
Source§

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

Point lookup returning an owned record. Backends that can hand out borrows should also implement BorrowedGraphStorage::node_ref and override [with_node] to avoid clones on the hot path.
Source§

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

Enumerate every node id. Should be O(nodes) without cloning records.
Source§

fn node_ids_by_label(&self, label: &str) -> Vec<NodeId>

Enumerate node ids carrying the given label. Implementations that keep a label index should override this.
Source§

fn contains_relationship(&self, id: RelationshipId) -> bool

Source§

fn relationship(&self, id: RelationshipId) -> Option<RelationshipRecord>

Source§

fn all_rel_ids(&self) -> Vec<RelationshipId>

Source§

fn rel_ids_by_type(&self, rel_type: &str) -> Vec<RelationshipId>

Source§

fn relationship_endpoints(&self, id: RelationshipId) -> Option<(NodeId, NodeId)>

Endpoint pair (src, dst) for a relationship. Required because traversal uses it on hot paths; a backend that stores endpoints alongside the id index can answer this without fetching properties.
Source§

fn expand_ids( &self, node_id: NodeId, direction: Direction, types: &[String], ) -> Vec<(RelationshipId, NodeId)>

Expand a node’s incident relationships filtered by direction and (optional) types. This is the single traversal primitive; variable- length paths, degree, and adjacency helpers are all derived from it.
Source§

fn try_for_each_expand_id<F, E>( &self, node_id: NodeId, direction: Direction, types: &[String], visit: F, ) -> Result<(), E>
where F: FnMut(RelationshipId, NodeId) -> Result<(), E>, Self: Sized,

Visit expanded (relationship_id, other_node_id) pairs without forcing backends to allocate an intermediate Vec. The default keeps the trait easy to implement; hot backends can override it.
Source§

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

Source§

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

Source§

fn with_node<F, R>(&self, id: NodeId, f: F) -> Option<R>
where F: FnOnce(&NodeRecord) -> R, Self: Sized,

Source§

fn with_relationship<F, R>(&self, id: RelationshipId, f: F) -> Option<R>
where F: FnOnce(&RelationshipRecord) -> R, Self: Sized,

Source§

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

Source§

fn has_relationship(&self, id: RelationshipId) -> bool

Source§

fn node_count(&self) -> usize

Source§

fn relationship_count(&self) -> usize

Source§

fn all_nodes(&self) -> Vec<NodeRecord>

Source§

fn nodes_by_label(&self, label: &str) -> Vec<NodeRecord>

Source§

fn all_relationships(&self) -> Vec<RelationshipRecord>

Source§

fn relationships_by_type(&self, rel_type: &str) -> Vec<RelationshipRecord>

Source§

fn relationship_ids_of( &self, node_id: NodeId, direction: Direction, ) -> Vec<RelationshipId>

Source§

fn outgoing_relationships(&self, node_id: NodeId) -> Vec<RelationshipRecord>

Source§

fn incoming_relationships(&self, node_id: NodeId) -> Vec<RelationshipRecord>

Source§

fn relationships_of( &self, node_id: NodeId, direction: Direction, ) -> Vec<RelationshipRecord>

Source§

fn degree(&self, node_id: NodeId, direction: Direction) -> usize

Source§

fn expand( &self, node_id: NodeId, direction: Direction, types: &[String], ) -> Vec<(RelationshipRecord, NodeRecord)>

Source§

fn neighbors( &self, node_id: NodeId, direction: Direction, types: &[String], ) -> Vec<NodeRecord>

Source§

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

Source§

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

Source§

fn label_property_keys(&self, label: &str) -> Vec<String>

Source§

fn rel_type_property_keys(&self, rel_type: &str) -> Vec<String>

Source§

fn find_nodes_by_property( &self, label: Option<&str>, key: &str, value: &PropertyValue, ) -> Vec<NodeRecord>
where Self: Sized,

Source§

fn find_node_ids_by_property( &self, label: Option<&str>, key: &str, value: &PropertyValue, ) -> Vec<NodeId>
where Self: Sized,

Source§

fn find_relationships_by_property( &self, rel_type: Option<&str>, key: &str, value: &PropertyValue, ) -> Vec<RelationshipRecord>
where Self: Sized,

Source§

fn find_relationship_ids_by_property( &self, rel_type: Option<&str>, key: &str, value: &PropertyValue, ) -> Vec<RelationshipId>
where Self: Sized,

Source§

fn node_exists_with_label_and_property( &self, label: &str, key: &str, value: &PropertyValue, ) -> bool
where Self: Sized,

Source§

fn relationship_exists_with_type_and_property( &self, rel_type: &str, key: &str, value: &PropertyValue, ) -> bool
where Self: Sized,

Source§

fn is_isolated(&self, node_id: NodeId) -> bool

Source§

fn expand_detailed( &self, node_id: NodeId, direction: Direction, types: &[String], ) -> Vec<ExpandedRelationship>

Source§

fn node_has_label(&self, node_id: NodeId, label: &str) -> bool
where Self: Sized,

Source§

fn node_labels(&self, node_id: NodeId) -> Option<Vec<String>>
where Self: Sized,

Source§

fn node_properties(&self, node_id: NodeId) -> Option<Properties>
where Self: Sized,

Source§

fn node_property(&self, node_id: NodeId, key: &str) -> Option<PropertyValue>
where Self: Sized,

Source§

fn relationship_type(&self, rel_id: RelationshipId) -> Option<String>
where Self: Sized,

Source§

fn relationship_properties(&self, rel_id: RelationshipId) -> Option<Properties>
where Self: Sized,

Source§

fn relationship_property( &self, rel_id: RelationshipId, key: &str, ) -> Option<PropertyValue>
where Self: Sized,

Source§

fn relationship_source(&self, rel_id: RelationshipId) -> Option<NodeId>

Source§

fn relationship_target(&self, rel_id: RelationshipId) -> Option<NodeId>

Source§

fn other_node(&self, rel_id: RelationshipId, node_id: NodeId) -> Option<NodeId>

Source§

fn has_label_name(&self, label: &str) -> bool

Source§

fn has_relationship_type_name(&self, rel_type: &str) -> bool

Source§

fn all_property_keys(&self) -> Vec<String>
where Self: Sized,

Source§

fn has_property_key(&self, key: &str) -> bool
where Self: Sized,

Source§

fn label_has_property_key(&self, label: &str, key: &str) -> bool
where Self: Sized,

Source§

fn rel_type_has_property_key(&self, rel_type: &str, key: &str) -> bool
where Self: Sized,

Source§

impl GraphStorageMut for InMemoryGraph

Source§

fn create_node( &mut self, labels: Vec<String>, properties: Properties, ) -> NodeRecord

Source§

fn create_relationship( &mut self, src: NodeId, dst: NodeId, rel_type: &str, properties: Properties, ) -> Option<RelationshipRecord>

Source§

fn set_node_property( &mut self, node_id: NodeId, key: String, value: PropertyValue, ) -> bool

Source§

fn remove_node_property(&mut self, node_id: NodeId, key: &str) -> bool

Source§

fn add_node_label(&mut self, node_id: NodeId, label: &str) -> bool

Source§

fn remove_node_label(&mut self, node_id: NodeId, label: &str) -> bool

Source§

fn set_relationship_property( &mut self, rel_id: RelationshipId, key: String, value: PropertyValue, ) -> bool

Source§

fn remove_relationship_property( &mut self, rel_id: RelationshipId, key: &str, ) -> bool

Source§

fn delete_relationship(&mut self, rel_id: RelationshipId) -> bool

Source§

fn delete_node(&mut self, node_id: NodeId) -> bool

Returns false if the node still has attached relationships.
Source§

fn detach_delete_node(&mut self, node_id: NodeId) -> bool

Deletes the node and all attached relationships.
Source§

fn clear(&mut self)

Drop every node and every relationship, returning the store to an empty state. Provided as a trait method so callers (bindings, admin tools) can reset a graph without knowing the concrete backend. Read more
Source§

fn create_index( &mut self, request: IndexRequest, if_not_exists: bool, ) -> Result<CreateIndexOutcome, CreateIndexError>

Register an explicitly-declared index in the catalog. Backends that don’t maintain a catalog return CreateIndexError::Unsupported. Read more
Source§

fn drop_index( &mut self, name: &str, if_exists: bool, ) -> Result<DropIndexOutcome, DropIndexError>

Remove an explicitly-declared index from the catalog. Backends without catalog support return DropIndexError::Unsupported. if_exists collapses missing-index errors into DropIndexOutcome::NoOpMissing.
Source§

fn create_constraint( &mut self, request: ConstraintRequest, if_not_exists: bool, ) -> Result<CreateConstraintOutcome, CreateConstraintError>

Register an explicitly-declared constraint. Backends without catalog support return CreateConstraintError::Unsupported. Uniqueness/key kinds may transparently register a backing range index of the same name.
Source§

fn drop_constraint( &mut self, name: &str, if_exists: bool, ) -> Result<DropConstraintOutcome, DropConstraintError>

Drop a named constraint. Cascades to the backing index if the constraint owned one.
Source§

fn replace_node_properties( &mut self, node_id: NodeId, properties: Properties, ) -> bool
where Self: Sized,

Source§

fn merge_node_properties( &mut self, node_id: NodeId, properties: Properties, ) -> bool

Source§

fn set_node_labels(&mut self, node_id: NodeId, labels: Vec<String>) -> bool
where Self: Sized,

Source§

fn replace_relationship_properties( &mut self, rel_id: RelationshipId, properties: Properties, ) -> bool
where Self: Sized,

Source§

fn merge_relationship_properties( &mut self, rel_id: RelationshipId, properties: Properties, ) -> bool

Source§

fn delete_relationships_of( &mut self, node_id: NodeId, direction: Direction, ) -> usize

Source§

fn get_or_create_node( &mut self, labels: Vec<String>, match_key: &str, match_value: &PropertyValue, init_properties: Properties, ) -> NodeRecord
where Self: Sized,

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GraphCatalog for T
where T: GraphStorage,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.