pub struct HnswConfig {
pub m: usize,
pub m_max: usize,
pub ef_construction: usize,
pub ef_search: usize,
pub parallel_construction: bool,
pub num_threads: usize,
}Expand description
HNSW index configuration.
These parameters control the trade-off between search accuracy, speed, and memory usage.
Fields§
§m: usizeMaximum number of connections per element per layer.
Higher values improve search quality but use more memory. Typical values: 12-48. Default: 16.
m_max: usizeMaximum number of connections for the first layer.
Usually set to 2 * M. Default: 32.
ef_construction: usizeSize of the dynamic candidate list during construction.
Higher values improve index quality but slow down construction. Typical values: 100-500. Default: 200.
ef_search: usizeSize of the dynamic candidate list during search.
Higher values improve search quality but slow down search. Must be >= k (number of results). Default: 100.
parallel_construction: boolEnable parallel index construction.
Uses multiple threads to speed up batch insertions.
num_threads: usizeNumber of threads for parallel operations (0 = auto).
Implementations§
Source§impl HnswConfig
impl HnswConfig
Sourcepub fn fast() -> Self
pub fn fast() -> Self
Create a configuration optimized for speed.
Lower accuracy but faster search and construction.
Sourcepub fn accurate() -> Self
pub fn accurate() -> Self
Create a configuration optimized for accuracy.
Higher accuracy but slower search and uses more memory.
Sourcepub fn memory_efficient() -> Self
pub fn memory_efficient() -> Self
Create a configuration optimized for memory efficiency.
Lower memory usage but may have lower accuracy.
Sourcepub fn with_ef_construction(self, ef: usize) -> Self
pub fn with_ef_construction(self, ef: usize) -> Self
Set the ef_construction parameter.
Sourcepub fn with_ef_search(self, ef: usize) -> Self
pub fn with_ef_search(self, ef: usize) -> Self
Set the ef_search parameter.
Sourcepub fn with_num_threads(self, n: usize) -> Self
pub fn with_num_threads(self, n: usize) -> Self
Set the number of threads for parallel operations.
Trait Implementations§
Source§impl Clone for HnswConfig
impl Clone for HnswConfig
Source§impl Debug for HnswConfig
impl Debug for HnswConfig
Auto Trait Implementations§
impl Freeze for HnswConfig
impl RefUnwindSafe for HnswConfig
impl Send for HnswConfig
impl Sync for HnswConfig
impl Unpin for HnswConfig
impl UnsafeUnpin for HnswConfig
impl UnwindSafe for HnswConfig
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
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> 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> ⓘ
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> ⓘ
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