From 8f644496a676f06fed91abc4ed7d9a3c4bf04848 Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 8 Dec 2018 21:13:04 +0000 Subject: [PATCH] address comments, cleanup --- src/index/id_map.rs | 2 -- src/macros.rs | 2 +- src/selector.rs | 5 +++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/index/id_map.rs b/src/index/id_map.rs index 13aa777432..1e94961143 100644 --- a/src/index/id_map.rs +++ b/src/index/id_map.rs @@ -360,7 +360,6 @@ mod tests { let mut index = index_factory(4, "Flat", MetricType::L2).unwrap(); let mut id_index = IdMap::new(index).unwrap(); let some_data = &[2.3_f32, 0.0, -1., 1., 1., 1., 1., 4.5, 2.3, 7.6, 1., 2.2]; - println!("{}", some_data.len()); let ids = &[4, 8, 12]; @@ -370,7 +369,6 @@ mod tests { let id_sel = IdSelector::batch(&[4, 12]).ok().unwrap(); id_index.remove_ids(&id_sel).unwrap(); - println!("{}", id_index.ntotal()); assert_eq!(id_index.ntotal(), 1); } } diff --git a/src/macros.rs b/src/macros.rs index 5d451e8193..fcbfa58e1c 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -109,7 +109,7 @@ macro_rules! impl_native_index { } } - fn remove_ids(&mut self, sel: &IdSelector) -> Result<(i64)> { + fn remove_ids(&mut self, sel: &IdSelector) -> Result { unsafe { let mut n_removed = 0; faiss_try!(faiss_Index_remove_ids( diff --git a/src/selector.rs b/src/selector.rs index 81618a187a..37ef36d474 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -2,6 +2,7 @@ use error::Result; use faiss_sys::*; use index::Idx; +use std::os::raw::c_long; use std::ptr; /// Abstraction over IDSelectorRange and IDSelectorBatch @@ -22,10 +23,10 @@ impl IdSelector { /// Create new batch selector pub fn batch(indices: &[Idx]) -> Result { - let n = indices.len() as i64; + let n = indices.len() as c_long; let mut p_sel = ptr::null_mut(); unsafe { - faiss_try!(faiss_IDSelectorBatch_new(&mut p_sel, n, &indices[0])); + faiss_try!(faiss_IDSelectorBatch_new(&mut p_sel, n, indices.as_ptr())); }; Ok(IdSelector { inner: p_sel as *mut _}) }