pub struct HnswBackend { /* private fields */ }Expand description
HNSW vector backend wrapping HnswService.
Implementations§
Source§impl HnswBackend
impl HnswBackend
Sourcepub fn new(config: HnswServiceConfig) -> Self
pub fn new(config: HnswServiceConfig) -> Self
Create a new HNSW backend with the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default configuration.
Sourcepub fn with_max_vectors(config: HnswServiceConfig, limit: usize) -> Self
pub fn with_max_vectors(config: HnswServiceConfig, limit: usize) -> Self
Create with a capacity limit.
Sourcepub fn inner(&self) -> &HnswService
pub fn inner(&self) -> &HnswService
Access the underlying HnswService for legacy code paths.
Sourcepub fn save_to_file(&self, path: &Path) -> VectorResult<()>
pub fn save_to_file(&self, path: &Path) -> VectorResult<()>
Persist backend state (vectors, id map, tombstones, epoch, capacity).
Soft-deleted entries remain in the vector list but are recorded in
the tombstones section so they stay excluded after
[load_from_file]. See module docs for the compaction story.
Sourcepub fn load_from_file(path: &Path) -> VectorResult<Self>
pub fn load_from_file(path: &Path) -> VectorResult<Self>
Load a backend from a snapshot written by [save_to_file].
Backward compatible: files produced by plain HnswStore /
HnswService save (entries + ef params only) load successfully
with empty id_map, empty tombstones, epoch 0, and no capacity
limit.
Trait Implementations§
Source§impl Debug for HnswBackend
impl Debug for HnswBackend
Source§impl VectorBackend for HnswBackend
impl VectorBackend for HnswBackend
Source§fn insert(
&self,
id: u64,
key: &str,
vector: &[f32],
metadata: Value,
) -> VectorResult<()>
fn insert( &self, id: u64, key: &str, vector: &[f32], metadata: Value, ) -> VectorResult<()>
Insert a vector with the given numeric ID, string key, and metadata. Read more
Source§fn backend_name(&self) -> &str
fn backend_name(&self) -> &str
Return a human-readable name for this backend (e.g. “hnsw”, “diskann”, “hybrid”).
Source§fn current_epoch(&self) -> u64
fn current_epoch(&self) -> u64
Return the current monotonic epoch. Read more
Source§fn insert_with_epoch(
&self,
id: u64,
key: &str,
vector: &[f32],
metadata: Value,
parent_epoch: u64,
) -> VectorResult<()>
fn insert_with_epoch( &self, id: u64, key: &str, vector: &[f32], metadata: Value, parent_epoch: u64, ) -> VectorResult<()>
Insert a vector only if the store’s current epoch matches
parent_epoch. If the epoch has advanced past parent_epoch,
the call is rejected with VectorError::EpochConflict. Read moreSource§fn soft_delete(&self, id: u64) -> bool
fn soft_delete(&self, id: u64) -> bool
Mark a vector as tombstoned instead of physically removing it. Read more
Source§fn compact(&self, older_than_epoch: u64) -> usize
fn compact(&self, older_than_epoch: u64) -> usize
Physically remove tombstones whose deletion epoch is older than
older_than_epoch. Returns the number of entries purged.Source§fn tombstone_count(&self) -> usize
fn tombstone_count(&self) -> usize
Return the number of tombstoned (soft-deleted) entries.
Source§fn max_vectors(&self) -> Option<usize>
fn max_vectors(&self) -> Option<usize>
Return the configured maximum number of vectors, or
None if
unbounded.Source§fn set_max_vectors(&self, limit: Option<usize>)
fn set_max_vectors(&self, limit: Option<usize>)
Set the maximum number of vectors. Pass
None for unbounded.Auto Trait Implementations§
impl !Freeze for HnswBackend
impl RefUnwindSafe for HnswBackend
impl Send for HnswBackend
impl Sync for HnswBackend
impl Unpin for HnswBackend
impl UnsafeUnpin for HnswBackend
impl UnwindSafe for HnswBackend
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> 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 more