pub trait GraphStore {
Show 41 methods
// Required methods
fn transaction<T>(
&mut self,
operation: impl FnOnce(&mut Self) -> GraphStoreResult<T>,
) -> GraphStoreResult<T>
where Self: Sized;
fn create_graph(&mut self, name: &str) -> GraphStoreResult<()>;
fn drop_graph(&mut self, name: &str) -> GraphStoreResult<()>;
fn graph_names(&self) -> GraphStoreResult<Vec<String>>;
fn has_graph(&self, name: &str) -> GraphStoreResult<bool>;
fn union_graphs(
&mut self,
g1: &str,
g2: &str,
target: &str,
) -> GraphStoreResult<()>;
fn intersect_graphs(
&mut self,
g1: &str,
g2: &str,
target: &str,
) -> GraphStoreResult<()>;
fn difference_graphs(
&mut self,
g1: &str,
g2: &str,
target: &str,
) -> GraphStoreResult<()>;
fn copy_graph(&mut self, source: &str, target: &str) -> GraphStoreResult<()>;
fn add_vertex(
&mut self,
vertex: Vertex,
graph: &str,
) -> GraphStoreResult<()>;
fn add_edge(&mut self, edge: Edge, graph: &str) -> GraphStoreResult<()>;
fn remove_vertex(
&mut self,
vertex_id: VertexId,
graph: &str,
) -> GraphStoreResult<()>;
fn remove_edge(
&mut self,
edge_id: EdgeId,
graph: &str,
) -> GraphStoreResult<()>;
fn neighbors(
&self,
vertex_id: VertexId,
label: Option<&str>,
direction: Direction,
graph: &str,
) -> GraphStoreResult<Vec<VertexId>>;
fn vertices_by_label(
&self,
label: &str,
graph: &str,
) -> GraphStoreResult<Vec<Vertex>>;
fn vertices_in_graph(&self, graph: &str) -> GraphStoreResult<Vec<Vertex>>;
fn edges_in_graph(&self, graph: &str) -> GraphStoreResult<Vec<Edge>>;
fn vertex_graphs(
&self,
vertex_id: VertexId,
) -> GraphStoreResult<BTreeSet<String>>;
fn edge_graphs(&self, edge_id: EdgeId) -> GraphStoreResult<BTreeSet<String>>;
fn out_edge_ids(
&self,
vertex_id: VertexId,
graph: &str,
) -> GraphStoreResult<BTreeSet<EdgeId>>;
fn in_edge_ids(
&self,
vertex_id: VertexId,
graph: &str,
) -> GraphStoreResult<BTreeSet<EdgeId>>;
fn edge_ids_by_label(
&self,
label: &str,
graph: &str,
) -> GraphStoreResult<BTreeSet<EdgeId>>;
fn vertex_ids_in_graph(
&self,
graph: &str,
) -> GraphStoreResult<BTreeSet<VertexId>>;
fn degree_distribution(
&self,
graph: &str,
) -> GraphStoreResult<BTreeMap<VertexId, u64>>;
fn label_degree(&self, label: &str, graph: &str) -> GraphStoreResult<f64>;
fn vertex_label_counts(
&self,
graph: &str,
) -> GraphStoreResult<BTreeMap<String, u64>>;
fn get_vertex(
&self,
vertex_id: VertexId,
) -> GraphStoreResult<Option<Vertex>>;
fn get_edge(&self, edge_id: EdgeId) -> GraphStoreResult<Option<Edge>>;
fn next_vertex_id(&mut self) -> GraphStoreResult<VertexId>;
fn next_edge_id(&mut self) -> GraphStoreResult<EdgeId>;
fn clear(&mut self) -> GraphStoreResult<()>;
fn vertices(&self) -> GraphStoreResult<BTreeMap<VertexId, Vertex>>;
fn edges(&self) -> GraphStoreResult<BTreeMap<EdgeId, Edge>>;
// Provided methods
fn vertex_ids_by_label(
&self,
label: &str,
graph: &str,
) -> GraphStoreResult<Vec<VertexId>> { ... }
fn edges_by_label(
&self,
label: &str,
graph: &str,
) -> GraphStoreResult<Vec<Edge>> { ... }
fn vertex_id_page(
&self,
graph: &str,
after: Option<u64>,
limit: usize,
) -> GraphStoreResult<Vec<u64>> { ... }
fn edge_id_page(
&self,
graph: &str,
after: Option<u64>,
limit: usize,
) -> GraphStoreResult<Vec<u64>> { ... }
fn require_vertex_in_graph(
&self,
vertex_id: VertexId,
graph: &str,
) -> GraphStoreResult<()> { ... }
fn for_each_vertex_borrowed(
&self,
_ids: &[VertexId],
_visit: &mut dyn FnMut(VertexId, Option<&Vertex>) -> bool,
) -> GraphStoreResult<Option<usize>> { ... }
fn allocate_vertex_id(
&mut self,
_label: &str,
_graph: &str,
) -> GraphStoreResult<VertexId> { ... }
fn allocate_edge_id(
&mut self,
_label: &str,
_graph: &str,
) -> GraphStoreResult<EdgeId> { ... }
}Expand description
Storage interface for named property graphs.
Each store hosts zero or more named graphs that share a single vertex / edge id space (a vertex can belong to multiple graphs). Mutations are scoped to a target graph by name.
Required Methods§
Sourcefn transaction<T>(
&mut self,
operation: impl FnOnce(&mut Self) -> GraphStoreResult<T>,
) -> GraphStoreResult<T>where
Self: Sized,
fn transaction<T>(
&mut self,
operation: impl FnOnce(&mut Self) -> GraphStoreResult<T>,
) -> GraphStoreResult<T>where
Self: Sized,
Apply a group of mutations atomically. Persistent stores use a storage transaction or savepoint, never a cloned graph as a rollback image. Both errors and unwinding must restore the pre-operation state.
Sourcefn create_graph(&mut self, name: &str) -> GraphStoreResult<()>
fn create_graph(&mut self, name: &str) -> GraphStoreResult<()>
Create a new named graph. No-op if it already exists.
Sourcefn drop_graph(&mut self, name: &str) -> GraphStoreResult<()>
fn drop_graph(&mut self, name: &str) -> GraphStoreResult<()>
Drop a named graph and all of its membership entries. Vertex / edge records that aren’t referenced by any other graph become unreachable and are released.
Sourcefn graph_names(&self) -> GraphStoreResult<Vec<String>>
fn graph_names(&self) -> GraphStoreResult<Vec<String>>
Return all graph names sorted ascending.
fn has_graph(&self, name: &str) -> GraphStoreResult<bool>
Sourcefn union_graphs(
&mut self,
g1: &str,
g2: &str,
target: &str,
) -> GraphStoreResult<()>
fn union_graphs( &mut self, g1: &str, g2: &str, target: &str, ) -> GraphStoreResult<()>
target := g1 union g2 over vertex and edge sets.
Sourcefn intersect_graphs(
&mut self,
g1: &str,
g2: &str,
target: &str,
) -> GraphStoreResult<()>
fn intersect_graphs( &mut self, g1: &str, g2: &str, target: &str, ) -> GraphStoreResult<()>
target := g1 intersect g2.
Sourcefn difference_graphs(
&mut self,
g1: &str,
g2: &str,
target: &str,
) -> GraphStoreResult<()>
fn difference_graphs( &mut self, g1: &str, g2: &str, target: &str, ) -> GraphStoreResult<()>
target := g1 \ g2.
fn copy_graph(&mut self, source: &str, target: &str) -> GraphStoreResult<()>
fn add_vertex(&mut self, vertex: Vertex, graph: &str) -> GraphStoreResult<()>
fn add_edge(&mut self, edge: Edge, graph: &str) -> GraphStoreResult<()>
fn remove_vertex( &mut self, vertex_id: VertexId, graph: &str, ) -> GraphStoreResult<()>
fn remove_edge(&mut self, edge_id: EdgeId, graph: &str) -> GraphStoreResult<()>
Sourcefn neighbors(
&self,
vertex_id: VertexId,
label: Option<&str>,
direction: Direction,
graph: &str,
) -> GraphStoreResult<Vec<VertexId>>
fn neighbors( &self, vertex_id: VertexId, label: Option<&str>, direction: Direction, graph: &str, ) -> GraphStoreResult<Vec<VertexId>>
Neighbor vertex ids reached from vertex_id along edges with the
given label (or any label when label is None) in the given
direction.
fn vertices_by_label( &self, label: &str, graph: &str, ) -> GraphStoreResult<Vec<Vertex>>
fn vertices_in_graph(&self, graph: &str) -> GraphStoreResult<Vec<Vertex>>
fn edges_in_graph(&self, graph: &str) -> GraphStoreResult<Vec<Edge>>
fn vertex_graphs( &self, vertex_id: VertexId, ) -> GraphStoreResult<BTreeSet<String>>
fn edge_graphs(&self, edge_id: EdgeId) -> GraphStoreResult<BTreeSet<String>>
fn out_edge_ids( &self, vertex_id: VertexId, graph: &str, ) -> GraphStoreResult<BTreeSet<EdgeId>>
fn in_edge_ids( &self, vertex_id: VertexId, graph: &str, ) -> GraphStoreResult<BTreeSet<EdgeId>>
fn edge_ids_by_label( &self, label: &str, graph: &str, ) -> GraphStoreResult<BTreeSet<EdgeId>>
fn vertex_ids_in_graph( &self, graph: &str, ) -> GraphStoreResult<BTreeSet<VertexId>>
fn degree_distribution( &self, graph: &str, ) -> GraphStoreResult<BTreeMap<VertexId, u64>>
fn label_degree(&self, label: &str, graph: &str) -> GraphStoreResult<f64>
fn vertex_label_counts( &self, graph: &str, ) -> GraphStoreResult<BTreeMap<String, u64>>
Sourcefn get_vertex(&self, vertex_id: VertexId) -> GraphStoreResult<Option<Vertex>>
fn get_vertex(&self, vertex_id: VertexId) -> GraphStoreResult<Option<Vertex>>
Fetch one owned record. A storage implementation must not retain all entities merely to return a borrow, and I/O failures are not absence.
fn get_edge(&self, edge_id: EdgeId) -> GraphStoreResult<Option<Edge>>
Sourcefn next_vertex_id(&mut self) -> GraphStoreResult<VertexId>
fn next_vertex_id(&mut self) -> GraphStoreResult<VertexId>
Returns and advances the next available vertex id.
Sourcefn next_edge_id(&mut self) -> GraphStoreResult<EdgeId>
fn next_edge_id(&mut self) -> GraphStoreResult<EdgeId>
Returns and advances the next available edge id.
fn clear(&mut self) -> GraphStoreResult<()>
Provided Methods§
Sourcefn vertex_ids_by_label(
&self,
label: &str,
graph: &str,
) -> GraphStoreResult<Vec<VertexId>>
fn vertex_ids_by_label( &self, label: &str, graph: &str, ) -> GraphStoreResult<Vec<VertexId>>
Return only the vertex ids for a label. Stores with a label index should override this to avoid materializing full vertices.
Sourcefn edges_by_label(
&self,
label: &str,
graph: &str,
) -> GraphStoreResult<Vec<Edge>>
fn edges_by_label( &self, label: &str, graph: &str, ) -> GraphStoreResult<Vec<Edge>>
Read only edges carrying a label. Durable stores push this predicate into their physical label index before fetching any payloads.
Sourcefn vertex_id_page(
&self,
graph: &str,
after: Option<u64>,
limit: usize,
) -> GraphStoreResult<Vec<u64>>
fn vertex_id_page( &self, graph: &str, after: Option<u64>, limit: usize, ) -> GraphStoreResult<Vec<u64>>
Bounded ascending vertex identities, exclusively after the cursor. Durable stores override this with an indexed storage cursor.
Sourcefn edge_id_page(
&self,
graph: &str,
after: Option<u64>,
limit: usize,
) -> GraphStoreResult<Vec<u64>>
fn edge_id_page( &self, graph: &str, after: Option<u64>, limit: usize, ) -> GraphStoreResult<Vec<u64>>
Bounded ascending edge identities without materializing edge payloads.
Sourcefn require_vertex_in_graph(
&self,
vertex_id: VertexId,
graph: &str,
) -> GraphStoreResult<()>
fn require_vertex_in_graph( &self, vertex_id: VertexId, graph: &str, ) -> GraphStoreResult<()>
Require an explicit query vertex to be a live member of graph.
Implementations may override this with a cheaper membership lookup.
Missing query input is distinct from a valid vertex with no edges and
must not be reported as an empty neighborhood/path result.
Sourcefn for_each_vertex_borrowed(
&self,
_ids: &[VertexId],
_visit: &mut dyn FnMut(VertexId, Option<&Vertex>) -> bool,
) -> GraphStoreResult<Option<usize>>
fn for_each_vertex_borrowed( &self, _ids: &[VertexId], _visit: &mut dyn FnMut(VertexId, Option<&Vertex>) -> bool, ) -> GraphStoreResult<Option<usize>>
Visit requested vertices on the pinned view in caller order, retaining
duplicates and missing rows. The internal callback must not reenter
graph storage. Stop before reading another identity when it returns
false. None declines without invoking it; Some counts invocations.
Sourcefn allocate_vertex_id(
&mut self,
_label: &str,
_graph: &str,
) -> GraphStoreResult<VertexId>
fn allocate_vertex_id( &mut self, _label: &str, _graph: &str, ) -> GraphStoreResult<VertexId>
Allocate a vertex id for a new entity with label inside
graph. Stores that implement the Apache AGE graphid scheme
override this to return (label_id << 48) | sequence; the
default falls back to the store-wide counter.
Sourcefn allocate_edge_id(
&mut self,
_label: &str,
_graph: &str,
) -> GraphStoreResult<EdgeId>
fn allocate_edge_id( &mut self, _label: &str, _graph: &str, ) -> GraphStoreResult<EdgeId>
Allocate an edge id for a new entity with label inside
graph. See GraphStore::allocate_vertex_id.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".