Trait ANNIndexOwned

Source
pub trait ANNIndexOwned<const N: usize> {
    // Required methods
    fn insert_with_rng(
        &mut self,
        vector: Vector<N>,
        id: String,
        rng: &mut impl Rng,
    );
    fn delete_by_id(&mut self, id: &str) -> bool;
    fn get_by_id(&self, id: &str) -> Option<&Vector<N>>;
    fn search_with_metric(
        &self,
        query: &Vector<N>,
        top_k: usize,
        metric: ScoreMetric,
    ) -> Vec<(String, f32)>;

    // Provided methods
    fn insert(&mut self, vector: Vector<N>, id: String) { ... }
    fn search(&self, query: &Vector<N>, top_k: usize) -> Vec<(String, f32)> { ... }
}

Required Methods§

Source

fn insert_with_rng(&mut self, vector: Vector<N>, id: String, rng: &mut impl Rng)

Insert a vector into the index with a custom rng.

Source

fn delete_by_id(&mut self, id: &str) -> bool

Delete a vector from the index by id. Returns true if the vector was deleted, false if it was not found.

Source

fn get_by_id(&self, id: &str) -> Option<&Vector<N>>

Get a vector from the index by id.

Source

fn search_with_metric( &self, query: &Vector<N>, top_k: usize, metric: ScoreMetric, ) -> Vec<(String, f32)>

Search for the top_k nearest neighbors of the query vector. Returns a array of (id, score) pairs, higher score means closer.

Provided Methods§

Source

fn insert(&mut self, vector: Vector<N>, id: String)

Insert a vector into the index.

Source

fn search(&self, query: &Vector<N>, top_k: usize) -> Vec<(String, f32)>

Search for the top_k nearest neighbors of the query vector. Returns a array of (id, score) pairs, higher score means closer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<const N: usize> ANNIndexOwned<N> for VectorLite<N>