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 from_parts(
prism: PrismIndex,
id_map: Vec<u64>,
snapshot_max: u64,
metric: Metric,
dim: u16,
) -> Self
pub fn from_parts( prism: PrismIndex, id_map: Vec<u64>, snapshot_max: u64, metric: Metric, dim: u16, ) -> Self
Reassemble from persisted parts (the ANN segment decode path). The
caller is responsible for prism.store.vectors being in PRISM-internal
(cell-reordered) order - see segment::SegmentParts::into_index.
pub fn prism(&self) -> &PrismIndex
Sourcepub fn active_config(metric: Metric) -> PrismConfig
pub fn active_config(metric: Metric) -> PrismConfig
The PRISM configuration this index family builds with - part of the persisted segment’s binding (a config change invalidates segments).
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
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>
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>
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