Enet4 / faiss-rs

Rust language bindings for Faiss
Apache License 2.0
202 stars 36 forks source link

read_index io flag support #49

Closed mooreniemi closed 2 years ago

mooreniemi commented 2 years ago

Reading Faiss documentation and related issues:

A standard index can be memory-mapped as an on-disk index with using the I/O flag IO_FLAG_MMAP. This makes it possible to load many indexes that would not otherwise fit in RAM.

So I wanted to send an I/O flag in to read_index, as in this example.

But currently, that doesn't appear possible with this crate's read_index method. Am I missing some other way of accomplishing this? Would you accept a PR to make available?

Enet4 commented 2 years ago

Hmm yes, I suppose this was either an oversight or a wish to keep things simple back then. In any case, a pull request for a function read_index_with_flags and a safe IoFlag abstraction would be appreciated.

mooreniemi commented 2 years ago

K I will send PR. Is it expected binding generation wouldn't catch these consts? I will recreate them manually unless they should be generated automatically somehow already.

https://github.com/facebookresearch/faiss/blob/151e3d7be54aec844b6328dc3e7dd0b83fcfa5bc/faiss/index_io.h#L46

Ah I see I should be checking the c_api, right. So this:

https://github.com/facebookresearch/faiss/blob/main/c_api/index_io_c.h#L34

mooreniemi commented 2 years ago

https://github.com/Enet4/faiss-rs/pull/50