pub trait ANNIndexExternal<'a, const N: usize> {
type Index;
// Required methods
fn build<R: Rng>(
num_trees: usize,
max_leaf_size: usize,
vectors: &'a [Vector<N>],
rng: &mut R,
) -> Result<Self::Index, &'static str>;
fn search(&self, query: &Vector<N>, top_k: usize) -> Vec<(usize, f32)>;
fn memory_usage(&self) -> usize;
}
Expand description
A trait for ANNIndex that references external data. The index is read-only once built.
Required Associated Types§
Required Methods§
Sourcefn build<R: Rng>(
num_trees: usize,
max_leaf_size: usize,
vectors: &'a [Vector<N>],
rng: &mut R,
) -> Result<Self::Index, &'static str>
fn build<R: Rng>( num_trees: usize, max_leaf_size: usize, vectors: &'a [Vector<N>], rng: &mut R, ) -> Result<Self::Index, &'static str>
Build the index for the given vectors and ids.
§Arguments
num_trees
- The number of trees to build, higher means more accurate but slower and larger memory usage.max_leaf_size
- The maximum number of vectors in a leaf node, lower means higher accuracy but slower search.vectors
- The vectors to build the index from.
Sourcefn memory_usage(&self) -> usize
fn memory_usage(&self) -> usize
Get the memory usage of the index.
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.