pub struct IVFRaBitQIndex {
pub config: IVFRaBitQConfig,
pub centroids_version: u64,
pub codebook_version: u64,
pub clusters: ClusterStorage<QuantizedVector>,
}Expand description
IVF-RaBitQ index for a single segment
Fields§
§config: IVFRaBitQConfigConfiguration
centroids_version: u64Version of coarse centroids used (for merge compatibility)
codebook_version: u64Version of RaBitQ codebook used (for merge compatibility)
clusters: ClusterStorage<QuantizedVector>Cluster storage with RaBitQ codes
Implementations§
Source§impl IVFRaBitQIndex
impl IVFRaBitQIndex
Sourcepub fn new(
config: IVFRaBitQConfig,
centroids_version: u64,
codebook_version: u64,
) -> Self
pub fn new( config: IVFRaBitQConfig, centroids_version: u64, codebook_version: u64, ) -> Self
Create a new empty IVF-RaBitQ index
Sourcepub fn build(
config: IVFRaBitQConfig,
coarse_centroids: &CoarseCentroids,
codebook: &RaBitQCodebook,
vectors: &[Vec<f32>],
doc_ids: Option<&[u32]>,
) -> Self
pub fn build( config: IVFRaBitQConfig, coarse_centroids: &CoarseCentroids, codebook: &RaBitQCodebook, vectors: &[Vec<f32>], doc_ids: Option<&[u32]>, ) -> Self
Build index from vectors using provided coarse centroids and codebook
Sourcepub fn add_vector(
&mut self,
coarse_centroids: &CoarseCentroids,
codebook: &RaBitQCodebook,
doc_id: u32,
vector: &[f32],
)
pub fn add_vector( &mut self, coarse_centroids: &CoarseCentroids, codebook: &RaBitQCodebook, doc_id: u32, vector: &[f32], )
Add a single vector to the index
Sourcepub fn search(
&self,
coarse_centroids: &CoarseCentroids,
codebook: &RaBitQCodebook,
query: &[f32],
k: usize,
nprobe: Option<usize>,
) -> Vec<(u32, f32)>
pub fn search( &self, coarse_centroids: &CoarseCentroids, codebook: &RaBitQCodebook, query: &[f32], k: usize, nprobe: Option<usize>, ) -> Vec<(u32, f32)>
Search for k nearest neighbors
Sourcepub fn merge_into(
&mut self,
other: &IVFRaBitQIndex,
doc_id_offset: u32,
) -> Result<(), &'static str>
pub fn merge_into( &mut self, other: &IVFRaBitQIndex, doc_id_offset: u32, ) -> Result<(), &'static str>
Merge another index into this one (instance method)
pub fn is_empty(&self) -> bool
Sourcepub fn num_clusters(&self) -> usize
pub fn num_clusters(&self) -> usize
Number of non-empty clusters
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Deserialize from bytes
Trait Implementations§
Source§impl Clone for IVFRaBitQIndex
impl Clone for IVFRaBitQIndex
Source§fn clone(&self) -> IVFRaBitQIndex
fn clone(&self) -> IVFRaBitQIndex
Returns a duplicate of the value. Read more
1.0.0 · 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 IVFRaBitQIndex
impl Debug for IVFRaBitQIndex
Source§impl<'de> Deserialize<'de> for IVFRaBitQIndex
impl<'de> Deserialize<'de> for IVFRaBitQIndex
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 IVFRaBitQIndex
impl RefUnwindSafe for IVFRaBitQIndex
impl Send for IVFRaBitQIndex
impl Sync for IVFRaBitQIndex
impl Unpin for IVFRaBitQIndex
impl UnwindSafe for IVFRaBitQIndex
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
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.