[−][src]Struct hnsw::DiscreteHNSW
This provides a HNSW implementation for any discrete distance function.
This can achieve much higher performance than a non-discrete distance function
due to the discrete distance priority queue used to search. This can be combined with
the Hamming
struct to add binary features to the HNSW.
Methods
impl<T: DiscreteDistance, M: ArrayLength<u32>, M0: ArrayLength<u32>, R> DiscreteHNSW<T, M, M0, R> where
R: RngCore + SeedableRng,
[src]
R: RngCore + SeedableRng,
pub fn new() -> Self
[src]
Creates a new HNSW with a PRNG which is default seeded to produce deterministic behavior.
pub fn new_params(params: Params) -> Self
[src]
Creates a new HNSW with a default seeded PRNG and with the specified params.
impl<T: DiscreteDistance, M: ArrayLength<u32>, M0: ArrayLength<u32>, R> DiscreteHNSW<T, M, M0, R> where
R: RngCore,
[src]
R: RngCore,
pub fn new_prng(prng: R) -> Self
[src]
Creates a HNSW with the passed prng
.
pub fn new_params_and_prng(params: Params, prng: R) -> Self
[src]
Creates a HNSW with the passed params
and prng
.
pub fn insert(&mut self, q: T, searcher: &mut DiscreteSearcher<T>) -> u32
[src]
Inserts a feature into the HNSW.
pub fn nearest<'a>(
&self,
q: &T,
ef: usize,
searcher: &mut DiscreteSearcher<T>,
dest: &'a mut [u32]
) -> &'a mut [u32]
[src]
&self,
q: &T,
ef: usize,
searcher: &mut DiscreteSearcher<T>,
dest: &'a mut [u32]
) -> &'a mut [u32]
Does a k-NN search where q
is the query element and it attempts to put up to M
nearest neighbors into dest
.
ef
is the candidate pool size. ef
can be increased to get better recall at the expense of speed.
If ef
is less than dest.len()
then dest
will only be filled with ef
elements.
Returns a slice of the filled neighbors.
pub fn feature(&self, item: u32) -> &T
[src]
pub fn len(&self) -> usize
[src]
pub fn is_empty(&self) -> bool
[src]
Trait Implementations
impl<T: DiscreteDistance, M: ArrayLength<u32>, M0: ArrayLength<u32>, R> Default for DiscreteHNSW<T, M, M0, R> where
R: SeedableRng,
[src]
R: SeedableRng,
impl<T: Clone + DiscreteDistance, M: Clone + ArrayLength<u32>, M0: Clone + ArrayLength<u32>, R: Clone> Clone for DiscreteHNSW<T, M, M0, R>
[src]
fn clone(&self) -> DiscreteHNSW<T, M, M0, R>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl<T, M, M0, R> Sync for DiscreteHNSW<T, M, M0, R> where
R: Sync,
T: Sync,
R: Sync,
T: Sync,
impl<T, M, M0, R> Unpin for DiscreteHNSW<T, M, M0, R> where
R: Unpin,
T: Unpin,
<M as ArrayLength<u32>>::ArrayType: Unpin,
<M0 as ArrayLength<u32>>::ArrayType: Unpin,
R: Unpin,
T: Unpin,
<M as ArrayLength<u32>>::ArrayType: Unpin,
<M0 as ArrayLength<u32>>::ArrayType: Unpin,
impl<T, M, M0, R> Send for DiscreteHNSW<T, M, M0, R> where
R: Send,
T: Send,
R: Send,
T: Send,
impl<T, M, M0, R> UnwindSafe for DiscreteHNSW<T, M, M0, R> where
R: UnwindSafe,
T: UnwindSafe,
<M as ArrayLength<u32>>::ArrayType: UnwindSafe,
<M0 as ArrayLength<u32>>::ArrayType: UnwindSafe,
R: UnwindSafe,
T: UnwindSafe,
<M as ArrayLength<u32>>::ArrayType: UnwindSafe,
<M0 as ArrayLength<u32>>::ArrayType: UnwindSafe,
impl<T, M, M0, R> RefUnwindSafe for DiscreteHNSW<T, M, M0, R> where
R: RefUnwindSafe,
T: RefUnwindSafe,
<M as ArrayLength<u32>>::ArrayType: RefUnwindSafe,
<M0 as ArrayLength<u32>>::ArrayType: RefUnwindSafe,
R: RefUnwindSafe,
T: RefUnwindSafe,
<M as ArrayLength<u32>>::ArrayType: RefUnwindSafe,
<M0 as ArrayLength<u32>>::ArrayType: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> FromCast<T> for T
[src]
impl<T, U> Cast<U> for T where
U: FromCast<T>,
[src]
U: FromCast<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,