pub struct DeltaIndex {
pub dim: usize,
/* private fields */
}Expand description
Secondary in-memory index that absorbs fresh inserts before they are patched into the main HNSW graph.
Fields§
§dim: usizeImplementations§
Source§impl DeltaIndex
impl DeltaIndex
Sourcepub fn new(dim: usize, max_fresh: usize) -> Self
pub fn new(dim: usize, max_fresh: usize) -> Self
Create a new delta index for vectors of dim dimensions.
max_fresh is the capacity threshold above which is_full() returns
true, signalling that a compaction flush should be triggered.
Sourcepub fn insert(&mut self, id: u32, vector: Vec<f32>)
pub fn insert(&mut self, id: u32, vector: Vec<f32>)
Stage a fresh insert. Does not deduplicate — callers must ensure IDs are unique across the delta and the main HNSW.
Sourcepub fn tombstone(&mut self, id: u32)
pub fn tombstone(&mut self, id: u32)
Mark id as tombstoned. It will be excluded from search results
and from the patch applied to the main HNSW.
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Returns true when the number of fresh vectors has reached max_fresh.
Sourcepub fn search(
&self,
query: &[f32],
k: usize,
metric: DistanceMetric,
) -> Vec<(u32, f32)>
pub fn search( &self, query: &[f32], k: usize, metric: DistanceMetric, ) -> Vec<(u32, f32)>
Brute-force scan over fresh vectors (excluding tombstones), returning
the top-k results sorted ascending by distance.
Sourcepub fn drain_fresh(&mut self) -> Vec<(u32, Vec<f32>)>
pub fn drain_fresh(&mut self) -> Vec<(u32, Vec<f32>)>
Drain all staged fresh vectors for patching into the main HNSW.
After this call fresh_len() returns 0.
Sourcepub fn drain_tombstones(&mut self) -> Vec<u32>
pub fn drain_tombstones(&mut self) -> Vec<u32>
Drain the current tombstone set. After this call no IDs are considered tombstoned in this delta.
Sourcepub fn is_tombstoned(&self, id: u32) -> bool
pub fn is_tombstoned(&self, id: u32) -> bool
Returns true if id is currently tombstoned in this delta.
Auto Trait Implementations§
impl Freeze for DeltaIndex
impl RefUnwindSafe for DeltaIndex
impl Send for DeltaIndex
impl Sync for DeltaIndex
impl Unpin for DeltaIndex
impl UnsafeUnpin for DeltaIndex
impl UnwindSafe for DeltaIndex
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> 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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.