Skip to main content

GraphStore

Struct GraphStore 

Source
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

Source

pub fn new() -> GraphStore

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.

Source

pub fn with_registry(registry: Arc<LabelRegistry>) -> GraphStore

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

Source

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

Source

pub fn intern_edge_label(&self, label: &str) -> Result<LabelId, GraphStoreError>

Intern an arbitrary edge label string.

Source

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.

Source

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.

Source

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.

Source

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

Source

pub fn get_node_table_ref(&self, node_id: &str) -> Option<TableRef>

Get table reference for a node (if linked)

Source

pub fn get_node(&self, id: &str) -> Option<StoredNode>

Get a node by ID (lock-free read)

Source

pub fn outgoing_edges(&self, source_id: &str) -> Vec<(String, String, f32)>

Get all outgoing edges from a node (edge_label, target, weight).

Source

pub fn incoming_edges(&self, target_id: &str) -> Vec<(String, String, f32)>

Get all incoming edges to a node (edge_label, source, weight).

Source

pub fn outgoing_of_type( &self, source_id: &str, edge_label: &str, ) -> Vec<(String, f32)>

Get outgoing edges of a specific label.

Source

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

Check if a node exists

Source

pub fn node_count(&self) -> u64

Get node count

Source

pub fn edge_count(&self) -> u64

Get edge count

Source

pub fn iter_nodes(&self) -> NodeIterator<'_>

Iterate over all nodes (streaming)

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn node_secondary_index(&self) -> &NodeSecondaryIndex

Read-only handle to the secondary index (for planner/diagnostics).

Source

pub fn stats(&self) -> GraphStats

Get statistics

Source

pub fn serialize(&self) -> Vec<u8>

Serialize to bytes for persistence (file format v2: includes the embedded LabelRegistry catalog right after the fixed header).

Source

pub fn deserialize(data: &[u8]) -> Result<GraphStore, 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§

Source§

impl Default for GraphStore

Source§

fn default() -> GraphStore

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

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more