pub struct ListBoundComputer<'a> { /* private fields */ }Expand description
Computes bounds for a query across multiple lists
Precomputes query-related values once, then evaluates bounds per list in O(1).
Implementations§
Source§impl<'a> ListBoundComputer<'a>
impl<'a> ListBoundComputer<'a>
Sourcepub fn new(query: &'a [f32], metric: DistanceMetric) -> Self
pub fn new(query: &'a [f32], metric: DistanceMetric) -> Self
Create a new bound computer for a query
Sourcepub fn cosine_upper_bound(&self, metadata: &SphericalCapMetadata) -> f32
pub fn cosine_upper_bound(&self, metadata: &SphericalCapMetadata) -> f32
Compute upper bound on similarity for a spherical cap (cosine/dot)
For normalized query q and list with centroid c and max deviation θ_max: max_{v∈L} q·v ≤ cos(max(0, angle(q,c) - θ_max))
Complexity: O(d) for dot product, rest is O(1)
Sourcepub fn l2_lower_bound(&self, metadata: &L2ListMetadata) -> f32
pub fn l2_lower_bound(&self, metadata: &L2ListMetadata) -> f32
Compute lower bound on L2 distance for a list
LB = max(0, dist(q, c) - radius)
Sourcepub fn compute_bound(
&self,
cap: &SphericalCapMetadata,
l2: Option<&L2ListMetadata>,
) -> f32
pub fn compute_bound( &self, cap: &SphericalCapMetadata, l2: Option<&L2ListMetadata>, ) -> f32
Compute bound appropriate for the configured metric
For similarity metrics (cosine, dot): returns upper bound (higher = tighter) For distance metrics (L2): returns lower bound (lower = tighter)
Auto Trait Implementations§
impl<'a> Freeze for ListBoundComputer<'a>
impl<'a> RefUnwindSafe for ListBoundComputer<'a>
impl<'a> Send for ListBoundComputer<'a>
impl<'a> Sync for ListBoundComputer<'a>
impl<'a> Unpin for ListBoundComputer<'a>
impl<'a> UnsafeUnpin for ListBoundComputer<'a>
impl<'a> UnwindSafe for ListBoundComputer<'a>
Blanket Implementations§
impl<T> Allocation for T
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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