Struct faiss_next::CpuIndex
source · pub struct CpuIndex {
pub inner: *mut FaissIndex,
}Expand description
Index use cpu
§Examples
use faiss_next as faiss;
use faiss::Index;
let mut index = faiss::index_factory(128, "Flat", faiss::FaissMetricType::METRIC_L2).expect("failed to create index");
index.add(&vec![0.0;128 * 128]).expect("failed to add feature");
let ret = index.search(&vec![0.0;128], 1).expect("failed to search");Fields§
§inner: *mut FaissIndexTrait Implementations§
source§impl Index for CpuIndex
impl Index for CpuIndex
source§fn inner(&self) -> *mut FaissIndex
fn inner(&self) -> *mut FaissIndex
return inner pointer
source§fn add<T: AsRef<[f32]> + ?Sized>(&mut self, x: &T) -> Result<()>
fn add<T: AsRef<[f32]> + ?Sized>(&mut self, x: &T) -> Result<()>
add vectors to index, x.len() should be a multiple of d
source§fn search<T: AsRef<[f32]> + ?Sized>(
&self,
x: &T,
k: usize
) -> Result<SearchResult>
fn search<T: AsRef<[f32]> + ?Sized>( &self, x: &T, k: usize ) -> Result<SearchResult>
search vector against index,
x.len() should be a multiple of d, k means top ksource§fn train<T: AsRef<[f32]> + ?Sized>(&mut self, x: &T) -> Result<()>
fn train<T: AsRef<[f32]> + ?Sized>(&mut self, x: &T) -> Result<()>
train index when some index impl is used,
is_trained is todosource§fn remove_ids(&mut self, sel: IDSelector) -> Result<usize>
fn remove_ids(&mut self, sel: IDSelector) -> Result<usize>
remove feature with IDSelector
Auto Trait Implementations§
impl RefUnwindSafe for CpuIndex
impl !Send for CpuIndex
impl !Sync for CpuIndex
impl Unpin for CpuIndex
impl UnwindSafe for CpuIndex
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more