Skip to main content

GraphSnapshot

Struct GraphSnapshot 

Source
pub struct GraphSnapshot { /* private fields */ }
Expand description

An owned snapshot of the graph at a point in time.

Unlike the current GraphSnapshot<'g>, this snapshot:

  • Does not hold any locks
  • Can be sent across threads (Send + Sync)
  • Can outlive the source Graph
  • Is immutable and will never change

§Example

use interstellar::storage::cow::Graph;
use interstellar::storage::GraphStorage;
use std::collections::HashMap;
use std::thread;

let graph = Graph::new();
graph.add_vertex("person", HashMap::new());

let snap = graph.snapshot();

// Snapshot can be sent to another thread
let handle = thread::spawn(move || {
    snap.vertex_count()
});

assert_eq!(handle.join().unwrap(), 1);

Implementations§

Source§

impl GraphSnapshot

Source

pub fn version(&self) -> u64

Get the snapshot version.

Source

pub fn interner(&self) -> &StringInterner

Get the string interner for this snapshot.

This returns a reference to the snapshot-local cloned interner.

Source

pub fn arc_storage(&self) -> Arc<dyn GraphStorage + Send + Sync>

Get Arc-wrapped storage for streaming execution.

Returns a clone of self wrapped in Arc. Since GraphSnapshot implements GraphStorage, this enables streaming pipelines to own the storage without lifetime constraints.

Source

pub fn arc_interner(&self) -> Arc<StringInterner>

Get Arc-wrapped interner for streaming execution.

Returns a clone of the internal Arc reference.

Source

pub fn gremlin(&self) -> GraphTraversalSource<'_>

Create a Gremlin traversal source for this snapshot.

This provides the full Gremlin-style fluent API for querying the graph. Since GraphSnapshot is immutable, only read operations are available.

§Example
use interstellar::storage::cow::Graph;
use interstellar::value::Value;
use std::collections::HashMap;

let graph = Graph::new();
graph.add_vertex("Person", HashMap::from([
    ("name".to_string(), Value::String("Alice".to_string())),
]));

let snapshot = graph.snapshot();
let g = snapshot.gremlin();

let count = g.v().has_label("Person").count();
assert_eq!(count, 1);
Source§

impl GraphSnapshot

Source

pub fn arc_streamable(&self) -> Arc<dyn StreamableStorage>

Returns an Arc for use with StreamingExecutor.

This enables the traversal engine to hold an owned reference to the storage that can be used to create streaming iterators. The clone is cheap since GraphSnapshot is internally Arc-based.

§Example
let snapshot = graph.snapshot();
let streamable = snapshot.arc_streamable();
let interner = snapshot.arc_interner();
let executor = StreamingExecutor::new_streaming(streamable, interner, ...);

Trait Implementations§

Source§

impl Clone for GraphSnapshot

Source§

fn clone(&self) -> GraphSnapshot

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl GraphStorage for GraphSnapshot

Source§

fn get_vertex(&self, id: VertexId) -> Option<Vertex>

Retrieves a vertex by its ID. Read more
Source§

fn vertex_count(&self) -> u64

Returns the total number of vertices in the graph. Read more
Source§

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

Retrieves an edge by its ID. Read more
Source§

fn edge_count(&self) -> u64

Returns the total number of edges in the graph. Read more
Source§

fn out_edges(&self, vertex: VertexId) -> Box<dyn Iterator<Item = Edge> + '_>

Returns an iterator over all outgoing edges from a vertex. Read more
Source§

fn in_edges(&self, vertex: VertexId) -> Box<dyn Iterator<Item = Edge> + '_>

Returns an iterator over all incoming edges to a vertex. Read more
Source§

fn vertices_with_label( &self, label: &str, ) -> Box<dyn Iterator<Item = Vertex> + '_>

Returns an iterator over all vertices with a given label. Read more
Source§

fn edges_with_label(&self, label: &str) -> Box<dyn Iterator<Item = Edge> + '_>

Returns an iterator over all edges with a given label. Read more
Source§

