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
// SPDX-License-Identifier: BUSL-1.1
//! Spatial engine operations dispatched to the Data Plane.
use nodedb_types::{SurrogateBitmap, geometry::Geometry};
/// Spatial predicate type for R-tree index scan.
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
serde::Serialize,
serde::Deserialize,
zerompk::ToMessagePack,
zerompk::FromMessagePack,
)]
#[msgpack(c_enum)]
pub enum SpatialPredicate {
/// ST_DWithin: geometry within distance (meters).
DWithin,
/// ST_Contains: query geometry contains document geometry.
Contains,
/// ST_Intersects: query geometry intersects document geometry.
Intersects,
/// ST_Within: document geometry is within query geometry.
Within,
}
/// Spatial engine physical operations.
#[derive(
Debug,
Clone,
PartialEq,
serde::Serialize,
serde::Deserialize,
zerompk::ToMessagePack,
zerompk::FromMessagePack,
)]
pub enum SpatialOp {
/// R-tree index scan with spatial predicate and exact refinement.
Scan {
collection: String,
field: String,
predicate: SpatialPredicate,
/// Typed query geometry, parsed and validated on the Control Plane.
query_geometry: Geometry,
/// Distance threshold in meters (for ST_DWithin). 0 for non-distance predicates.
distance_meters: f64,
/// Additional attribute filters applied after spatial candidates.
attribute_filters: Vec<u8>,
limit: usize,
projection: Vec<String>,
/// RLS post-candidate filters.
rls_filters: Vec<u8>,
/// Optional surrogate prefilter injected by a cross-engine sub-plan.
/// When present, only candidates whose surrogate is in this bitmap
/// are returned. `None` = no prefilter; all R-tree candidates pass.
prefilter: Option<SurrogateBitmap>,
},
}