Distance

Trait Distance 

Source
pub trait Distance:
    Send
    + Sync
    + Sized
    + Clone
    + Debug
    + 'static {
    type Header: Pod + Zeroable + Debug;
    type VectorCodec: UnalignedVectorCodec;

    const DEFAULT_OVERSAMPLING: usize = 1usize;
Show 16 methods // Required methods fn name() -> &'static str; fn new_header(vector: &UnalignedVector<Self::VectorCodec>) -> Self::Header; fn built_distance(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32; fn norm_no_header(v: &UnalignedVector<Self::VectorCodec>) -> f32; fn init(node: &mut Leaf<'_, Self>); fn create_split<'a, R: Rng>( children: &'a ImmutableSubsetLeafs<'_, Self>, rng: &mut R, ) -> Result<Cow<'a, UnalignedVector<Self::VectorCodec>>>; fn margin_no_header( p: &UnalignedVector<Self::VectorCodec>, q: &UnalignedVector<Self::VectorCodec>, ) -> f32; // Provided methods fn non_built_distance(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32 { ... } fn normalized_distance(d: f32, _dimensions: usize) -> f32 { ... } fn pq_distance(distance: f32, margin: f32, side: Side) -> f32 { ... } fn norm(leaf: &Leaf<'_, Self>) -> f32 { ... } fn normalize(node: &mut Leaf<'_, Self>) { ... } fn update_mean( mean: &mut Leaf<'_, Self>, new_node: &Leaf<'_, Self>, norm: f32, c: f32, ) { ... } fn margin(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32 { ... } fn side<R: Rng>( normal_plane: &UnalignedVector<Self::VectorCodec>, node: &Leaf<'_, Self>, rng: &mut R, ) -> Side { ... } fn preprocess( _wtxn: &mut RwTxn<'_>, _new_iter: impl for<'a> Fn(&'a mut RwTxn<'_>) -> Result<RwPrefix<'a, KeyCodec, NodeCodec<Self>>>, ) -> Result<()> { ... }
}
Expand description

A trait used by arroy to compute the distances, compute the split planes, and normalize user vectors.

Provided Associated Constants§

Required Associated Types§

Source

type Header: Pod + Zeroable + Debug

A header structure with informations related to the

Source

type VectorCodec: UnalignedVectorCodec

Required Methods§

Source

fn name() -> &'static str

Source

fn new_header(vector: &UnalignedVector<Self::VectorCodec>) -> Self::Header

Source

fn built_distance(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32

Returns a non-normalized distance.

Source

fn norm_no_header(v: &UnalignedVector<Self::VectorCodec>) -> f32

Source

fn init(node: &mut Leaf<'_, Self>)

Source

fn create_split<'a, R: Rng>( children: &'a ImmutableSubsetLeafs<'_, Self>, rng: &mut R, ) -> Result<Cow<'a, UnalignedVector<Self::VectorCodec>>>

Source

fn margin_no_header( p: &UnalignedVector<Self::VectorCodec>, q: &UnalignedVector<Self::VectorCodec>, ) -> f32

Provided Methods§

Source

fn non_built_distance(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32

Source

fn normalized_distance(d: f32, _dimensions: usize) -> f32

Normalizes the distance returned by the distance method.

Source

fn pq_distance(distance: f32, margin: f32, side: Side) -> f32

Source

fn norm(leaf: &Leaf<'_, Self>) -> f32

Source

fn normalize(node: &mut Leaf<'_, Self>)

Source

fn update_mean( mean: &mut Leaf<'_, Self>, new_node: &Leaf<'_, Self>, norm: f32, c: f32, )

Source

fn margin(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32

Source

fn side<R: Rng>( normal_plane: &UnalignedVector<Self::VectorCodec>, node: &Leaf<'_, Self>, rng: &mut R, ) -> Side

Source

fn preprocess( _wtxn: &mut RwTxn<'_>, _new_iter: impl for<'a> Fn(&'a mut RwTxn<'_>) -> Result<RwPrefix<'a, KeyCodec, NodeCodec<Self>>>, ) -> Result<()>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§