Expand description
Storage backends for graph data.
This module defines the GraphStorage trait and provides concrete implementations
for storing graph data. The storage layer is responsible for:
- Storing vertices and edges with their labels and properties
- Providing efficient lookups by ID
- Supporting adjacency traversal (outgoing/incoming edges)
- Label-based filtering using indexed lookups
§Available Backends
| Backend | Description | Use Case |
|---|---|---|
Graph | COW graph with structural sharing | Development, production in-memory |
[PersistentGraph] | Memory-mapped persistent storage | Production, large graphs (requires mmap feature) |
§Architecture
All storage backends implement the GraphStorage trait, which provides a unified
interface for the traversal engine. This allows the same traversal code to work
with any backend.
┌─────────────────────────────────────────────┐
│ Traversal Engine │
└─────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ GraphStorage trait │
└─────────────────────────────────────────────┘
│
┌────────────┴────────────┐
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ GraphSnapshot │ │ PersistentGraph │
└─────────────────┘ └─────────────────┘§Example
use interstellar::storage::{Graph, GraphStorage};
use std::collections::HashMap;
let graph = Graph::new();
// Add vertices via Graph methods
let alice = graph.add_vertex("person", HashMap::from([
("name".to_string(), "Alice".into()),
]));
let bob = graph.add_vertex("person", HashMap::from([
("name".to_string(), "Bob".into()),
]));
graph.add_edge(alice, bob, "knows", HashMap::new()).unwrap();
// Query via snapshot
let snapshot = graph.snapshot();
assert_eq!(snapshot.vertex_count(), 2);
assert_eq!(snapshot.edge_count(), 1);Re-exports§
pub use cow::BatchContext;pub use cow::BatchError;pub use cow::Graph;pub use cow::GraphMutWrapper;pub use cow::GraphSnapshot;pub use cow::GraphState;pub use interner::StringInterner;
Modules§
- cow
- Copy-on-Write graph storage with snapshot isolation.
- interner
- String interning for efficient label storage.
Structs§
- Edge
- An edge in the graph connecting two vertices.
- Vertex
- A vertex in the graph with its label and properties.
Traits§
- Graph
Storage - Trait for graph storage backends.
- Graph
Storage Mut - Trait for mutable graph storage operations.
- Streamable
Storage - Extension trait for storage backends that support streaming iteration.