Fix IndexIDMap2::reset() leaving stale rev_map entries - #5615
Open
madhukar6143 wants to merge 1 commit into
Open
madhukar6143 wants to merge 1 commit into
madhukar6143 wants to merge 1 commit into
Conversation
IndexIDMap2Template inherited IndexIDMapTemplate::reset(), which clears the sub-index, id_map and ntotal but not the rev_map. After reset() and a re-add with new IDs, the stale rev_map entries made removed external IDs still reconstructable (resolving to unrelated new vectors), and check_consistency() failed because rev_map.size() != id_map.size() (facebookresearch#5578). Override reset() in IndexIDMap2Template to clear rev_map after the base reset(). This covers both IndexIDMap2 and IndexBinaryIDMap2. Add test_reset_id_map: after reset() and re-add, a removed ID no longer reconstructs, the new ID reconstructs correctly, and check_consistency() passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IndexIDMap2Template inherited IndexIDMapTemplate::reset(), which clears the sub-index, id_map and ntotal but not the rev_map. After reset() and a re-add with new IDs, the stale rev_map entries made removed external IDs still reconstructable (resolving to unrelated new vectors), and check_consistency() failed because rev_map.size() != id_map.size() (Fixes #5578).
Override reset() in IndexIDMap2Template to clear rev_map after the base reset(). This covers both IndexIDMap2 and IndexBinaryIDMap2.
Add test_reset_id_map: after reset() and re-add, a removed ID no longer reconstructs, the new ID reconstructs correctly, and check_consistency() passes.