Skip to main content

GraphReader

Trait GraphReader 

Source
pub trait GraphReader: Send + Sync {
Show 16 methods // Required methods fn get_node(&self, id: NodeId) -> Result<Option<Node>>; fn get_edge(&self, id: EdgeId) -> Result<Option<Edge>>; fn all_node_ids(&self) -> Result<Vec<NodeId>>; fn nodes_by_label(&self, label: &str) -> Result<Vec<NodeId>>; fn nodes_by_property( &self, label: &str, property: &str, value: &Property, ) -> Result<Vec<NodeId>>; fn outgoing(&self, id: NodeId) -> Result<Vec<(EdgeId, NodeId)>>; fn incoming(&self, id: NodeId) -> Result<Vec<(EdgeId, NodeId)>>; // Provided methods fn nodes_by_properties( &self, label: &str, properties: &[String], values: &[Property], ) -> Result<Vec<NodeId>> { ... } fn edges_by_property( &self, _edge_type: &str, _property: &str, _value: &Property, ) -> Result<Vec<EdgeId>> { ... } fn list_property_indexes(&self) -> Result<Vec<(String, Vec<String>)>> { ... } fn list_edge_property_indexes(&self) -> Result<Vec<(String, Vec<String>)>> { ... } fn list_point_indexes(&self) -> Result<Vec<(String, String)>> { ... } fn list_edge_point_indexes(&self) -> Result<Vec<(String, String)>> { ... } fn nodes_in_bbox( &self, label: &str, property: &str, srid: i32, xlo: f64, ylo: f64, xhi: f64, yhi: f64, ) -> Result<Vec<NodeId>> { ... } fn edges_in_bbox( &self, _edge_type: &str, _property: &str, _srid: i32, _xlo: f64, _ylo: f64, _xhi: f64, _yhi: f64, ) -> Result<Vec<EdgeId>> { ... } fn list_property_constraints(&self) -> Result<Vec<PropertyConstraintSpec>> { ... }
}
Expand description

Read-side counterpart to crate::GraphWriter. Gives the executor a uniform view of the graph regardless of whether the data behind it lives entirely in a local storage engine (single-node or full-replica Raft mode) or is sharded across cluster peers (routing mode, where a partitioned reader fans out point reads to owners and scatter-gathers bulk scans).

Methods are sync because the executor’s iterator model is sync. Async- backed implementations (e.g. a remote reader that talks gRPC) bridge via Handle::block_on; callers must run the executor inside spawn_blocking so they don’t stall the tokio runtime.

Required Methods§

Source

fn get_node(&self, id: NodeId) -> Result<Option<Node>>

Source

fn get_edge(&self, id: EdgeId) -> Result<Option<Edge>>

Source

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

Source

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

Source

fn nodes_by_property( &self, label: &str, property: &str, value: &Property, ) -> Result<Vec<NodeId>>

Equality lookup via a property index. Callers (planner) must have verified the (label, property) index exists before emitting this call — fallback implementations are free to do a label-scan-and-filter for impls that don’t maintain their own property index, but the storage-backed reader treats a call on a non-existent index as an empty result since no entries are maintained.

Source

fn outgoing(&self, id: NodeId) -> Result<Vec<(EdgeId, NodeId)>>

Source

fn incoming(&self, id: NodeId) -> Result<Vec<(EdgeId, NodeId)>>

Provided Methods§

Source

fn nodes_by_properties( &self, label: &str, properties: &[String], values: &[Property], ) -> Result<Vec<NodeId>>

Composite form of Self::nodes_by_property. properties and values are parallel slices of equal length — every slot must be present for the call to land a match. The default impl delegates to nodes_by_property for length-1 slices and returns empty otherwise, so readers that haven’t wired a native composite seek degrade to no-results rather than mis-answering. The storage-backed blanket overrides with a real composite lookup.

Source

fn edges_by_property( &self, _edge_type: &str, _property: &str, _value: &Property, ) -> Result<Vec<EdgeId>>

Relationship-scope analogue of Self::nodes_by_property. The planner only emits an EdgeSeek after confirming a (edge_type, property) index is registered via Self::list_edge_property_indexes. Default impl returns empty so readers that haven’t wired a native seek path degrade to no-results rather than mis-answering; the storage-backed blanket overrides with a real lookup.

Source

fn list_property_indexes(&self) -> Result<Vec<(String, Vec<String>)>>

Snapshot the (label, property) pairs of every property index visible through this reader. Used by SHOW INDEXES. Default impl returns empty — the storage-backed reader overrides via the blanket impl, and partitioned/overlay readers delegate to their bases.

Source

fn list_edge_property_indexes(&self) -> Result<Vec<(String, Vec<String>)>>

Relationship-scope analogue of Self::list_property_indexes. Returns (edge_type, property) pairs for every registered edge property index. Default impl returns empty; overlay and partitioned readers delegate to their bases.

Source

fn list_point_indexes(&self) -> Result<Vec<(String, String)>>

Snapshot the (label, property) pairs of every point / spatial index visible through this reader. Used by SHOW POINT INDEXES. Default impl returns empty; storage-backed readers override via the blanket impl.

Source

fn list_edge_point_indexes(&self) -> Result<Vec<(String, String)>>

Relationship-scope analogue of Self::list_point_indexes. (edge_type, property) pairs. Default impl returns empty.

Source

fn nodes_in_bbox( &self, label: &str, property: &str, srid: i32, xlo: f64, ylo: f64, xhi: f64, yhi: f64, ) -> Result<Vec<NodeId>>

Axis-aligned bounding-box range query over the point index (label, property). Returns every node carrying label whose property is a Property::Point under srid that falls inside [xlo..xhi] × [ylo..yhi].

Default impl does the naive scan (iterate nodes_by_label, filter in memory) so that readers that don’t maintain a spatial index — or that haven’t wired a native range query — stay correct, just slow. Partitioned readers inherit this default and get cluster-wide correctness through the scatter-gather nodes_by_label underneath. The storage-backed blanket overrides with the Z-order seek.

Source

fn edges_in_bbox( &self, _edge_type: &str, _property: &str, _srid: i32, _xlo: f64, _ylo: f64, _xhi: f64, _yhi: f64, ) -> Result<Vec<EdgeId>>

Relationship-scope analogue of Self::nodes_in_bbox. Default impl returns empty — edge-scoped bbox queries aren’t yet part of the planner’s rewrite surface, so no read path exercises this on anything but the storage-backed blanket. When the edge point-seek lowering lands this default should grow a naive scan via edges_by_type (needs to be added to the trait first).

Source

fn list_property_constraints(&self) -> Result<Vec<PropertyConstraintSpec>>

Snapshot every registered constraint visible through this reader, for SHOW CONSTRAINTS and db.constraints(). Default impl returns empty; storage-backed readers override.

Implementors§

Source§

impl GraphReader for StorageReaderAdapter<'_>

Source§

impl<T: StorageEngine> GraphReader for T

Blanket impl: any sized type that implements StorageEngine is automatically a GraphReader. Covers the concrete meshdb_storage::RocksDbStorageEngine — a &RocksDbStorageEngine coerces to &dyn GraphReader via this blanket.

Not covered: dyn StorageEngine itself. Rust does not transitively coerce &dyn StorageEngine to &dyn GraphReader because trait objects of unrelated traits carry different vtables and there’s no supertrait relationship connecting them. Call sites that hold a &dyn StorageEngine should use StorageReaderAdapter to wrap it as a GraphReader.