Skip to main content

DenseVectorConfig

Struct DenseVectorConfig 

Source
pub struct DenseVectorConfig {
    pub dim: usize,
    pub index_type: VectorIndexType,
    pub quantization: DenseVectorQuantization,
    pub num_clusters: Option<usize>,
    pub nprobe: usize,
    pub build_threshold: Option<usize>,
    pub unit_norm: bool,
    pub rabitq_bits: Option<u8>,
    pub soar: Option<SoarConfig>,
}
Expand description

Configuration for dense vector fields using Flat, RaBitQ, IVF-RaBitQ, or ScaNN

Indexes operate in two states:

  • Flat (accumulating): Brute-force search over raw vectors. Used when vector count is below build_threshold or before build_index is called.
  • Built (ANN): Fast approximate nearest neighbor search using trained structures. Centroids and codebooks are trained from data and stored within the segment.

Fields§

§dim: usize

Dimensionality of vectors

§index_type: VectorIndexType

Target vector index algorithm (Flat, RaBitQ, IVF-RaBitQ, or ScaNN) When in accumulating state, search uses brute-force regardless of this setting.

§quantization: DenseVectorQuantization

Storage quantization for vector elements (f32, f16, uint8)

§num_clusters: Option<usize>

Number of IVF clusters for IVF-RaBitQ and ScaNN (default: sqrt(n) capped at 4096) If None, automatically determined based on dataset size.

§nprobe: usize

Number of clusters to probe during search (default: 32)

§build_threshold: Option<usize>

Minimum number of vectors required before building ANN index. Below this threshold, brute-force (Flat) search is used. Default: 1000 for RaBitQ, 10000 for IVF-RaBitQ/ScaNN.

§unit_norm: bool

Whether stored vectors are pre-normalized to unit L2 norm. When true, scoring skips per-vector norm computation (cosine = dot / ||q||), reducing compute by ~40%. Common for embedding models (e.g. OpenAI, Cohere). Default: true (most embedding models produce L2-normalized vectors).

§rabitq_bits: Option<u8>

Total RaBitQ bits per dimension for IVF-RaBitQ indexes. 1 = classic binary RaBitQ (default). 2-8 = extended multi-bit codes with much tighter distance estimates — allows lowering rerank_factor (fewer raw-vector reads) at the same recall. Recommended: 4-5 for disk-resident indexes.

§soar: Option<SoarConfig>

SOAR spilled cluster assignments for IVF-based indexes (IVF-RaBitQ, ScaNN). Assigns vectors to a secondary cluster with an orthogonality-amplified residual, improving recall at the same nprobe for ~1.2-2x assignment storage. Default: None (disabled). Ignored for Flat/RaBitQ index types.

Implementations§

Source§

impl DenseVectorConfig

Source

pub fn new(dim: usize) -> Self

Source

pub fn with_ivf(dim: usize, num_clusters: Option<usize>, nprobe: usize) -> Self

Create IVF-RaBitQ configuration

Source

pub fn with_scann( dim: usize, num_clusters: Option<usize>, nprobe: usize, ) -> Self

Create ScaNN configuration

Source

pub fn flat(dim: usize) -> Self

Create Flat (brute-force) configuration - no ANN index

Source

pub fn with_quantization(self, quantization: DenseVectorQuantization) -> Self

Set storage quantization

Source

pub fn with_build_threshold(self, threshold: usize) -> Self

Set build threshold for auto-building ANN index

Source

pub fn with_unit_norm(self) -> Self

Mark vectors as pre-normalized to unit L2 norm

Source

pub fn with_num_clusters(self, num_clusters: usize) -> Self

Set number of IVF clusters

Source

pub fn with_rabitq_bits(self, bits: u8) -> Self

Set RaBitQ total bits per dimension (1 = classic, 2-8 = extended)

Source

pub fn with_soar(self, soar: SoarConfig) -> Self

Enable SOAR spilled secondary cluster assignments (IVF-based indexes only)

Source

pub fn uses_ivf(&self) -> bool

Check if this config uses IVF

Source

pub fn uses_scann(&self) -> bool

Check if this config uses ScaNN

Source

pub fn is_flat(&self) -> bool

Check if this config is flat (brute-force)

Source

pub fn default_build_threshold(&self) -> usize

Get the default build threshold for this index type

Source

pub fn optimal_num_clusters(&self, num_vectors: usize) -> usize

Calculate optimal number of clusters for given vector count

Trait Implementations§

Source§

impl Clone for DenseVectorConfig

Source§

fn clone(&self) -> DenseVectorConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DenseVectorConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DenseVectorConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for DenseVectorConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DropFlavorWrapper<T> for T

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<E> ResultError for E
where E: Send + Debug + Sync,

Source§

impl<T> ResultType for T
where T: Send + Clone + Sync + Debug,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more