Trait faiss_next::Index

source ·
pub trait Index {
    // Required method
    fn inner(&self) -> *mut FaissIndex;

    // Provided methods
    fn add<T: AsRef<[f32]> + ?Sized>(&mut self, x: &T) -> Result<()> { ... }
    fn search<T: AsRef<[f32]> + ?Sized>(
        &self,
        x: &T,
        k: usize
    ) -> Result<SearchResult> { ... }
    fn d(&self) -> usize { ... }
    fn train<T: AsRef<[f32]> + ?Sized>(&mut self, x: &T) -> Result<()> { ... }
    fn remove_ids(&mut self, sel: IDSelector) -> Result<usize> { ... }
    fn save<P: AsRef<str>>(&self, pth: P) -> Result<()> { ... }
    fn load<P: AsRef<str>>(pth: P) -> Result<CpuIndex> { ... }
}
Expand description

Index trait, all index should implement this trait

Required Methods§

source

fn inner(&self) -> *mut FaissIndex

return inner pointer

Provided Methods§

source

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>

search vector against index, x.len() should be a multiple of d, k means top k

source

fn d(&self) -> usize

return dimension of index

source

fn train<T: AsRef<[f32]> + ?Sized>(&mut self, x: &T) -> Result<()>

train index when some index impl is used, is_trained is todo

source

fn remove_ids(&mut self, sel: IDSelector) -> Result<usize>

remove feature with IDSelector

source

fn save<P: AsRef<str>>(&self, pth: P) -> Result<()>

save index to disk

source

fn load<P: AsRef<str>>(pth: P) -> Result<CpuIndex>

load index from disk

Object Safety§

This trait is not object safe.

Implementors§