Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4762
Some search functions require special handling on the search resutls. For example collecting resutls from diverse groups.
In order to support this, we re-purpose the ResultHandler object to offer an arbitrary callback whenever a new vector should be taken in consideration.
Many indexes did already have such a callback, but in non-uniform formats. This diff consolidates these diverse implementations. This is especially the case for the InvertedListScanner that is now implemented on top of that.
Most indexes now get a `search1` that searches one query vector and takes a ResultCollector as input. This is the object that can be used a a callback to do specific handling on the results.
The current impleentatoin of search1 may not be perfectly optimized, especially for IndexFlatCodes indexes. Another todo is to support BlockResultHandlers to allow multiple queries at a time.
Differential Revision: D91003349
fbshipit-source-id: 3ce98145f9633174bd3d84bb1ae85f36084e41ce