pub struct VectorLite<const N: usize> { /* private fields */ }
Expand description
A lightweight lsh-based ann index.
Implementations§
Source§impl<const N: usize> VectorLite<N>
impl<const N: usize> VectorLite<N>
Sourcepub fn new(num_trees: usize, max_leaf_size: usize) -> Self
pub fn new(num_trees: usize, max_leaf_size: usize) -> Self
Create a new VectorLite index with the given number of trees and max leaf size. More trees means more accuracy but slower search and larger memory usage. Lower max_leaf_size means higher accuracy but larger memory usage.
Sourcepub fn index(&self) -> &VectorLiteIndex<N>
pub fn index(&self) -> &VectorLiteIndex<N>
Get the index.
Sourcepub fn from_bytes(bytes: &[u8]) -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
Deserialize the index from a byte vector.
Trait Implementations§
Source§impl<const N: usize> ANNIndexOwned<N> for VectorLite<N>
impl<const N: usize> ANNIndexOwned<N> for VectorLite<N>
Source§fn insert_with_rng(&mut self, vector: Vector<N>, id: String, rng: &mut impl Rng)
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
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 search_with_metric(
&self,
query: &Vector<N>,
top_k: usize,
metric: ScoreMetric,
) -> Vec<(String, f32)>
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.
Source§impl<'__de, const N: usize, __Context> BorrowDecode<'__de, __Context> for VectorLite<N>
impl<'__de, const N: usize, __Context> BorrowDecode<'__de, __Context> for VectorLite<N>
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<const N: usize, __Context> Decode<__Context> for VectorLite<N>
impl<const N: usize, __Context> Decode<__Context> for VectorLite<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for VectorLite<N>
impl<const N: usize> RefUnwindSafe for VectorLite<N>
impl<const N: usize> !Send for VectorLite<N>
impl<const N: usize> !Sync for VectorLite<N>
impl<const N: usize> Unpin for VectorLite<N>
impl<const N: usize> UnwindSafe for VectorLite<N>
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