Skip to main content

relate_executor/graph/
engine_api.rs

1//! The in-memory graph as the snapshot contract other crates call.
2
3use std::collections::HashSet;
4
5use relate_catalog::{ConstraintDef, IndexDef};
6use relate_core::{Node, NodeId, RelId, Relationship, Result};
7use relate_engine_api::{CheckpointTheater, GraphExport, GraphImport, RedoOp};
8use relate_model::Constraint;
9
10use super::Graph;
11
12impl GraphExport for Graph {
13    fn commit_ts(&self) -> u64 {
14        Graph::commit_ts(self)
15    }
16    fn next_node_id(&self) -> i64 {
17        Graph::next_node_id(self)
18    }
19    fn next_rel_id(&self) -> i64 {
20        Graph::next_rel_id(self)
21    }
22    fn live_node_count(&self) -> usize {
23        Graph::live_node_count(self)
24    }
25    fn dirty_node_ids(&self) -> HashSet<NodeId> {
26        Graph::dirty_node_ids(self)
27    }
28    fn dirty_rel_ids(&self) -> HashSet<RelId> {
29        Graph::dirty_rel_ids(self)
30    }
31    fn all_node_ids_at(&self, ts: u64) -> Vec<NodeId> {
32        Graph::all_node_ids_at(self, ts)
33    }
34    fn all_rel_ids_at(&self, ts: u64) -> Vec<RelId> {
35        Graph::all_rel_ids_at(self, ts)
36    }
37    fn node_at(&self, id: NodeId, ts: u64) -> Option<Node> {
38        Graph::node_at(self, id, ts)
39    }
40    fn rel_at(&self, id: RelId, ts: u64) -> Option<Relationship> {
41        Graph::rel_at(self, id, ts)
42    }
43    fn node_checkpoint_bytes(&self, id: NodeId, ts: u64) -> Result<Option<u64>> {
44        Graph::node_checkpoint_bytes(self, id, ts)
45    }
46    fn rel_checkpoint_bytes(&self, id: RelId, ts: u64) -> Result<Option<u64>> {
47        Graph::rel_checkpoint_bytes(self, id, ts)
48    }
49    fn named_indexes(&self) -> Vec<IndexDef> {
50        Graph::named_indexes(self)
51    }
52    fn named_constraints(&self) -> Vec<ConstraintDef> {
53        Graph::named_constraints(self)
54    }
55    fn checkpoint_theater_for_write(&self) -> Result<CheckpointTheater> {
56        Graph::checkpoint_theater_for_write(self)
57    }
58    fn graph_type_spec(&self) -> Result<Option<String>> {
59        Graph::graph_type_spec(self)
60    }
61    fn clear_checkpoint_dirty(&self) {
62        Graph::clear_checkpoint_dirty(self)
63    }
64    fn catalog_ddl(&self) -> Vec<String> {
65        crate::catalog_create_statements(self)
66    }
67}
68
69impl GraphImport for Graph {
70    fn set_next_node_id(&self, id: i64) {
71        Graph::set_next_node_id(self, id)
72    }
73    fn set_next_rel_id(&self, id: i64) {
74        Graph::set_next_rel_id(self, id)
75    }
76    fn set_commit_ts(&self, ts: u64) {
77        Graph::set_commit_ts(self, ts)
78    }
79    fn install_named_index(&self, index: IndexDef) -> Result<()> {
80        Graph::install_named_index(self, index)
81    }
82    fn install_named_constraint(&self, constraint: ConstraintDef) -> Result<()> {
83        Graph::install_named_constraint(self, constraint)
84    }
85    fn restore_checkpoint_theater(&self, theater: CheckpointTheater) -> Result<()> {
86        Graph::restore_checkpoint_theater(self, theater)
87    }
88    fn mark_legacy_unenforced(&self) {
89        Graph::mark_legacy_unenforced(self)
90    }
91    fn finish_restore(&self) {
92        Graph::finish_restore(self)
93    }
94    fn load_checkpoint_nodes(&self, nodes: &[Node]) -> Result<()> {
95        Graph::load_checkpoint_nodes(self, nodes)
96    }
97    fn load_checkpoint_rels(&self, rels: &[Relationship]) -> Result<()> {
98        Graph::load_checkpoint_rels(self, rels)
99    }
100    fn apply_replayed_redo(&self, ops: Vec<RedoOp>, commit_ts: u64) -> Result<()> {
101        Graph::apply_replayed_redo(self, ops, commit_ts)
102    }
103    fn rebuild_indexes(&self) {
104        Graph::rebuild_indexes(self)
105    }
106    fn restore_graph_type_spec(&self, spec: Option<&str>) -> Result<()> {
107        Graph::restore_graph_type_spec(self, spec)
108    }
109    fn restore_legacy_enforced_constraints(&self, constraints: Vec<Constraint>) -> Result<()> {
110        Graph::restore_legacy_enforced_constraints(self, constraints)
111    }
112}