feat(vortex-geo): geometry Bbox zone-map statistic + distance-filter pruning#8646
feat(vortex-geo): geometry Bbox zone-map statistic + distance-filter pruning#8646HarukiMoriarty wants to merge 1 commit into
Bbox zone-map statistic + distance-filter pruning#8646Conversation
Merging this PR will not alter performance
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
9b5a017 to
4274729
Compare
…-filter pruning Add a `GeometryBounds` aggregate that computes a per-chunk 2D minimum bounding rectangle (`Struct<xmin, ymin, xmax, ymax>`) for native geometry columns and stores it as a zone-map statistic, plus a `GeoDistanceBoundsPrune` stats-rewrite rule that skips a chunk when its MBR is disjoint from a `GeoDistance(geom, const) <= r` query box. - vortex-array: aggregates self-declare as default zone stats via a `zone_stat_default` vtable/plugin hook; the zoned writer discovers them from the session registry in deterministic (id-sorted) order. - vortex-geo: `GeometryBounds` covers every native geometry type. All native storage is `List^n<Struct<x, y, ..>>`, so `flatten_coordinates` peels the `List` levels to reach the vertices without per-type dispatch. The prune rule guards on `is_native_geometry`, ignores a NaN radius, and only handles the near forms `<=` / `<`; its `geometry_and_constant` / `disjoint_proof` helpers are the shared toolkit future spatial predicates (intersects, contains) reuse, documented in the prune module. Missing stats bind to null, so older files degrade to no pruning. - vortex-bench: Morton-sort each generated SpatialBench table by its geometry column's bounding-box center so every lane (parquet, vortex-WKB, vortex-geo-native) reads spatially-clustered data and the zone-map prune can actually skip chunks. Idempotent via a parquet marker; stale derived vortex files from pre-sort parquet are deleted so the existence-keyed conversions regenerate. Signed-off-by: Nemo Yu <zyu379@wisc.edu>
4274729 to
bda1557
Compare
| /// The default per-chunk zone statistic to store for a column of `input_dtype`, or `None` if | ||
| /// this aggregate isn't one. |
There was a problem hiding this comment.
Nit: this is kind of hard to understand, maybe say something like this or similar:
/// The default zone statistic (per-chunk) for a column of `input_dtype`,
/// or `None` if the dtype is not supported.
```rust
connortsui20
left a comment
There was a problem hiding this comment.
Seems fine to me, but someone who has worked on aggregates and stats more should probably review this
Summary
Adds spatial chunk-pruning to Vortex. A new
GeometryBoundsaggregate stores a per-chunk minimum bounding box (MBR) as a zone-map statistic, and a stats-rewrite rule uses it to skip chunks that cannot satisfy aST_Distance(geom, const) <= rfilter.Limitation
<=/<are pruned.>/>=are soundly prunable via the symmetric farthest-corner bound but are intentionally omitted (rarely?)Testing
8 new vortex-geo tests. Point bbox across batches; Polygon bbox over all ring vertices, empty group → null, and registry self-declaration. only <=/< prune while >/>=/==/!= don't (parameterized), distance symmetry, non-distance comparisons ignored, and an end-to-end falsify.
Performance
SF=1
SF=3
SF=10
Takeaway: when the data is pre-sorted, the bounding box pruning can significantly reduce the intermediate results DuckDB read in, make Q1 and Q3 significantly faster