use cpp interface instead of c API
mpetri opened this issue · comments
Having played with accessing faiss via the cxx crate it was reasonably straightforward to create interoperability between rust and faiss.
Is there a reason why the use of the C api is preferred for interacting with faiss?
There happens to be a combination of reasons for faiss-rs to be integrated this way.
The most obvious one is that cxx
did not exist back then. These bindings were first created in early 2018, and cxx
only became known in 2019, and a somewhat viable choice much later. The only other reasonable choice that could have been made back then was to try to bindgen
the C++ API directly, potentially with poor results when working with standard C++ containers and such.
Creating a C API for Faiss was an opportunity to fill in the gap while opening doors for other technologies to use Faiss without SWIG or trying to get along with C++. And since this works, there isn't a high enough benefit/cost ratio to justify a rewrite that would also influence the current expectations of the library. For such an idea to go through, there should be a somewhat smooth transition process, and/or it should retain the possibility of setting up all relevant build parameters from the main Faiss project.
You can read more into the process of creating faiss-rs in the blog posts "Taking the long road: bindings for a vector similarity search library", Part 1 & Part 2.
Thanks. Closing this issue.