pub struct IqdbConfig { /* private fields */ }Expand description
Construction-time configuration for an Iqdb handle.
Build one with IqdbConfig::new and chain the optional overrides. Pass
it to Iqdb::open_in_memory_with or
Iqdb::open_with.
§Examples
use iqdb::{CacheConfig, DistanceMetric, IndexKind, IqdbConfig, IvfConfig};
let cfg = IqdbConfig::new(64, DistanceMetric::Euclidean)
.index(IndexKind::Ivf(IvfConfig::default().with_n_clusters(256)))
.cache(CacheConfig::new().capacity(10_000));
assert_eq!(cfg.dim(), 64);
assert_eq!(cfg.metric(), DistanceMetric::Euclidean);Implementations§
Source§impl IqdbConfig
impl IqdbConfig
Sourcepub fn new(dim: usize, metric: DistanceMetric) -> Self
pub fn new(dim: usize, metric: DistanceMetric) -> Self
Start a config for a dim-dimensional database compared under
metric. Defaults to an exact IndexKind::Flat index with no
cache.
§Examples
use iqdb::{DistanceMetric, IqdbConfig};
let cfg = IqdbConfig::new(3, DistanceMetric::Cosine);
assert_eq!(cfg.dim(), 3);Sourcepub fn index(self, kind: IndexKind) -> Self
pub fn index(self, kind: IndexKind) -> Self
Select the index implementation (and its tuning).
§Examples
use iqdb::{DistanceMetric, HnswConfig, IndexKind, IqdbConfig};
let cfg = IqdbConfig::new(128, DistanceMetric::Cosine)
.index(IndexKind::Hnsw(HnswConfig::default().with_m(32)));
assert!(matches!(cfg.index_kind(), IndexKind::Hnsw(_)));Sourcepub fn cache(self, cache: CacheConfig) -> Self
pub fn cache(self, cache: CacheConfig) -> Self
Wrap searches in a result cache with the given configuration. Without this call the database is uncached (correct, just not memoized).
§Examples
use iqdb::{CacheConfig, DistanceMetric, IqdbConfig};
let cfg = IqdbConfig::new(16, DistanceMetric::Cosine)
.cache(CacheConfig::new().capacity(4_096));
assert!(cfg.is_cached());Sourcepub fn fsync(self, policy: FsyncPolicy) -> Self
pub fn fsync(self, policy: FsyncPolicy) -> Self
Set the write-ahead-log fsync cadence for the durable, file-backed path. Ignored by an in-memory database.
The default, FsyncPolicy::Always, makes every acknowledged write
durable before it returns. FsyncPolicy::Periodic bounds the
un-synced window for throughput; FsyncPolicy::Never is for tests
and tmpfs-backed paths only.
§Examples
use iqdb::{DistanceMetric, FsyncPolicy, IqdbConfig};
use std::time::Duration;
let cfg = IqdbConfig::new(16, DistanceMetric::Cosine)
.fsync(FsyncPolicy::Periodic(Duration::from_millis(50)));Sourcepub fn compression(self, compression: Compression) -> Self
pub fn compression(self, compression: Compression) -> Self
Set the snapshot compression for the durable, file-backed path. Ignored by an in-memory database.
Compression::Zstd and Compression::Lz4 require the matching
zstd / lz4 cargo feature; opening with one whose feature is not
compiled in fails with Error::Persist.
The default is Compression::None.
§Examples
use iqdb::{Compression, DistanceMetric, IqdbConfig};
let cfg = IqdbConfig::new(16, DistanceMetric::Cosine)
.compression(Compression::Zstd { level: 3 });Sourcepub fn metric(&self) -> DistanceMetric
pub fn metric(&self) -> DistanceMetric
The configured distance metric.
Sourcepub fn index_kind(&self) -> IndexKind
pub fn index_kind(&self) -> IndexKind
The configured index kind.
Trait Implementations§
Source§impl Clone for IqdbConfig
impl Clone for IqdbConfig
Source§fn clone(&self) -> IqdbConfig
fn clone(&self) -> IqdbConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for IqdbConfig
impl RefUnwindSafe for IqdbConfig
impl Send for IqdbConfig
impl Sync for IqdbConfig
impl Unpin for IqdbConfig
impl UnsafeUnpin for IqdbConfig
impl UnwindSafe for IqdbConfig
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
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