Files
faiss/tests
Alibek Zhakubayev d380b7d96c Fix IndexFlatCodes::reset on mmap-loaded codes (#5707)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5707

`IndexFlatCodes::reset()` called `codes.clear()`. When the index was read with `IO_FLAG_MMAP_IFC` (or through a zero-copy reader), `codes` is a non-owning view, and `MaybeOwnedVector::clear()` asserts `is_owned`, so `reset()` aborted the process. This hits `IndexFlat`, `IndexScalarQuantizer` and every index that resets a flat-codes storage, e.g. `IndexHNSWFlat` and `IndexNSGFlat`.

`reset()` now keeps `clear()` for owned codes (capacity is kept, as before) and replaces a view with an empty owned vector. The index can then be refilled with `add()`.

___

Differential Revision: D123073895

fbshipit-source-id: 892e07eaa81d0176e34769714292c036c772a4d7
2026-10-05 11:01:07 -07:00
..
2026-05-01 09:55:55 -07:00