pub struct MutableBase { /* private fields */ }Expand description
A graph over capacity slots that is mutated in place.
A slot is live (it holds an id), dead (deleted but still allocated, still routing) or free (reusable). Lists may name dead slots between scans and never name free slots.
Implementations§
Source§impl MutableBase
impl MutableBase
Sourcepub fn new(
dim: usize,
params: &BuildParams,
options: &MutableOptions,
) -> Result<Self, UpdateError>
pub fn new( dim: usize, params: &BuildParams, options: &MutableOptions, ) -> Result<Self, UpdateError>
An empty index of options.max_pts * (1 + slack) slots of dim dimensions.
pub fn dim(&self) -> usize
pub fn metric(&self) -> Metric
pub fn is_empty(&self) -> bool
pub fn stats(&self) -> MutableStats
Sourcepub fn insert_batch(
&mut self,
ids: &[u32],
vectors: &[f32],
) -> Result<(), UpdateError>
pub fn insert_batch( &mut self, ids: &[u32], vectors: &[f32], ) -> Result<(), UpdateError>
Adds vectors (row-major) under ids, all or none. Takes the lowest free slots,
running a repair scan first when there are too few, then links the new slots with the
build’s insertion pass over the live and dead graph.
Sourcepub fn delete_batch(&mut self, ids: &[u32]) -> Result<(), UpdateError>
pub fn delete_batch(&mut self, ids: &[u32]) -> Result<(), UpdateError>
Deletes ids, all or none: each slot is tombstoned and keeps routing until a scan.
pub fn delete(&mut self, id: u32) -> Result<(), UpdateError>
Sourcepub fn search(
&self,
query: &[f32],
k: usize,
ef: usize,
) -> Result<Vec<(f32, u32)>, UpdateError>
pub fn search( &self, query: &[f32], k: usize, ef: usize, ) -> Result<Vec<(f32, u32)>, UpdateError>
The k best live points for query as (score, id), ascending, from a result set of
max(ef, k) live slots. The score is -<q, x> for angular rows and |x|^2 / 2 - <q, x>
for Euclidean rows, computed on the f32 rows.
Sourcepub fn repair_scan(&mut self) -> ScanStats
pub fn repair_scan(&mut self) -> ScanStats
Repairs every live list that names a dead slot, then releases the dead slots to the free list. A slot is released only after every list has been repaired, so no list ever names a free slot. Then the entry is re-elected if it was dead and the routing tree is rebuilt over the live slots.
Sourcepub fn verify(&self, after_scan: bool) -> Result<(), String>
pub fn verify(&self, after_scan: bool) -> Result<(), String>
Checks the invariants of the design note: I1 (degree, no self edge, no duplicate, ids in
range), I2 (no list names a free slot; after a scan, after_scan, none names a dead
slot either), I3 (every live slot is reachable from the entry over list and routing
edges), I4 (the entry is allocated, and live after a scan) and I6 (id_to_slot and
slot_to_id are inverse; dead and free slots hold no id). Costs O(capacity * degree).
Auto Trait Implementations§
impl Freeze for MutableBase
impl RefUnwindSafe for MutableBase
impl Send for MutableBase
impl Sync for MutableBase
impl Unpin for MutableBase
impl UnsafeUnpin for MutableBase
impl UnwindSafe for MutableBase
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.