Repository navigation
test: failing test for values_per_hash drift on duplicate geo point removal - #9043
Conversation
…nt removal Reproduces the bug where `remove_point` only calls `decrement_hash_value_counts` once per unique geohash, while `add_many_geo_points` increments it once per value. When a point has duplicate geo coordinates (same geohash), the counters drift upward permanently after removal. Ref: #9033 (comment) Co-authored-by: Cursor <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR changes InMemoryGeoMapIndex::remove_point to decrement per-hash value counters for every removed geo value (including duplicates sharing the same GeoHash) and adds a regression test that inserts a point with three identical geo coordinates, removes it, and asserts point/value counts, root geohash value counts, and geo-radius cardinality estimation are zero for the empty index. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`add_many_geo_points` increments `values_per_hash` once per value, but `remove_point` deduplicated geohashes with a HashSet + `continue` that also skipped the per-value decrement. A point with duplicate geo coordinates (same geohash) therefore left the counters drifted upward permanently after removal. Move `decrement_hash_value_counts` above the dedup guard so it runs once per value, matching the increment side. `points_map` and `points_per_hash` track points, not values, so they stay deduplicated. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…emoval (#9043) * test: add failing test for values_per_hash drift on duplicate geo point removal Reproduces the bug where `remove_point` only calls `decrement_hash_value_counts` once per unique geohash, while `add_many_geo_points` increments it once per value. When a point has duplicate geo coordinates (same geohash), the counters drift upward permanently after removal. Ref: #9033 (comment) Co-authored-by: Cursor <[email protected]> * fix: decrement values_per_hash once per value on geo point removal `add_many_geo_points` increments `values_per_hash` once per value, but `remove_point` deduplicated geohashes with a HashSet + `continue` that also skipped the per-value decrement. A point with duplicate geo coordinates (same geohash) therefore left the counters drifted upward permanently after removal. Move `decrement_hash_value_counts` above the dedup guard so it runs once per value, matching the increment side. `points_map` and `points_per_hash` track points, not values, so they stay deduplicated. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: generall <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
InMemoryGeoMapIndex::remove_point:decrement_hash_value_countsis called only once per unique geohash, whileadd_many_geo_pointsincrementsvalues_per_hashonce per value. When a point has duplicate geo coordinates (producing the same geohash), the counters drift upward permanently after deletion.values_of_hashreturns 0 for the root hash. Currently it returns 2 (3 increments - 1 decrement = 2 leftover).Context
Identified in review: #9033 (comment)
The fix would be to call
decrement_hash_value_countsfor every value before the uniqueness check inremove_point, moving it above theif !removed_geo_hashes.insert(...)guard (while keepingpoints_mapcleanup anddecrement_hash_point_countsper unique hash only).Test plan
dev(demonstrates the bug)Made with Cursor