1use crate::error::Result;
2use crate::types::*;
3use std::collections::HashMap;
4
5pub trait RelationalExecutor: Send + Sync {
6 fn scan(&self, table: &str, snapshot: SnapshotId) -> Result<Vec<VersionedRow>>;
7 fn scan_filter(
8 &self,
9 table: &str,
10 snapshot: SnapshotId,
11 predicate: &dyn Fn(&VersionedRow) -> bool,
12 ) -> Result<Vec<VersionedRow>>;
13 fn point_lookup(
14 &self,
15 table: &str,
16 col: &str,
17 value: &Value,
18 snapshot: SnapshotId,
19 ) -> Result<Option<VersionedRow>>;
20 fn insert(&self, tx: TxId, table: &str, values: HashMap<ColName, Value>) -> Result<RowId>;
21 fn upsert(
22 &self,
23 tx: TxId,
24 table: &str,
25 conflict_col: &str,
26 values: HashMap<ColName, Value>,
27 snapshot: SnapshotId,
28 ) -> Result<UpsertResult>;
29 fn delete(&self, tx: TxId, table: &str, row_id: RowId) -> Result<()>;
30}
31
32pub trait GraphExecutor: Send + Sync {
33 fn bfs(
34 &self,
35 start: NodeId,
36 edge_types: Option<&[EdgeType]>,
37 direction: Direction,
38 min_depth: u32,
39 max_depth: u32,
40 snapshot: SnapshotId,
41 ) -> Result<TraversalResult>;
42 #[allow(clippy::type_complexity)]
43 fn neighbors(
44 &self,
45 node: NodeId,
46 edge_types: Option<&[EdgeType]>,
47 direction: Direction,
48 snapshot: SnapshotId,
49 ) -> Result<Vec<(NodeId, EdgeType, HashMap<String, Value>)>>;
50 fn insert_edge(
51 &self,
52 tx: TxId,
53 source: NodeId,
54 target: NodeId,
55 edge_type: EdgeType,
56 properties: HashMap<String, Value>,
57 ) -> Result<bool>;
58 fn delete_edge(&self, tx: TxId, source: NodeId, target: NodeId, edge_type: &str) -> Result<()>;
59}
60
61pub trait VectorExecutor: Send + Sync {
62 fn search(
63 &self,
64 query: &[f32],
65 k: usize,
66 candidates: Option<&roaring::RoaringTreemap>,
67 snapshot: SnapshotId,
68 ) -> Result<Vec<(RowId, f32)>>;
69 fn insert_vector(&self, tx: TxId, row_id: RowId, vector: Vec<f32>) -> Result<()>;
70 fn delete_vector(&self, tx: TxId, row_id: RowId) -> Result<()>;
71}
72
73pub trait TransactionManager: Send + Sync {
74 fn begin(&self) -> TxId;
75 fn commit(&self, tx: TxId) -> Result<()>;
76 fn rollback(&self, tx: TxId) -> Result<()>;
77 fn snapshot(&self) -> SnapshotId;
78}