Skip to main content

GraphStore

Struct GraphStore 

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

Implementations§

Source§

impl GraphStore

Source

pub fn open_file(path: impl AsRef<Path>) -> Result<Self, GraphError>

Source

pub fn open_memory() -> Result<Self, GraphError>

Source

pub fn begin_write(&self) -> Result<WriteTransaction, GraphError>

Open a write transaction spanning multiple graph operations. Callers (e.g. the query executor) drive an entire Cypher statement through the *_in_txn methods below using this one transaction, then call write_txn.commit() themselves — this is the crash-safety boundary from the plan: one statement = one transaction, not one transaction per individual node/edge write.

v1 uses a write transaction even for pure-read statements (rather than a separate read-only path) to keep one code path and guarantee every statement — reads included — sees one consistent snapshot. Trade-off: this serializes concurrent readers behind redb’s single-writer lock instead of allowing true concurrent reads; a read-only transaction path is the natural follow-up if read concurrency becomes a bottleneck.

Source

pub fn begin_read(&self) -> Result<ReadTransaction, GraphError>

Open a read transaction for a statement that never mutates anything (MATCH ... RETURN) — a consistent point-in-time snapshot that runs alongside any concurrent readers or a concurrent writer without contending for redb’s single-writer lock. No commit/abort: a read transaction has nothing to roll back, it just releases on drop.

Source

pub fn commit(write_txn: WriteTransaction) -> Result<(), GraphError>

Commit a transaction obtained from begin_write.

Source

pub fn abort(write_txn: WriteTransaction) -> Result<(), GraphError>

Abort (roll back) a transaction obtained from begin_write, discarding any writes made through it.

Source

pub fn create_node( &self, labels: &[&str], props: BTreeMap<String, PropertyValue>, ) -> Result<NodeId, GraphError>

Source

pub fn create_node_in_txn( write_txn: &WriteTransaction, labels: &[&str], props: BTreeMap<String, PropertyValue>, ) -> Result<NodeId, GraphError>

Source

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

Source

pub fn get_node_in_txn( txn: Txn<'_>, id: NodeId, ) -> Result<Option<Node>, GraphError>

Source

pub fn create_edge( &self, label: &str, src: NodeId, dst: NodeId, props: BTreeMap<String, PropertyValue>, ) -> Result<EdgeId, GraphError>

Source

pub fn create_edge_in_txn( write_txn: &WriteTransaction, label: &str, src: NodeId, dst: NodeId, props: BTreeMap<String, PropertyValue>, ) -> Result<EdgeId, GraphError>

Source

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

Source

pub fn get_edge_in_txn( txn: Txn<'_>, id: EdgeId, ) -> Result<Option<Edge>, GraphError>

Source

pub fn neighbors( &self, node: NodeId, dir: Direction, label_filter: Option<&str>, ) -> Result<Vec<AdjEntry>, GraphError>

Neighbors of node in dir, optionally filtered by edge label. Reads directly from the adjacency multimap without touching edges.

Source

pub fn neighbors_in_txn( txn: Txn<'_>, node: NodeId, dir: Direction, label_filter: Option<&str>, ) -> Result<Vec<AdjEntry>, GraphError>

Source

pub fn delete_edge(&self, id: EdgeId) -> Result<bool, GraphError>

Source

pub fn delete_edge_in_txn( write_txn: &WriteTransaction, id: EdgeId, ) -> Result<bool, GraphError>

Source

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

Delete a node. If detach is false and the node has incident edges, returns GraphError::NodeHasEdges instead of deleting anything.

Source

pub fn delete_node_in_txn( write_txn: &WriteTransaction, id: NodeId, detach: bool, ) -> Result<bool, GraphError>

Source

pub fn set_node_prop( &self, id: NodeId, key: &str, value: PropertyValue, ) -> Result<bool, GraphError>

Source

pub fn set_node_prop_in_txn( write_txn: &WriteTransaction, id: NodeId, key: &str, value: PropertyValue, ) -> Result<bool, GraphError>

Source

pub fn set_edge_prop( &self, id: EdgeId, key: &str, value: PropertyValue, ) -> Result<bool, GraphError>

Source

pub fn set_edge_prop_in_txn( write_txn: &WriteTransaction, id: EdgeId, key: &str, value: PropertyValue, ) -> Result<bool, GraphError>

Source

pub fn all_nodes( &self, label_filter: Option<&str>, ) -> Result<Vec<Node>, GraphError>

Full scan of all nodes, optionally filtered by label. v1 has no secondary index on label, so this is a linear scan of the table.

Source

pub fn all_nodes_in_txn( txn: Txn<'_>, label_filter: Option<&str>, ) -> Result<Vec<Node>, GraphError>

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