pub struct AnnIndex {
pub snapshot_max: u64,
pub metric: Metric,
pub dim: u16,
/* private fields */
}Expand description
In-memory ANN index over a (row_id, vector) snapshot.
Fields§
§snapshot_max: u64Highest row_id in the snapshot.
metric: Metric§dim: u16Implementations§
Source§impl AnnIndex
impl AnnIndex
Sourcepub fn build(
rows: Vec<(u64, Vec<f32>)>,
metric: Metric,
dim: u16,
) -> Result<Self, AnnError>
pub fn build( rows: Vec<(u64, Vec<f32>)>, metric: Metric, dim: u16, ) -> Result<Self, AnnError>
Build an unfiltered index from (row_id, vector) pairs.
Sourcepub fn build_with_attrs(
rows: Vec<(u64, Vec<f32>, Vec<u32>)>,
num_attrs: usize,
metric: Metric,
dim: u16,
) -> Result<Self, AnnError>
pub fn build_with_attrs( rows: Vec<(u64, Vec<f32>, Vec<u32>)>, num_attrs: usize, metric: Metric, dim: u16, ) -> Result<Self, AnnError>
Build a filtered index from (row_id, vector, attr_codes) triples. Each
attribute is a PRISM dimension; distinct tuples form the searchable cells.
Sourcepub fn search(&self, query: &[f32], k: usize) -> Vec<(u64, f32)>
pub fn search(&self, query: &[f32], k: usize) -> Vec<(u64, f32)>
Top-k search returning (row_id, distance) ascending, at the default ef.
Sourcepub fn search_with_ef(
&self,
query: &[f32],
k: usize,
ef: usize,
) -> Vec<(u64, f32)>
pub fn search_with_ef( &self, query: &[f32], k: usize, ef: usize, ) -> Vec<(u64, f32)>
Unfiltered search with an explicit beam width ef.
Sourcepub fn search_filtered_default_ef(
&self,
query: &[f32],
k: usize,
filter: &Filter,
) -> Vec<(u64, f32)>
pub fn search_filtered_default_ef( &self, query: &[f32], k: usize, filter: &Filter, ) -> Vec<(u64, f32)>
Filtered search at the default ef.
Sourcepub fn search_filtered(
&self,
query: &[f32],
k: usize,
ef: usize,
filter: &Filter,
) -> Vec<(u64, f32)>
pub fn search_filtered( &self, query: &[f32], k: usize, ef: usize, filter: &Filter, ) -> Vec<(u64, f32)>
Filtered search; filter dims index the build_with_attrs attributes
(Filter::none() matches all).
Sourcepub fn indexed_len(&self) -> usize
pub fn indexed_len(&self) -> usize
Number of indexed rows.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AnnIndex
impl RefUnwindSafe for AnnIndex
impl Send for AnnIndex
impl Sync for AnnIndex
impl Unpin for AnnIndex
impl UnsafeUnpin for AnnIndex
impl UnwindSafe for AnnIndex
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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