pub struct Graph { /* private fields */ }Expand description
Top-level graph handle: memtable over immutable segments, LSM-style.
Reads merge the memtable with every open segment; flush drains the
memtable into a new segment and commits a new manifest generation.
Graph::new is in-memory only (no flush); Graph::open is the embedded
persistent mode.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn upsert_node(&mut self, key: &str) -> NodeId
pub fn upsert_node(&mut self, key: &str) -> NodeId
Create a node with a user-facing key, or return the existing id.
pub fn node(&self, key: &str) -> Option<NodeId>
Sourcepub fn label(&mut self, name: &str) -> EdgeLabel
pub fn label(&mut self, name: &str) -> EdgeLabel
Intern a label string, returning its id. Label indices are identity forever — the manifest’s label list is append-only.
pub fn add_edge( &mut self, src: NodeId, label: EdgeLabel, dst: NodeId, ) -> Result<()>
Sourcepub fn out(&self, src: NodeId, label: EdgeLabel) -> impl Iterator<Item = NodeId>
pub fn out(&self, src: NodeId, label: EdgeLabel) -> impl Iterator<Item = NodeId>
Outbound neighbors of src under label, merged across memtable
and segments, ascending and deduplicated.
Sourcepub fn in(&self, dst: NodeId, label: EdgeLabel) -> impl Iterator<Item = NodeId>
pub fn in(&self, dst: NodeId, label: EdgeLabel) -> impl Iterator<Item = NodeId>
Inbound neighbors of dst under label, merged the same way.
Sourcepub fn flush(&mut self) -> Result<u64>
pub fn flush(&mut self) -> Result<u64>
Drain the memtable into a new segment and commit the next manifest generation. No-op (returns the current generation) when there is nothing to write.