Trait faiss::index::Index

source ·
pub trait Index {
Show 14 methods // Required methods fn is_trained(&self) -> bool; fn ntotal(&self) -> u64; fn d(&self) -> u32; fn metric_type(&self) -> MetricType; fn add(&mut self, x: &[f32]) -> Result<()>; fn add_with_ids(&mut self, x: &[f32], xids: &[Idx]) -> Result<()>; fn train(&mut self, x: &[f32]) -> Result<()>; fn assign(&mut self, q: &[f32], k: usize) -> Result<AssignSearchResult>; fn search(&mut self, q: &[f32], k: usize) -> Result<SearchResult>; fn range_search( &mut self, q: &[f32], radius: f32 ) -> Result<RangeSearchResult>; fn reset(&mut self) -> Result<()>; fn remove_ids(&mut self, sel: &IdSelector) -> Result<usize>; fn verbose(&self) -> bool; fn set_verbose(&mut self, value: bool);
}
Expand description

Interface for a Faiss index. Most methods in this trait match the ones in the native library, whereas some others serve as getters to the index’ parameters.

Although all methods appear to be available for all index implementations, some methods may not be supported. For instance, a FlatIndex stores vectors sequentially, and so does not support add_with_ids nor remove_ids. Users are advised to read the Faiss wiki pages in order to understand which index algorithms support which operations.

Required Methods§

source

fn is_trained(&self) -> bool

Whether the Index does not require training, or if training is done already

source

fn ntotal(&self) -> u64

The total number of vectors indexed

source

fn d(&self) -> u32

The dimensionality of the indexed vectors

source

fn metric_type(&self) -> MetricType

The metric type assumed by the index

source

fn add(&mut self, x: &[f32]) -> Result<()>

Add new data vectors to the index. This assumes a C-contiguous memory slice of vectors, where the total number of vectors is x.len() / d.

source

fn add_with_ids(&mut self, x: &[f32], xids: &[Idx]) -> Result<()>

Add new data vectors to the index with IDs. This assumes a C-contiguous memory slice of vectors, where the total number of vectors is x.len() / d. Not all index types may support this operation.

source

fn train(&mut self, x: &[f32]) -> Result<()>

Train the underlying index with the given data.

source

fn assign(&mut self, q: &[f32], k: usize) -> Result<AssignSearchResult>

Similar to search, but only provides the labels.

source

fn search(&mut self, q: &[f32], k: usize) -> Result<SearchResult>

Perform a search for the k closest vectors to the given query vectors.

Perform a ranged search for the vectors closest to the given query vectors by the given radius.

source

fn reset(&mut self) -> Result<()>

Clear the entire index.

source

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

Remove data vectors represented by IDs.

source

fn verbose(&self) -> bool

Index verbosity level

source

fn set_verbose(&mut self, value: bool)

Set Index verbosity level

Implementations on Foreign Types§

source§

impl<I> Index for Box<I>where I: Index,

source§

fn is_trained(&self) -> bool

source§

fn ntotal(&self) -> u64

source§

fn d(&self) -> u32

source§

fn metric_type(&self) -> MetricType

source§

fn add(&mut self, x: &[f32]) -> Result<()>

source§

fn add_with_ids(&mut self, x: &[f32], xids: &[Idx]) -> Result<()>

source§

fn train(&mut self, x: &[f32]) -> Result<()>

source§

fn assign(&mut self, q: &[f32], k: usize) -> Result<AssignSearchResult>

source§

fn search(&mut self, q: &[f32], k: usize) -> Result<SearchResult>

source§

fn reset(&mut self) -> Result<()>

source§

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

source§

fn verbose(&self) -> bool

source§

fn set_verbose(&mut self, value: bool)

Implementors§