pub struct VectorMetricQuery<'a> { /* private fields */ }Expand description
Metric scorer bound to a single query vector.
Use this when ranking many candidates against one query. It preserves the
same scores and error contract as VectorMetric::distance, but avoids
recomputing query-only metric state for every candidate.
Implementations§
Source§impl<'a> VectorMetricQuery<'a>
impl<'a> VectorMetricQuery<'a>
Sourcepub const fn metric(&self) -> VectorMetric
pub const fn metric(&self) -> VectorMetric
Return the metric this scorer uses.
Sourcepub const fn query(&self) -> &'a VectorValue
pub const fn query(&self) -> &'a VectorValue
Return the bound query vector.
Sourcepub fn distance(&self, candidate: &VectorValue) -> CoreResult<f64>
pub fn distance(&self, candidate: &VectorValue) -> CoreResult<f64>
Compute this bound query’s lower-is-better distance to candidate.
§Errors
Returns CoreError::VectorDimensionMismatch if dimensions differ.
VectorMetric::Cosine also returns CoreError::VectorZeroNorm when
candidate has zero magnitude.
Sourcepub fn distance_with_candidate_squared_norm(
&self,
candidate: &VectorValue,
candidate_squared_norm: f64,
) -> CoreResult<f64>
pub fn distance_with_candidate_squared_norm( &self, candidate: &VectorValue, candidate_squared_norm: f64, ) -> CoreResult<f64>
Compute distance using a precomputed candidate squared norm.
When candidate_squared_norm is the candidate’s actual squared norm,
this is equivalent to Self::distance. It lets ANN indexes cache
centroid norms for cosine scoring while still using the canonical metric
kernels and error behavior. Non-cosine metrics ignore
candidate_squared_norm.
§Errors
Returns CoreError::VectorDimensionMismatch if dimensions differ.
VectorMetric::Cosine returns CoreError::VectorZeroNorm when the
supplied candidate squared norm is not positive and finite.
Trait Implementations§
Source§impl<'a> Clone for VectorMetricQuery<'a>
impl<'a> Clone for VectorMetricQuery<'a>
Source§fn clone(&self) -> VectorMetricQuery<'a>
fn clone(&self) -> VectorMetricQuery<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for VectorMetricQuery<'a>
Auto Trait Implementations§
impl<'a> Freeze for VectorMetricQuery<'a>
impl<'a> RefUnwindSafe for VectorMetricQuery<'a>
impl<'a> Send for VectorMetricQuery<'a>
impl<'a> Sync for VectorMetricQuery<'a>
impl<'a> Unpin for VectorMetricQuery<'a>
impl<'a> UnsafeUnpin for VectorMetricQuery<'a>
impl<'a> UnwindSafe for VectorMetricQuery<'a>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.