Skip to content

Commit e0e3fe7

Browse files
committed
Execute spatial predicates with RowFn
Signed-off-by: Connor Tsui <[email protected]>
1 parent 350ab9d commit e0e3fe7

8 files changed

Lines changed: 854 additions & 448 deletions

File tree

‎Cargo.toml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,13 @@ flatbuffers = "25.2.10"
162162
fsst-rs = "0.6.0"
163163
futures = { version = "0.3.31", default-features = false }
164164
fuzzy-matcher = "0.3"
165-
geo = "0.31.0"
165+
# `vortex-spatial`'s `contains_route` transcribes geo's `impl_contains_from_relate!` dispatch
166+
# table, so any bump that moves a row silently changes containment verdicts. The tests stay green
167+
# wherever relate and the direct algorithm agree. Pinned exactly so that taking any new geo,
168+
# patch releases included, is a deliberate edit of this line that re-verifies the table; a caret
169+
# requirement would let `cargo update` (or automated lockfile maintenance) take 0.31.x with no diff
170+
# to review. See `vortex-spatial/src/scalar_fn/contains.rs`.
171+
geo = "=0.31.0"
166172
geo-traits = "0.3.0"
167173
geo-types = "0.7.19"
168174
geoarrow = "0.8.0"

‎vortex-spatial/benches/binary_predicates.rs‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
//! column-x-column arms are the control: no operand is constant, so a prepared path has nothing to
1313
//! hoist and must not regress them.
1414
//!
15-
//! `contains` has no all-overlapping arm. One `contains(query polygon, contained square)` row
16-
//! builds a topology graph over the constant's 128 edges, which CodSpeed's CPU simulation charges
17-
//! around 120 µs, so no row count both fits the per-iteration budget and exercises the row loop.
18-
//! [`intersects::polygons_overlapping_x_constant`] covers the never-rejects case instead.
19-
//!
2015
//! Run with `cargo bench -p vortex-spatial --bench binary_predicates`.
2116
2217
#![expect(clippy::unwrap_used)]
@@ -64,6 +59,10 @@ const ROWS: usize = 1 << 5;
6459
/// pairwise predicate. It needs a smaller fixture than [`ROWS`] to stay inside the same budget.
6560
const OVERLAPPING_POLYGON_ROWS: usize = 1 << 4;
6661

62+
/// Containment builds a topology graph for each polygon pair. Four rows fit the benchmark budget
63+
/// while exercising construction followed by reuse of the prepared constant geometry.
64+
const CONTAINED_POLYGON_ROWS: usize = 4;
65+
6766
/// Deterministic pseudo-random value in `[0, 1)`.
6867
fn unit(i: usize) -> f64 {
6968
((i.wrapping_mul(2654435761) >> 8) % 10_000) as f64 / 10_000.0
@@ -225,6 +224,23 @@ mod contains {
225224
});
226225
}
227226

227+
/// Constant container against contained polygons: every bbox check passes, the first row
228+
/// prepares the constant geometry, and the remaining rows reuse it for the full predicate.
229+
#[divan::bench]
230+
fn constant_x_polygons_overlapping(bencher: Bencher) {
231+
let mut ctx = SESSION.create_execution_ctx();
232+
let query = query_constant(&mut ctx, CONTAINED_POLYGON_ROWS);
233+
let polygons = squares_mostly_overlapping(CONTAINED_POLYGON_ROWS);
234+
bencher
235+
.counter(ItemsCount::new(CONTAINED_POLYGON_ROWS))
236+
.bench_local(|| {
237+
execute(
238+
SpatialContains::try_new_array(query.clone(), polygons.clone()),
239+
&mut ctx,
240+
)
241+
});
242+
}
243+
228244
/// Constant container against a point column with one null row in eight.
229245
#[divan::bench]
230246
fn constant_x_nullable_points(bencher: Bencher) {

0 commit comments

Comments
 (0)