GraphTable

Struct GraphTable 

Source
pub struct GraphTable<'txn> { /* private fields */ }
Expand description

A table storing graph edges with bidirectional indexes and temporal tracking.

This table maintains two internal tables (forward and reverse) to enable efficient queries for both outgoing and incoming edges. Both tables are updated atomically within the same write transaction.

Value tuple: (is_active, weight, created_at, deleted_at)

Implementations§

Source§

impl<'txn> GraphTable<'txn>

Source

pub fn open(txn: &'txn WriteTransaction, name: &str) -> Result<Self, TableError>

Opens a graph table for writing.

Creates two internal tables: {name}_forward and {name}_reverse.

Source

pub fn add_edge( &mut self, source: &Uuid, edge_type: &str, target: &Uuid, is_active: bool, weight: f32, created_at: Option<u64>, ) -> Result<(), TableError>

Adds an edge to the graph with optional timestamp.

Updates both forward and reverse indexes atomically.

§Arguments
  • source - Source vertex UUID
  • edge_type - Edge type (e.g., “follows”, “knows”)
  • target - Target vertex UUID
  • is_active - Whether the edge is active
  • weight - Edge weight/score
  • created_at - Optional creation timestamp (uses current time if None)
Source

pub fn remove_edge( &mut self, source: &Uuid, edge_type: &str, target: &Uuid, ) -> Result<(), StorageError>

Soft deletes an edge from the graph by setting deleted_at timestamp.

The edge remains in storage for temporal queries but is marked as deleted. Updates both forward and reverse indexes atomically.

Source

pub fn hard_delete_edge( &mut self, source: &Uuid, edge_type: &str, target: &Uuid, ) -> Result<(), StorageError>

Hard deletes an edge from the graph, removing it entirely from storage.

This permanently removes the edge and its history. Use remove_edge() for soft delete that preserves temporal history.

Source

pub fn update_edge( &mut self, source: &Uuid, edge_type: &str, target: &Uuid, is_active: bool, weight: f32, ) -> Result<(), TableError>

Updates the properties of an existing edge while preserving timestamps.

Updates both forward and reverse indexes atomically.

Source

pub fn add_edges_batch( &mut self, edges: &[(Uuid, &str, Uuid, bool, f32, u64)], sorted: bool, ) -> Result<usize, StorageError>

Adds multiple edges to the graph in a single batch operation.

This method leverages Manifold’s bulk insertion API for improved throughput, especially beneficial when loading large graphs. Both forward and reverse indexes are updated atomically within the same transaction.

§Arguments
  • edges - Vector of edge tuples: (source, edge_type, target, is_active, weight, created_at)
  • sorted - Whether the input is pre-sorted by (source, edge_type, target). Set to true if your data is already sorted for best performance.
§Returns

Returns the number of edges inserted.

§Performance
  • Sorted data (sorted = true): Uses optimized insertion with minimal tree rebalancing
  • Unsorted data (sorted = false): Chunks and sorts data internally for good performance
  • Batch operations benefit from WAL group commit for higher throughput
§Example
let u1 = Uuid::new_v4();
let u2 = Uuid::new_v4();
let u3 = Uuid::new_v4();
let now = 1234567890;

let edges = vec![
    (u1, "follows", u2, true, 1.0, now),
    (u1, "follows", u3, true, 0.8, now),
    (u2, "follows", u3, true, 0.9, now),
];

let count = graph.add_edges_batch(&edges, false)?;
assert_eq!(count, 3);
Source

pub fn len(&self) -> Result<u64, StorageError>

Returns the number of edges in the forward table.

Source

pub fn is_empty(&self) -> Result<bool, StorageError>

Returns true if the table contains no edges.

Auto Trait Implementations§

§

impl<'txn> Freeze for GraphTable<'txn>

§

impl<'txn> !RefUnwindSafe for GraphTable<'txn>

§

impl<'txn> Send for GraphTable<'txn>

§

impl<'txn> Sync for GraphTable<'txn>

§

impl<'txn> Unpin for GraphTable<'txn>

§

impl<'txn> !UnwindSafe for GraphTable<'txn>

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.