Skip to content

Add in-memory spatial grid index for point queries - #10

Merged
progys merged 1 commit into
masterfrom
feat-in-memory-spatial-index
Aug 15, 2026
Merged

progys merged 1 commit into
masterfrom
feat-in-memory-spatial-index

Conversation

@progys

@progys progys commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Summary

Point queries currently scan every stored shape (in parallel). This PR narrows the candidate set with an in-memory uniform-grid index over shape bounding boxes (broad phase), then refines with inShape in parallel.

Changes

  • ShapeIndex: uniform grid keyed by packed cell coordinates; a query checks only the cell containing the point. Shapes spanning more than 64 cells are kept in an overflow list checked by every query, bounding index memory for very large shapes.
  • BoundingBox value type; getBounds() added to the sealed Shape hierarchy (circle/donut/triangle).
  • Store gains queryContaining(Point); ObjectStore keeps the index in sync with put/clear and rebuilds it from the DB on startup.
  • PointCommand queries through the index; output order stays deterministic (encounter order of the parallel stream is preserved).
  • Tests: ShapeIndexTest (cell lookup, multi-cell overlap, overflow bucket, determinism, clear) + ObjectStoreTest query test + updated PointCommandTest.

Verification

  • 58/58 tests green (mvn clean test).
  • E2E: point query on shapes via exec:java returns the containing shapes.

Point queries now narrow the candidate set via a uniform-grid index over
shape bounding boxes (broad phase) instead of scanning every stored shape,
then refine with inShape in parallel. Shapes spanning more than 64 cells are
kept in an overflow list to bound index memory. Adds BoundingBox value type
and getBounds() to the sealed Shape hierarchy; Store gains queryContaining().
@cursor

cursor Bot commented Aug 15, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@progys
progys merged commit da417df into master Aug 15, 2026
4 checks passed
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