Crate diskann_rs

Source
Expand description

§DiskAnnRS

A DiskANN-like Rust library implementing approximate nearest neighbor search with single-file storage support. The library provides both Euclidean distance and Cosine similarity metrics, with a three-layer hierarchical search structure.

§Features

  • Single-file storage format
  • Support for both Euclidean and Cosine distance metrics
  • Parallel index construction using Rayon
  • Memory-mapped file access for efficient searches
  • Three-layer hierarchical search structure

§Example

use diskann_rs::{SingleFileDiskANN, DistanceMetric};

// Build a new index
let index = SingleFileDiskANN::build_index_singlefile(
    1000,    // number of vectors
    128,     // dimensionality
    32,      // maximum degree
    0.1,     // fraction of vectors in top layer
    0.2,     // fraction of vectors in middle layer
    DistanceMetric::Euclidean,
    "index.db"
).unwrap();

// Search the index
let query = vec![0.0; 128];  // your query vector
let neighbors = index.search(&query, 10, 64);  // find top 10 with beam width 64

Structs§

SingleFileDiskANN
Main struct representing a DiskANN index

Enums§

DiskAnnError
Custom error type for DiskAnnRS operations
DistanceMetric
Supported distance metrics for vector comparison