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 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 kfn is_trained(&self) -> bool
Source§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
Source§fn remove_ids(&mut self, sel: IDSelector) -> Result<usize>
fn remove_ids(&mut self, sel: IDSelector) -> Result<usize>
remove feature with IDSelector
Source§impl IndexInner for CpuIndex
impl IndexInner for CpuIndex
Source§fn inner(&self) -> *mut FaissIndex
fn inner(&self) -> *mut FaissIndex
return inner pointer
Auto Trait Implementations§
impl Freeze for CpuIndex
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