pub trait Distance: Send + Sync + Sized + Clone + Debug + 'static {
type Header: Pod + Zeroable + Debug;
Show 16 methods
// Required methods
fn name() -> &'static str;
fn new_header(vector: &UnalignedF32Slice) -> Self::Header;
fn built_distance(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32;
fn init(node: &mut Leaf<'_, Self>);
fn create_split<R: Rng>(
children: &ImmutableSubsetLeafs<'_, Self>,
rng: &mut R,
) -> Result<Vec<f32>>;
fn margin_no_header(p: &UnalignedF32Slice, q: &UnalignedF32Slice) -> f32;
// Provided methods
fn non_built_distance(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32 { ... }
fn normalized_distance(d: f32) -> f32 { ... }
fn pq_distance(distance: f32, margin: f32, side: Side) -> f32 { ... }
fn norm(leaf: &Leaf<'_, Self>) -> f32 { ... }
fn norm_no_header(v: &UnalignedF32Slice) -> 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: &UnalignedF32Slice,
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.
Required Associated Types§
Required Methods§
fn name() -> &'static str
fn new_header(vector: &UnalignedF32Slice) -> Self::Header
sourcefn built_distance(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32
fn built_distance(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32
Returns a non-normalized distance.
fn init(node: &mut Leaf<'_, Self>)
fn create_split<R: Rng>( children: &ImmutableSubsetLeafs<'_, Self>, rng: &mut R, ) -> Result<Vec<f32>>
fn margin_no_header(p: &UnalignedF32Slice, q: &UnalignedF32Slice) -> f32
Provided Methods§
fn non_built_distance(p: &Leaf<'_, Self>, q: &Leaf<'_, Self>) -> f32
sourcefn normalized_distance(d: f32) -> f32
fn normalized_distance(d: f32) -> f32
Normalizes the distance returned by the distance method.
fn pq_distance(distance: f32, margin: f32, side: Side) -> f32
fn norm(leaf: &Leaf<'_, Self>) -> f32
fn norm_no_header(v: &UnalignedF32Slice) -> 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: &UnalignedF32Slice, 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<()>
Object Safety§
This trait is not object safe.