Skip to content

Add static-geometry to h3indexset prefilter UDFs#131

Draft
estebanzimanyi wants to merge 1 commit into
feat/parity-th3indexfrom
feat/parity-h3-static-prefilter
Draft

Add static-geometry to h3indexset prefilter UDFs#131
estebanzimanyi wants to merge 1 commit into
feat/parity-th3indexfrom
feat/parity-h3-static-prefilter

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

Summary

Adds the two MobilityDuck UDFs that complete the h3 prefilter surface for trip × static-geometry cross-join queries (BerlinMOD Q4, Q7, Q11, Q12, Q15, Q17):

  • `geoToH3IndexSet(GEOMETRY, INTEGER) → H3INDEXSET` — covers POINT / LINESTRING / POLYGON / MULTI* / GeomCollection. Caller passes geometry in EPSG:4326.
  • `everIntersectsH3IndexSet_Th3Index(H3INDEXSET, TH3INDEX) → BOOLEAN` — true when the trajectory's H3 cell sequence ever equals any cell of the static set.

`H3INDEXSET` is a new logical type (alias on `BLOB`), storing a serialized MEOS `Set`.

Stacks on PR #129 (the th3index core).

Validation

BerlinMOD scalefactor 0.005 on a single-node DuckDB build, Q7-style intersection (every trip × every QueryPoint):

Variant Wall time
`ST_Intersects(trajectory(t.trip), p.geom)` baseline 0.517 s
Same predicate with `everIntersectsH3IndexSet_Th3Index` prefilter 0.076 s
Speedup 6.8×

Test plan

  • CI green on the org repo matrix
  • Smoke test on BerlinMOD sf 0.005 — h3 prefilter cuts the Q7-shape cross-join wall time from 0.517 s to 0.076 s

H3INDEXSET is a Set<H3INDEX> blob built from a static geometry at a
given H3 resolution.  Two new UDFs:

- geoToH3IndexSet(GEOMETRY, INTEGER) returns H3INDEXSET — covers
  POINT, LINESTRING, POLYGON, MULTI*, and GeomCollection input.
  Caller passes geometry in EPSG:4326 (e.g. ST_Transform).
- everIntersectsH3IndexSet_Th3Index(H3INDEXSET, TH3INDEX) returns
  BOOLEAN — true when the trajectory ever passes through any cell
  of the static set.

These accelerate the trip x static cross-join queries (BerlinMOD Q4,
Q7, Q11, Q12, Q15, Q17 on the bench).  Q7-style intersection on
BerlinMOD sf 0.005: 0.517 s without prefilter, 0.076 s with the
prefilter (6.8x).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant