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
impl GraphSnapshot
Sourcepub fn interner(&self) -> &StringInterner
pub fn interner(&self) -> &StringInterner
Get the string interner for this snapshot.
This returns a reference to the snapshot-local cloned interner.
Sourcepub fn arc_storage(&self) -> Arc<dyn GraphStorage + Send + Sync>
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.
Sourcepub fn arc_interner(&self) -> Arc<StringInterner>
pub fn arc_interner(&self) -> Arc<StringInterner>
Get Arc-wrapped interner for streaming execution.
Returns a clone of the internal Arc reference.
Sourcepub fn gremlin(&self) -> GraphTraversalSource<'_>
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
impl GraphSnapshot
Sourcepub fn arc_streamable(&self) -> Arc<dyn StreamableStorage>
pub fn arc_streamable(&self) -> Arc<dyn StreamableStorage>
Returns an Arc
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
impl Clone for GraphSnapshot
Source§fn clone(&self) -> GraphSnapshot
fn clone(&self) -> GraphSnapshot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more