hannoy
A production-ready, key-value-backed HNSW vector search implementation in Rust using LMDB.
Repository Health
Technical Analysis
Hannoy is a Rust approximate nearest neighbors library that implements the HNSW (Hierarchical Navigable Small World) graph algorithm on top of the LMDB memory-mapped key-value store. Derived from arroy, it swaps in-memory graphs for disk-backed storage so you can index datasets that would not fit in RAM.
Because LMDB supports non-blocking concurrent reads by design, hannoy indexes are safe to query from multi-threaded environments, and its use of compressed roaring bitmaps keeps per-vector overhead small. It ships with Python bindings via PyO3 and maturin in addition to its native Rust API.
What You Get
- A disk-backed HNSW approximate nearest-neighbor index built on LMDB
- Euclidean, cosine, Manhattan, and Hamming metrics plus quantized counterparts
- Native Rust and Python bindings with dynamic insertions and deletions
Common Use Cases
- Running HNSW vector search on machines where the dataset exceeds available RAM
- Querying an ANN index concurrently from multiple threads or processes
- Maintaining an index with ongoing document inserts and deletions without full re-indexing
Under The Hood
Architecture
Hannoy builds a hierarchical navigable small-world graph whose nodes and edges are serialized into LMDB via the heed wrapper. Graph edges are stored as compressed roaring bitmaps to minimize per-vector overhead, and queries navigate the multi-layer graph using ef_search/ef_construction parameters. A writer/builder/reader split governs the index lifecycle.
Tech Stack
Rust (edition 2021) with a cdylib+rlib crate type for Python interop. Key dependencies include heed (LMDB), bytemuck, hashbrown, min-max-heap, papaya, rayon, roaring, rustc-hash, tinyvec, and thiserror; Python bindings use PyO3 and maturin.
Code Quality
Described as production-ready, with a tests directory, benches, CodSpeed performance tracking, and CHANGELOG discipline. It inherits design patterns from the battle-tested arroy project.
API Design
The Rust API mirrors arroy’s ergonomic Writer/Reader pattern with builder-style tuning (ef_construction, ef_search), and the parallel Python API keeps the same mental model for data-science users.