pub struct IVFRaBitQIndex {
pub config: IVFConfig,
pub centroids_version: u64,
pub random_signs: Vec<i8>,
pub random_perm: Vec<u32>,
pub clusters: HashMap<u32, ClusterData>,
pub num_vectors: usize,
}Expand description
IVF-RaBitQ index for a single segment
Fields§
§config: IVFConfigConfiguration
centroids_version: u64Version of coarse centroids used (for merge compatibility)
random_signs: Vec<i8>Random signs for transform (+1 or -1)
random_perm: Vec<u32>Random permutation for transform
clusters: HashMap<u32, ClusterData>Cluster data (sparse - only populated clusters)
num_vectors: usizeTotal number of vectors indexed
Implementations§
Source§impl IVFRaBitQIndex
impl IVFRaBitQIndex
Sourcepub fn build(
config: IVFConfig,
coarse_centroids: &CoarseCentroids,
vectors: &[Vec<f32>],
doc_ids: Option<&[u32]>,
) -> Self
pub fn build( config: IVFConfig, coarse_centroids: &CoarseCentroids, vectors: &[Vec<f32>], doc_ids: Option<&[u32]>, ) -> Self
Build index from vectors using provided coarse centroids
Sourcepub fn add_vector(
&mut self,
coarse_centroids: &CoarseCentroids,
doc_id: u32,
vector: &[f32],
)
pub fn add_vector( &mut self, coarse_centroids: &CoarseCentroids, doc_id: u32, vector: &[f32], )
Add a single vector to the index
Sourcepub fn search(
&self,
coarse_centroids: &CoarseCentroids,
query: &[f32],
k: usize,
nprobe: usize,
) -> Vec<(u32, f32)>
pub fn search( &self, coarse_centroids: &CoarseCentroids, query: &[f32], k: usize, nprobe: usize, ) -> Vec<(u32, f32)>
Search for k nearest neighbors
Sourcepub fn merge(
indexes: &[&IVFRaBitQIndex],
doc_id_offsets: &[u32],
) -> Result<Self, &'static str>
pub fn merge( indexes: &[&IVFRaBitQIndex], doc_id_offsets: &[u32], ) -> Result<Self, &'static str>
Merge multiple IVF indexes (O(1) per cluster - just concatenate)
Sourcepub fn num_clusters(&self) -> usize
pub fn num_clusters(&self) -> usize
Get number of populated clusters
pub fn is_empty(&self) -> bool
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 more