Skip to main content

Graph

Struct Graph 

Source
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

Source

pub fn new() -> Self

In-memory only; flush returns Error::NoStore.

Source

pub fn open(dir: impl AsRef<Path>) -> Result<Self>

Open (or create) a graph rooted at dir.

Source

pub fn upsert_node(&mut self, key: &str) -> NodeId

Create a node with a user-facing key, or return the existing id.

Source

pub fn node(&self, key: &str) -> Option<NodeId>

Source

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.

Source

pub fn add_edge( &mut self, src: NodeId, label: EdgeLabel, dst: NodeId, ) -> Result<()>

Source

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.

Source

pub fn in(&self, dst: NodeId, label: EdgeLabel) -> impl Iterator<Item = NodeId>

Inbound neighbors of dst under label, merged the same way.

Source

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.

Source

pub fn generation(&self) -> u64

Source

pub fn node_count(&self) -> u64

Source

pub fn edge_count(&self) -> u64

Trait Implementations§

Source§

impl Default for Graph

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl RefUnwindSafe for Graph

§

impl Send for Graph

§

impl Sync for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin for Graph

§

impl UnwindSafe for Graph

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.