-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why &mut self for fn search in trait Index #11
Comments
A mutable reference to the index is required to comply with the thread safety guarantees of index implementations. In particular, an index of an unknown implementation is not guaranteed to be thread safe, even for searching. While the native Faiss API (and by consequence the C API) are more lenient on this matter by letting this operation be performed over a const reference, Rust has stricter aliasing requirements which are leveraged here to prevent data races at compile-time. In general, you are advised to follow the guidelines for concurrent index searching in the wiki page above. Since they are already backed by multiple threads internally, calling |
Thanks. https://docs.rs/faiss/0.9.0/faiss/index/trait.ConcurrentIndex.html How can I split results for 2 different queries from SearchResult struct? |
The API is currently a bit thin here, but the logic is the same as in the native API: in |
Thanks! |
Hello.
Faiss binding required only
*const FaissIndex
https://github.com/Enet4/faiss-rs/blob/master/faiss-sys/src/bindings.rs#L108
but here
&mut self
https://github.com/Enet4/faiss-rs/blob/master/src/macros.rs#L71
https://github.com/Enet4/faiss-rs/blob/master/src/macros.rs#L76
The text was updated successfully, but these errors were encountered: