Strengthen arguments to robust_prune. - #1358
Strengthen arguments to robust_prune.#1358Mark Hildebrand (hildebrandmw) wants to merge 5 commits into
robust_prune.#1358Conversation
There was a problem hiding this comment.
Pull request overview
This PR strengthens the graph::internal::prune::robust_prune API by requiring its candidate input to be a SortedNeighbors, making the sorted-by-distance invariant structural rather than a debug assertion. It also removes the lingering Eq bound from SortedNeighbors (left over from #1273) and introduces a SortedNeighbors::map_in helper to project a sorted neighbor list into another storage buffer while preserving sortedness.
Changes:
- Change
robust_pruneto acceptSortedNeighbors<'_, Option<V>>instead of a raw&[(f32, Option<V>)], removing the runtime sortedness assertion. - Refactor
SortedNeighborsto drop theEqbound and addmap_into project IDs into a separate, linearly accessible cache while preserving order. - Extend
VerboseEqsupport in tests (notably forstrand references).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| diskann/src/test/cmp.rs | Adds VerboseEq impl for references and expands leaf VerboseEq coverage (incl. str). |
| diskann/src/graph/internal/sorted_neighbors.rs | Drops Eq constraint, makes SortedNeighbors Copy/Clone, adds map_in, and adds tests for mapping behavior. |
| diskann/src/graph/internal/prune.rs | Updates robust_prune to accept SortedNeighbors candidates and adapts indexing/lookup logic accordingly. |
| diskann/src/graph/index.rs | Uses SortedNeighbors::map_in to build the prune candidate cache and updates the robust_prune call site. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| impl<T> VerboseEq for &T | ||
| where | ||
| T: VerboseEq + ?Sized, | ||
| { | ||
| fn verbose_eq(&self, other: &Self) -> ANNResult<()> { | ||
| (*self).verbose_eq(*other) | ||
| } | ||
| } |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1358 +/- ##
==========================================
- Coverage 91.55% 91.55% -0.01%
==========================================
Files 521 521
Lines 100371 100410 +39
==========================================
+ Hits 91898 91927 +29
- Misses 8473 8483 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Make the
sorted_cacheargument aSortedNeighborsinstead to structurally require sortedness. This removes theEqbound fromSortedNeighbors, which is left over from #1273, and provides a helpermap_infor projectingSortedNeighbors.