1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! Document / sparse engine operations dispatched to the Data Plane.
/// Document engine physical operations (schemaless + strict + DML).
#[derive(Debug, Clone)]
pub enum DocumentOp {
/// Point lookup by document ID.
PointGet {
collection: String,
document_id: String,
/// RLS post-fetch filters (serialized `Vec<ScanFilter>`).
/// If non-empty, the Data Plane evaluates these after fetching
/// the document. Returns `NOT_FOUND` on denial (no info leak).
/// Injected by the Control Plane planner from RLS policies.
#[allow(clippy::doc_markdown)]
rls_filters: Vec<u8>,
},
/// Point write: insert/update a document.
PointPut {
collection: String,
document_id: String,
value: Vec<u8>,
},
/// Point delete: remove a document.
PointDelete {
collection: String,
document_id: String,
},
/// Point update: read-modify-write with field-level changes.
PointUpdate {
collection: String,
document_id: String,
/// Field name → new JSON value.
updates: Vec<(String, Vec<u8>)>,
},
/// Full collection scan with filtering, sorting, and pagination.
Scan {
collection: String,
limit: usize,
offset: usize,
sort_keys: Vec<(String, bool)>,
/// Filter predicates serialized as JSON.
filters: Vec<u8>,
distinct: bool,
projection: Vec<String>,
/// Serialized `Vec<ComputedColumn>`.
computed_columns: Vec<u8>,
/// Serialized `Vec<WindowFuncSpec>`.
window_functions: Vec<u8>,
},
/// Batch insert documents in a single redb transaction.
BatchInsert {
collection: String,
/// (document_id, value_bytes) pairs.
documents: Vec<(String, Vec<u8>)>,
},
/// Range scan on a sparse/metadata index.
RangeScan {
collection: String,
field: String,
lower: Option<Vec<u8>>,
upper: Option<Vec<u8>>,
limit: usize,
},
/// Register collection with secondary index paths (DDL).
Register {
collection: String,
index_paths: Vec<String>,
crdt_enabled: bool,
},
/// Lookup documents by secondary index value.
IndexLookup {
collection: String,
path: String,
value: String,
},
/// Drop all secondary index entries for a field.
DropIndex { collection: String, field: String },
/// Truncate: delete ALL documents in a collection.
Truncate { collection: String },
/// Estimate count via HLL cardinality stats.
EstimateCount { collection: String, field: String },
/// INSERT ... SELECT: copy documents from source to target.
InsertSelect {
target_collection: String,
source_collection: String,
source_filters: Vec<u8>,
source_limit: usize,
},
/// Upsert: insert or merge.
Upsert {
collection: String,
document_id: String,
value: Vec<u8>,
},
/// Bulk update: scan + apply field updates to all matches.
BulkUpdate {
collection: String,
filters: Vec<u8>,
updates: Vec<(String, Vec<u8>)>,
},
/// Bulk delete: scan + delete all matches.
BulkDelete {
collection: String,
filters: Vec<u8>,
},
}