fn all_vertices(&self) -> Box<dyn Iterator<Item = Vertex> + '_>

Returns an iterator over all vertices in the graph. Read more
Source§

fn all_edges(&self) -> Box<dyn Iterator<Item = Edge> + '_>

Returns an iterator over all edges in the graph. Read more
Source§

fn interner(&self) -> &StringInterner

Returns a reference to the string interner for label resolution. Read more
Source§

fn vertices_by_property( &self, label: Option<&str>, property: &str, value: &Value, ) -> Box<dyn Iterator<Item = Vertex> + '_>

Lookup vertices by property value, using indexes if available. Read more
Source§

fn edges_by_property( &self, label: Option<&str>, property: &str, value: &Value, ) -> Box<dyn Iterator<Item = Edge> + '_>

Lookup edges by property value, using indexes if available. Read more
Source§

fn vertices_by_property_range( &self, label: Option<&str>, property: &str, start: Bound<&Value>, end: Bound<&Value>, ) -> Box<dyn Iterator<Item = Vertex> + '_>

Lookup vertices by property range, using indexes if available. Read more
Source§

fn supports_indexes(&self) -> bool

Returns whether this storage supports property indexes. Read more
Source§

impl SnapshotLike for GraphSnapshot

Source§

fn storage(&self) -> &dyn GraphStorage

Get a reference to the underlying graph storage.
Source§

fn interner(&self) -> &StringInterner

Get a reference to the string interner for label resolution.
Source§

fn as_dyn(&self) -> &dyn SnapshotLike

Get a reference to self as a trait object. Read more
Source§

fn arc_storage(&self) -> Arc<dyn GraphStorage + Send + Sync>

Get Arc-wrapped storage for streaming execution. Read more
Source§

fn arc_interner(&self) -> Arc<StringInterner>

Get Arc-wrapped interner for streaming execution. Read more
Source§

fn arc_streamable(&self) -> Arc<dyn StreamableStorage>

Get Arc-wrapped streamable storage for true O(1) streaming execution. Read more
Source§

impl StreamableStorage for GraphSnapshot

Source§

fn stream_all_vertices(&self) -> Box<dyn Iterator<Item = VertexId> + Send>

Stream all vertex IDs without collecting. Read more
Source§

fn stream_all_edges(&self) -> Box<dyn Iterator<Item = EdgeId> + Send>

Stream all edge IDs without collecting. Read more
Source§

fn stream_vertices_with_label( &self, label: &str, ) -> Box<dyn Iterator<Item = VertexId> + Send>

Stream vertex IDs with a given label without collecting. Read more
Source§

fn stream_edges_with_label( &self, label: &str, ) -> Box<dyn Iterator<Item = EdgeId> + Send>

Stream edge IDs with a given label without collecting. Read more
Source§

fn stream_out_edges( &self, vertex: VertexId, ) -> Box<dyn Iterator<Item = EdgeId> + Send>

Stream outgoing edge IDs from a vertex without collecting. Read more
Source§

fn stream_in_edges( &self, vertex: VertexId, ) -> Box<dyn Iterator<Item = EdgeId> + Send>

Stream incoming edge IDs to a vertex without collecting. Read more
Source§

fn stream_out_neighbors( &self, vertex: VertexId, label_ids: &[u32], ) -> Box<dyn Iterator<Item = VertexId> + Send>

Stream outgoing neighbor vertex IDs without collecting. Read more
Source§

fn stream_in_neighbors( &self, vertex: VertexId, label_ids: &[u32], ) -> Box<dyn Iterator<Item = VertexId> + Send>

Stream incoming neighbor vertex IDs without collecting. Read more
Source§

fn stream_both_neighbors( &self, vertex: VertexId, label_ids: &[u32], ) -> Box<dyn Iterator<Item = VertexId> + Send>

Stream both incoming and outgoing neighbor vertex IDs. Read more
Source§

impl Send for GraphSnapshot

Source§

impl Sync for GraphSnapshot

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V