pub struct GraphStore {
pub registry: Arc<LabelRegistry>,
/* private fields */
}Expand description
High-performance graph storage engine
Provides concurrent read access with minimal locking overhead. Writes are serialized through a write lock but reads can proceed in parallel.
Fields§
§registry: Arc<LabelRegistry>Dynamic label catalog. Resolves user-supplied label strings to
stable LabelId u32 values used in the v2 page format.
Implementations§
Source§impl GraphStore
impl GraphStore
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty graph store with a fresh LabelRegistry that
has the legacy reserved label IDs (1..=19) pre-seeded so v1
on-disk graph records still decode round-trip.
Sourcepub fn with_registry(registry: Arc<LabelRegistry>) -> Self
pub fn with_registry(registry: Arc<LabelRegistry>) -> Self
Create an empty graph store sharing the given LabelRegistry. Use
this when multiple GraphStore instances should agree on
LabelId assignments (e.g. when the same database holds several
named graphs).
Sourcepub fn intern_node_label(&self, label: &str) -> Result<LabelId, GraphStoreError>
pub fn intern_node_label(&self, label: &str) -> Result<LabelId, GraphStoreError>
Intern an arbitrary node label string. Convenience wrapper over
LabelRegistry::intern; the returned LabelId can be passed to
the upcoming label-id-aware insert APIs (PR3).
Sourcepub fn intern_edge_label(&self, label: &str) -> Result<LabelId, GraphStoreError>
pub fn intern_edge_label(&self, label: &str) -> Result<LabelId, GraphStoreError>
Intern an arbitrary edge label string.
Sourcepub fn publish_indexes(&self, registry: &IndexRegistry, collection: &str)
pub fn publish_indexes(&self, registry: &IndexRegistry, collection: &str)
Publish this graph’s secondary index into an external
IndexRegistry. The registry holds an Arc pointing to the same
live index, so planners consulting the registry see current stats
without any copy/refresh logic.
Scope: IndexScope::graph(collection). Idempotent — subsequent
calls replace the previous entry.
Sourcepub fn add_node_with_label(
&self,
id: &str,
display_label: &str,
category: &str,
) -> Result<RecordLocation, GraphStoreError>
pub fn add_node_with_label( &self, id: &str, display_label: &str, category: &str, ) -> Result<RecordLocation, GraphStoreError>
Add a node using a category label string. Interns category into the
LabelRegistry and writes the node in v2 format.
Sourcepub fn add_edge_with_label(
&self,
source_id: &str,
target_id: &str,
category: &str,
weight: f32,
) -> Result<RecordLocation, GraphStoreError>
pub fn add_edge_with_label( &self, source_id: &str, target_id: &str, category: &str, weight: f32, ) -> Result<RecordLocation, GraphStoreError>
Add an edge using a category label string.
Sourcepub fn add_node_linked(
&self,
id: &str,
label: &str,
category: &str,
table_id: u16,
row_id: u64,
) -> Result<RecordLocation, GraphStoreError>
pub fn add_node_linked( &self, id: &str, label: &str, category: &str, table_id: u16, row_id: u64, ) -> Result<RecordLocation, GraphStoreError>
Add a node linked to a table row (for unified queries).
Sourcepub fn get_node_table_ref(&self, node_id: &str) -> Option<TableRef>
pub fn get_node_table_ref(&self, node_id: &str) -> Option<TableRef>
Get table reference for a node (if linked)
Sourcepub fn get_node(&self, id: &str) -> Option<StoredNode>
pub fn get_node(&self, id: &str) -> Option<StoredNode>
Get a node by ID (lock-free read)
Sourcepub fn outgoing_edges(&self, source_id: &str) -> Vec<(String, String, f32)>
pub fn outgoing_edges(&self, source_id: &str) -> Vec<(String, String, f32)>
Get all outgoing edges from a node (edge_label, target, weight).
Sourcepub fn incoming_edges(&self, target_id: &str) -> Vec<(String, String, f32)>
pub fn incoming_edges(&self, target_id: &str) -> Vec<(String, String, f32)>
Get all incoming edges to a node (edge_label, source, weight).
Sourcepub fn outgoing_of_type(
&self,
source_id: &str,
edge_label: &str,
) -> Vec<(String, f32)>
pub fn outgoing_of_type( &self, source_id: &str, edge_label: &str, ) -> Vec<(String, f32)>
Get outgoing edges of a specific label.
Sourcepub fn node_count(&self) -> u64
pub fn node_count(&self) -> u64
Get node count
Sourcepub fn edge_count(&self) -> u64
pub fn edge_count(&self) -> u64
Get edge count
Sourcepub fn iter_nodes(&self) -> NodeIterator<'_> ⓘ
pub fn iter_nodes(&self) -> NodeIterator<'_> ⓘ
Iterate over all nodes (streaming)
Sourcepub fn iter_all_edges(&self) -> Vec<StoredEdge>
pub fn iter_all_edges(&self) -> Vec<StoredEdge>
Iterate all edges in the graph
This collects outgoing edges from all nodes to build a complete edge list. Returns StoredEdge structs with source, target, type, and weight.
Sourcepub fn nodes_of_label(&self, label_id: LabelId) -> Vec<StoredNode>
pub fn nodes_of_label(&self, label_id: LabelId) -> Vec<StoredNode>
Get nodes whose category resolves to label_id. O(k) via secondary
index plus one fetch per id.
Sourcepub fn nodes_by_label(&self, label: &str) -> Vec<StoredNode>
pub fn nodes_by_label(&self, label: &str) -> Vec<StoredNode>
Get nodes with a given label. Backed by the secondary inverted index
(label → node_id set) with a bloom-filter pre-check for absent
labels.
Sourcepub fn nodes_with_category(&self, category: &str) -> Vec<StoredNode>
pub fn nodes_with_category(&self, category: &str) -> Vec<StoredNode>
Get nodes whose category label (as registered in the
LabelRegistry) matches the given string. Replaces the
enum-typed [nodes_of_type] for callers that work with arbitrary
user-defined labels.
O(k) lookup via secondary index keyed by LabelId.
Sourcepub fn may_contain_label(&self, label: &str) -> bool
pub fn may_contain_label(&self, label: &str) -> bool
Returns true iff the label is possibly present. Bloom-backed
fast path for planners that want to skip a traversal without paying
the set lookup cost.
Sourcepub fn node_secondary_index(&self) -> &NodeSecondaryIndex
pub fn node_secondary_index(&self) -> &NodeSecondaryIndex
Read-only handle to the secondary index (for planner/diagnostics).
Sourcepub fn stats(&self) -> GraphStats
pub fn stats(&self) -> GraphStats
Get statistics
Sourcepub fn serialize(&self) -> Vec<u8> ⓘ
pub fn serialize(&self) -> Vec<u8> ⓘ
Serialize to bytes for persistence (file format v2: includes the
embedded LabelRegistry catalog right after the fixed header).
Sourcepub fn deserialize(data: &[u8]) -> Result<Self, GraphStoreError>
pub fn deserialize(data: &[u8]) -> Result<Self, GraphStoreError>
Deserialize from bytes. Dual-path: a v1 file (no embedded registry,
1-byte enum discriminants) is read with StoredNode::decode_v1
against a freshly-seeded legacy registry. A v2 file restores the
registry from its embedded blob and decodes records via
StoredNode::decode.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for GraphStore
impl RefUnwindSafe for GraphStore
impl Send for GraphStore
impl Sync for GraphStore
impl Unpin for GraphStore
impl UnsafeUnpin for GraphStore
impl UnwindSafe for GraphStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request