Skip to content

feat(cache): add geographic indexes and nearest-point queries - #1415

Open
zhangzhenghao wants to merge 9 commits into
masterfrom
feat/cache-geo-index
Open

zhangzhenghao wants to merge 9 commits into
masterfrom
feat/cache-geo-index

Conversation

@zhangzhenghao

@zhangzhenghao zhangzhenghao commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add explicit AddGeoIndex / DeleteGeoIndex lifecycle to cache storage, with independent tables/collections per named index.
  • Persist geographic points and query nearest N points with optional maximum distance using a shared Morton range index and spherical distance ordering.
  • Support SQLite, MySQL/MariaDB, PostgreSQL, MongoDB, Redis/Redis Cluster, NoDatabase, and cache gRPC proxy.
  • Keep original coordinates for distance calculations; handle poles and the antimeridian without requiring PostGIS or native GIS extensions.

Validation

  • Passed: GOMAXPROCS=2 go build -p 1 ./storage/cache ./protocol.
  • Passed: git diff --check and independent specification/code-quality source reviews.
  • Passed: full-project compilation with GOMAXPROCS=2 go build -p 1 ./....
  • The cache/protocol packages were also rebuilt successfully after the final source-review fixes.
  • No tests added or run, as explicitly requested.

Semantics

  • Create the named index before point operations. Existing indexes return ErrAlreadyExists; missing indexes return ErrNotFound for point operations.
  • Results use distance in meters, ascending, with ID byte order as the tie-breaker.
  • Queries provide exact spherical Top-N for a static dataset, not a cross-request snapshot under concurrent updates.
  • Index lifecycle changes must be coordinated across processes. In-process SQL/MongoDB lifecycle changes are serialized against point operations; no distributed DDL lock is introduced.
  • No item/user coordinate synchronization or public REST API is introduced.

@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.47253% with 296 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.67%. Comparing base (24e22a8) to head (71c6756).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
storage/cache/sql.go 58.84% 100 Missing ⚠️
storage/cache/mongodb.go 56.25% 98 Missing ⚠️
storage/cache/proxy.go 46.29% 58 Missing ⚠️
storage/cache/database.go 88.70% 21 Missing ⚠️
storage/cache/redis.go 86.71% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1415      +/-   ##
==========================================
- Coverage   78.37%   77.67%   -0.71%     
==========================================
  Files          93       90       -3     
  Lines       16667    17339     +672     
==========================================
+ Hits        13063    13468     +405     
- Misses       3604     3871     +267     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

2 participants