pub struct IVFPQIndex {
pub config: IVFPQConfig,
pub centroids_version: u64,
pub codebook_version: u64,
/* private fields */
}Expand description
IVF-PQ index for a single segment
Fields§
§config: IVFPQConfigConfiguration
centroids_version: u64Version of coarse centroids used (for merge compatibility)
codebook_version: u64Version of PQ codebook used (for merge compatibility)
Implementations§
Source§impl IVFPQIndex
impl IVFPQIndex
Sourcepub fn new(
config: IVFPQConfig,
centroids_version: u64,
codebook_version: u64,
) -> Self
pub fn new( config: IVFPQConfig, centroids_version: u64, codebook_version: u64, ) -> Self
Create a new empty IVF-PQ index
Sourcepub fn build(
config: IVFPQConfig,
coarse_centroids: &CoarseCentroids,
codebook: &PQCodebook,
vectors: &[Vec<f32>],
doc_id_ordinals: Option<&[(u32, u16)]>,
) -> Self
pub fn build( config: IVFPQConfig, coarse_centroids: &CoarseCentroids, codebook: &PQCodebook, vectors: &[Vec<f32>], doc_id_ordinals: Option<&[(u32, u16)]>, ) -> Self
Build index from vectors using provided coarse centroids and PQ codebook
doc_id_ordinals: (doc_id, ordinal) pairs. If None, uses (index, 0).
Sourcepub fn add_vector(
&mut self,
coarse_centroids: &CoarseCentroids,
codebook: &PQCodebook,
doc_id: u32,
ordinal: u16,
vector: &[f32],
)
pub fn add_vector( &mut self, coarse_centroids: &CoarseCentroids, codebook: &PQCodebook, doc_id: u32, ordinal: u16, vector: &[f32], )
Add a single vector to the index
Sourcepub fn add_vectors_parallel(
&mut self,
coarse_centroids: &CoarseCentroids,
codebook: &PQCodebook,
doc_id_ordinals: &[(u32, u16)],
vectors: &[f32],
) -> Result<(), &'static str>
pub fn add_vectors_parallel( &mut self, coarse_centroids: &CoarseCentroids, codebook: &PQCodebook, doc_id_ordinals: &[(u32, u16)], vectors: &[f32], ) -> Result<(), &'static str>
Add one contiguous vector batch in parallel while preserving input order inside every leaf. Callers can install this work on their bounded Rayon pool; normal segment builds use the current Rayon pool.
Sourcepub fn search_distinct_documents(
&self,
k: usize,
plan: &IvfPqQueryPlan,
) -> Vec<(u32, u16, f32)>
pub fn search_distinct_documents( &self, k: usize, plan: &IvfPqQueryPlan, ) -> Vec<(u32, u16, f32)>
Search a probe plan already computed from the global quantizer.
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 size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Memory usage estimate
Sourcepub fn estimated_memory_bytes(&self) -> usize
pub fn estimated_memory_bytes(&self) -> usize
Estimated memory usage in bytes (alias for size_bytes)
Trait Implementations§
Source§impl Clone for IVFPQIndex
impl Clone for IVFPQIndex
Source§fn clone(&self) -> IVFPQIndex
fn clone(&self) -> IVFPQIndex
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 moreAuto Trait Implementations§
impl Freeze for IVFPQIndex
impl RefUnwindSafe for IVFPQIndex
impl Send for IVFPQIndex
impl Sync for IVFPQIndex
impl Unpin for IVFPQIndex
impl UnsafeUnpin for IVFPQIndex
impl UnwindSafe for IVFPQIndex
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> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<E> ResultError for E
impl<T> ResultType 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.