Last active
April 11, 2018 19:00
-
-
Save Enet4/c6bf959e4f5953463b50dc46aeb740ad to your computer and use it in GitHub Desktop.
index_factory at index/mod.rs in faiss-rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Use the index factory to create a native instance of a Faiss index, for `d`-dimensional | |
/// vectors. | |
pub fn index_factory<D: AsRef<str>>( | |
d: u32, | |
description: D, | |
metric: MetricType, | |
) -> Result<IndexImpl> { | |
unsafe { | |
let metric = metric as c_uint; | |
let description = CString::new(description.as_ref()).map_err(|_| Error::IndexDescription)?; | |
let mut index_ptr = ::std::ptr::null_mut(); | |
faiss_try!(faiss_index_factory( | |
&mut index_ptr, | |
(d & 0x7FFFFFFF) as i32, | |
description.as_ptr(), | |
metric | |
)); | |
Ok(IndexImpl { inner: index_ptr }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment