pub struct Index { /* private fields */ }Expand description
In-memory flat ANN index.
Implementations§
Source§impl Index
impl Index
Sourcepub fn add(&mut self, id: impl Into<String>, vector: &[f32]) -> Result<()>
pub fn add(&mut self, id: impl Into<String>, vector: &[f32]) -> Result<()>
Insert a single vector.
Sourcepub fn add_batch(
&mut self,
ids: Vec<String>,
matrix: &ArrayView2<'_, f32>,
) -> Result<()>
pub fn add_batch( &mut self, ids: Vec<String>, matrix: &ArrayView2<'_, f32>, ) -> Result<()>
Insert many vectors. matrix is (n, d).
Sourcepub fn search(&self, query: &[f32], k: usize) -> Result<Vec<Hit>>
pub fn search(&self, query: &[f32], k: usize) -> Result<Vec<Hit>>
Top-k search. query is a 1-D vector of the same dimension as
stored vectors.
Sourcepub fn search_batch(
&self,
queries: &ArrayView2<'_, f32>,
k: usize,
parallel: bool,
) -> Result<Vec<Vec<Hit>>>
pub fn search_batch( &self, queries: &ArrayView2<'_, f32>, k: usize, parallel: bool, ) -> Result<Vec<Vec<Hit>>>
Batch search. queries is (n_q, d). With parallel = true, each
query runs on a rayon thread.
Auto Trait Implementations§
impl Freeze for Index
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnsafeUnpin for Index
impl UnwindSafe for Index
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more