pub struct IncrementalDiskANN<D>{ /* private fields */ }Expand description
An incremental DiskANN index supporting add/delete without full rebuild
Implementations§
Source§impl<D> IncrementalDiskANN<D>
impl<D> IncrementalDiskANN<D>
Sourcepub fn build_default(
vectors: &[Vec<f32>],
file_path: &str,
) -> Result<Self, DiskAnnError>
pub fn build_default( vectors: &[Vec<f32>], file_path: &str, ) -> Result<Self, DiskAnnError>
Build a new incremental index with default parameters
Sourcepub fn open(path: &str) -> Result<Self, DiskAnnError>
pub fn open(path: &str) -> Result<Self, DiskAnnError>
Open an existing index for incremental updates
Source§impl<D> IncrementalDiskANN<D>
impl<D> IncrementalDiskANN<D>
Sourcepub fn build_with_config(
vectors: &[Vec<f32>],
file_path: &str,
config: IncrementalConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
pub fn build_with_config(
vectors: &[Vec<f32>],
file_path: &str,
config: IncrementalConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
Build a new incremental index with custom configuration
Sourcepub fn open_with_config(
path: &str,
config: IncrementalConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
pub fn open_with_config(
path: &str,
config: IncrementalConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
Open an existing index with custom configuration
Sourcepub fn new_empty(dim: usize, dist: D, config: IncrementalConfig) -> Self
pub fn new_empty(dim: usize, dist: D, config: IncrementalConfig) -> Self
Create an empty incremental index (no base, delta-only)
Sourcepub fn build_with_labels(
vectors: &[Vec<f32>],
labels: &[Vec<u64>],
file_path: &str,
config: IncrementalConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
pub fn build_with_labels(
vectors: &[Vec<f32>],
labels: &[Vec<u64>],
file_path: &str,
config: IncrementalConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
Build an incremental index with per-vector labels for filtered search.
Sourcepub fn build_quantized_f16(
vectors: &[Vec<f32>],
file_path: &str,
config: IncrementalConfig,
quant_config: IncrementalQuantizedConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
pub fn build_quantized_f16(
vectors: &[Vec<f32>],
file_path: &str,
config: IncrementalConfig,
quant_config: IncrementalQuantizedConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
Build an incremental index with F16 quantization.
Sourcepub fn build_quantized_int8(
vectors: &[Vec<f32>],
file_path: &str,
config: IncrementalConfig,
quant_config: IncrementalQuantizedConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
pub fn build_quantized_int8(
vectors: &[Vec<f32>],
file_path: &str,
config: IncrementalConfig,
quant_config: IncrementalQuantizedConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
Build an incremental index with Int8 quantization.
Sourcepub fn build_quantized_pq(
vectors: &[Vec<f32>],
file_path: &str,
config: IncrementalConfig,
pq_config: PQConfig,
quant_config: IncrementalQuantizedConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
pub fn build_quantized_pq(
vectors: &[Vec<f32>],
file_path: &str,
config: IncrementalConfig,
pq_config: PQConfig,
quant_config: IncrementalQuantizedConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
Build an incremental index with PQ quantization.
Sourcepub fn build_full(
vectors: &[Vec<f32>],
labels: &[Vec<u64>],
file_path: &str,
config: IncrementalConfig,
quantizer_kind: QuantizerKind,
quant_config: IncrementalQuantizedConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
pub fn build_full(
vectors: &[Vec<f32>],
labels: &[Vec<u64>],
file_path: &str,
config: IncrementalConfig,
quantizer_kind: QuantizerKind,
quant_config: IncrementalQuantizedConfig,
) -> Result<Self, DiskAnnError>where
D: Default,
Build an incremental index with labels AND quantization.
Sourcepub fn add_vectors(
&self,
vectors: &[Vec<f32>],
) -> Result<Vec<u64>, DiskAnnError>
pub fn add_vectors( &self, vectors: &[Vec<f32>], ) -> Result<Vec<u64>, DiskAnnError>
Add new vectors to the index. Returns their assigned IDs.
Sourcepub fn add_vectors_with_labels(
&self,
vectors: &[Vec<f32>],
labels: &[Vec<u64>],
) -> Result<Vec<u64>, DiskAnnError>
pub fn add_vectors_with_labels( &self, vectors: &[Vec<f32>], labels: &[Vec<u64>], ) -> Result<Vec<u64>, DiskAnnError>
Add new vectors with labels to the index. Returns their assigned IDs.
Sourcepub fn delete_vectors(&self, ids: &[u64]) -> Result<(), DiskAnnError>
pub fn delete_vectors(&self, ids: &[u64]) -> Result<(), DiskAnnError>
Delete vectors by their IDs (lazy deletion via tombstones)
Sourcepub fn is_deleted(&self, id: u64) -> bool
pub fn is_deleted(&self, id: u64) -> bool
Check if a vector ID has been deleted
Sourcepub fn search(&self, query: &[f32], k: usize, beam_width: usize) -> Vec<u64>
pub fn search(&self, query: &[f32], k: usize, beam_width: usize) -> Vec<u64>
Search the index, merging results from base and delta, excluding tombstones
Sourcepub fn search_with_dists(
&self,
query: &[f32],
k: usize,
beam_width: usize,
) -> Vec<(u64, f32)>
pub fn search_with_dists( &self, query: &[f32], k: usize, beam_width: usize, ) -> Vec<(u64, f32)>
Search returning (id, distance) pairs
Sourcepub fn search_filtered(
&self,
query: &[f32],
k: usize,
beam_width: usize,
filter: &Filter,
) -> Vec<u64>
pub fn search_filtered( &self, query: &[f32], k: usize, beam_width: usize, filter: &Filter, ) -> Vec<u64>
Search with a filter predicate (requires labels).
Sourcepub fn search_filtered_with_dists(
&self,
query: &[f32],
k: usize,
beam_width: usize,
filter: &Filter,
) -> Vec<(u64, f32)>
pub fn search_filtered_with_dists( &self, query: &[f32], k: usize, beam_width: usize, filter: &Filter, ) -> Vec<(u64, f32)>
Search with filter, returning (id, distance) pairs.
Sourcepub fn search_batch(
&self,
queries: &[Vec<f32>],
k: usize,
beam_width: usize,
) -> Vec<Vec<u64>>
pub fn search_batch( &self, queries: &[Vec<f32>], k: usize, beam_width: usize, ) -> Vec<Vec<u64>>
Parallel batch search
Sourcepub fn get_vector(&self, id: u64) -> Option<Vec<f32>>
pub fn get_vector(&self, id: u64) -> Option<Vec<f32>>
Get a vector by its ID (works for both base and delta)
Sourcepub fn should_compact(&self) -> bool
pub fn should_compact(&self) -> bool
Check if compaction is recommended
Sourcepub fn compact(&mut self, new_path: &str) -> Result<(), DiskAnnError>where
D: Default,
pub fn compact(&mut self, new_path: &str) -> Result<(), DiskAnnError>where
D: Default,
Compact the index: merge base + delta, remove tombstones, write new file
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize the entire incremental index to bytes.
New format (v1):
[magic:u32 = 0x494E4352]["INCR"]
[version:u32 = 1]
[has_base:u8][base_len:u64][base_bytes...]
[dim:u64]
[num_delta:u64][delta_vectors flat]
[num_delta_graph:u64][graph data]
[entry_point:i64]
[max_degree:u64]
[num_tombstones:u64][tombstone_ids]
[has_labels:u8]
if has_labels:
[num_label_fields:u64]
[num_base_labels:u64][base_labels flat]
[num_delta_labels:u64][delta_labels flat]
[has_quantizer:u8]
if has_quantizer:
[code_size:u64]
[rerank_size:u64]
[quantizer_data_len:u64][quantizer_data]
[base_codes_len:u64][base_codes]Sourcepub fn from_bytes(
bytes: &[u8],
dist: D,
config: IncrementalConfig,
) -> Result<Self, DiskAnnError>
pub fn from_bytes( bytes: &[u8], dist: D, config: IncrementalConfig, ) -> Result<Self, DiskAnnError>
Load an incremental index from bytes.
Supports both old format (has_base byte first) and new format (INCR magic).
Sourcepub fn stats(&self) -> IncrementalStats
pub fn stats(&self) -> IncrementalStats
Get statistics about the index
Sourcepub fn has_labels(&self) -> bool
pub fn has_labels(&self) -> bool
Whether this index has labels configured.
Sourcepub fn has_quantizer(&self) -> bool
pub fn has_quantizer(&self) -> bool
Whether this index has quantization configured.
Auto Trait Implementations§
impl<D> !Freeze for IncrementalDiskANN<D>
impl<D> RefUnwindSafe for IncrementalDiskANN<D>where
D: RefUnwindSafe,
impl<D> Send for IncrementalDiskANN<D>
impl<D> Sync for IncrementalDiskANN<D>
impl<D> Unpin for IncrementalDiskANN<D>where
D: Unpin,
impl<D> UnwindSafe for IncrementalDiskANN<D>where
D: UnwindSafe,
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> 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