pub struct BinaryIvfIndex {
pub config: BinaryIvfConfig,
/* private fields */
}Expand description
IVF index over packed binary vectors (Hamming distance).
Fields§
§config: BinaryIvfConfigImplementations§
Source§impl BinaryIvfIndex
impl BinaryIvfIndex
Sourcepub fn build(
config: BinaryIvfConfig,
codes: &[u8],
doc_id_ordinals: &[(u32, u16)],
) -> Self
pub fn build( config: BinaryIvfConfig, codes: &[u8], doc_id_ordinals: &[(u32, u16)], ) -> Self
Train centroids via k-majority and build the index from packed vectors.
codes is n × byte_len contiguous packed vectors;
doc_id_ordinals[i] labels vector i.
Sourcepub fn search(
&self,
query: &[u8],
k: usize,
nprobe: Option<usize>,
) -> Vec<(u32, u16, f32)>
pub fn search( &self, query: &[u8], k: usize, nprobe: Option<usize>, ) -> Vec<(u32, u16, f32)>
Search: probe nprobe nearest clusters, exact Hamming within each.
Returns (doc_id, ordinal, similarity) with similarity = 1 - hamming/dim,
sorted descending — exact for every scanned vector.
Sourcepub fn merge_into(&mut self, other: &BinaryIvfIndex, doc_id_offset: u32)
pub fn merge_into(&mut self, other: &BinaryIvfIndex, doc_id_offset: u32)
Merge another index into this one, re-assigning its vectors to this index’s centroids. Lossless: cluster payloads are the exact codes.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn num_clusters(&self) -> usize
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Deserialize from bytes.
Sourcepub fn estimated_memory_bytes(&self) -> usize
pub fn estimated_memory_bytes(&self) -> usize
Estimated memory usage in bytes.
Trait Implementations§
Source§impl Clone for BinaryIvfIndex
impl Clone for BinaryIvfIndex
Source§fn clone(&self) -> BinaryIvfIndex
fn clone(&self) -> BinaryIvfIndex
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BinaryIvfIndex
impl Debug for BinaryIvfIndex
Source§impl<'de> Deserialize<'de> for BinaryIvfIndex
impl<'de> Deserialize<'de> for BinaryIvfIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for BinaryIvfIndex
impl RefUnwindSafe for BinaryIvfIndex
impl Send for BinaryIvfIndex
impl Sync for BinaryIvfIndex
impl Unpin for BinaryIvfIndex
impl UnsafeUnpin for BinaryIvfIndex
impl UnwindSafe for BinaryIvfIndex
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.