pub struct Hnsw { /* private fields */ }Expand description
One shard’s ANN graph for one index.
Implementations§
Source§impl Hnsw
impl Hnsw
Sourcepub fn vectors(&self) -> u64
pub fn vectors(&self) -> u64
Live (non-tombstoned) vectors — already tracked, so O(1).
Self::stats walks every node and every link to estimate bytes;
a caller that only wants the count should not trigger that walk.
Sourcepub fn stats(&self) -> VectorStats
pub fn stats(&self) -> VectorStats
Counters — O(1): links_total and tombstones
are maintained at the three mutation sites (link push, shrink,
tombstoning) instead of walking every node per call (this ran
on every tiering tick). [Self::recompute_stats] is the
walking reference the tests hold them to.
Source§impl Hnsw
impl Hnsw
Sourcepub fn new(dim: usize, params: HnswParams) -> Self
pub fn new(dim: usize, params: HnswParams) -> Self
Empty graph for dim-dimensional vectors.
Sourcepub fn apply(&mut self, key: &[u8], vector: Option<Vec<f32>>)
pub fn apply(&mut self, key: &[u8], vector: Option<Vec<f32>>)
Insert or replace key’s vector (None = remove). Replace =
detach old key (tombstone the node once keyless) + insert new.
Keys sharing one exact vector share one graph node.
Auto Trait Implementations§
impl Freeze for Hnsw
impl RefUnwindSafe for Hnsw
impl Send for Hnsw
impl Sync for Hnsw
impl Unpin for Hnsw
impl UnsafeUnpin for Hnsw
impl UnwindSafe for Hnsw
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