pub struct LSHIndex { /* private fields */ }Expand description
Document IDs by bucket, one table of buckets per LSH table.
Implementations§
Source§impl LSHIndex
impl LSHIndex
Sourcepub fn new(dim: usize, num_tables: usize, num_hyperplanes: usize) -> Self
pub fn new(dim: usize, num_tables: usize, num_hyperplanes: usize) -> Self
An empty index for dim-wide vectors. More tables find more true
neighbors; more hyperplanes per table make smaller buckets, so fewer
candidates to score. Zero tables make one bucket holding every ID, so
a query returns them all, as brute force would score them all.
Sourcepub fn insert(&mut self, id: &str, embedding: &[f64])
pub fn insert(&mut self, id: &str, embedding: &[f64])
Adds id to the bucket embedding falls in, in every table.
Sourcepub fn remove(&mut self, id: &str, embedding: &[f64])
pub fn remove(&mut self, id: &str, embedding: &[f64])
Removes id from the buckets embedding falls in, undoing
Self::insert of the same pair.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LSHIndex
impl RefUnwindSafe for LSHIndex
impl Send for LSHIndex
impl Sync for LSHIndex
impl Unpin for LSHIndex
impl UnsafeUnpin for LSHIndex
impl UnwindSafe for LSHIndex
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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