Skip to content

Fix IndexIDMap2::reset() leaving stale rev_map entries - #5615

Open
madhukar6143 wants to merge 1 commit into
facebookresearch:mainfrom
madhukar6143:fix-idmap2-reset-revmap
Open

madhukar6143 wants to merge 1 commit into
facebookresearch:mainfrom
madhukar6143:fix-idmap2-reset-revmap

Conversation

@madhukar6143

Copy link
Copy Markdown

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.

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>
@meta-cla meta-cla Bot added the CLA Signed label Sep 9, 2026

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexIDMap2::reset leaves stale reverse-map entries

1 participant