Expand description
§DiskAnn (generic over anndists::Distance<f32>)
A minimal, on-disk, DiskANN-like library that:
- Builds a Vamana-style graph (greedy + α-pruning) in memory
- Writes vectors + fixed-degree adjacency to a single file
- Memory-maps the file for low-overhead reads
- Is generic over any Distance
from anndists(L2, Cosine, Hamming, Dot, …)
§Example
use anndists::dist::{DistL2, DistCosine};
use diskann_rs::{DiskANN, DiskAnnParams};
// Build a new index from vectors, using L2 and default params
let vectors = vec![vec![0.0; 128]; 1000];
let index = DiskANN::<DistL2>::build_index_default(&vectors, DistL2{}, "index.db").unwrap();
// Or with custom params
let index2 = DiskANN::<DistCosine>::build_index_with_params(
&vectors,
DistCosine{},
"index_cos.db",
DiskAnnParams { max_degree: 48, ..Default::default() },
).unwrap();
// Search the index
let query = vec![0.0; 128];
let neighbors = index.search(&query, 10, 64);
// Open later (provide the same distance type)
let _reopened = DiskANN::<DistL2>::open_index_default_metric("index.db").unwrap();§File Layout
[ metadata_len:u64 ][ metadata (bincode) ][ padding up to vectors_offset ] [ vectors (num * dim * f32) ][ adjacency (num * max_degree * u32) ]
vectors_offset is a fixed 1 MiB gap by default.
Structs§
- DiskANN
- Main struct representing a DiskANN index (generic over distance)
- Disk
AnnParams - Optional bag of knobs if you want to override just a few.
Enums§
- Disk
AnnError - Custom error type for DiskAnnRS operations
Constants§
- DISKANN_
DEFAULT_ ALPHA - DISKANN_
DEFAULT_ BUILD_ BEAM - DISKANN_
DEFAULT_ MAX_ DEGREE - Defaults for in-memory DiskANN builds