- Exact search — scans every vector, computes the true distance, returns the top-
k; always correct, never approximate - Ground truth — the reference every approximate index (HNSW, IVF) is measured against via recall@k
- Deterministic — one smaller-is-nearer ordering across all five metrics, with a stable insertion-order tiebreaker and NaN-safe selection
- Fast where it counts — SIMD distance via
iqdb-distance, a bounded-heapO(n log k)top-k, amortizedO(1)insert/delete, and an optional rayon parallel scan - Right for small data — the obvious choice under ~10k vectors, where graph or partition overhead is not justified
Installation
[]
= "0.4"
# Optional rayon-backed parallel scan for large in-memory corpora:
# iqdb-flat = { version = "0.4", features = ["parallel"] }
Quick Start
use Arc;
use ;
use ;
use ;
Filtered search restricts the scan to rows whose metadata matches, evaluated before distance work so a selective filter skips proportionally:
# use ;
# use ;
use ;
#
The complete surface — every method, parameter, error, and more examples — is in
docs/API.md.
Performance
- Distance is delegated to
iqdb-distance, which dispatches to SIMD kernels (AVX2/NEON) where the target allows; flat never reimplements a metric. - Top-
kuses a bounded max-heap of sizekkeyed by(distance, sequence)—O(n log k), NaN-safe viaf32::total_cmp. - Insert / delete are amortized
O(1): aHashMapid→position map for duplicate checks,swap_removefor deletion, and a monotonic sequence stamp so reordering never disturbs the tiebreaker. - No-filter search allocates a fixed number of buffers independent of corpus size (locked in by
tests/no_alloc.rs). parallelfeature adds a rayon chunked scan that is byte-identical to the sequential baseline (tests/parallel_equivalence.rs); small corpora short-circuit to sequential.
Status
v0.4.0 is feature-complete: exact search, top-k, the full Index /
IndexCore trait implementation, the optional parallel scan, and metadata
pre-filtering all ship and are covered by unit, property, differential, and
scale tests. Remaining work to 1.0 is API finalisation, polish, and final
benchmarks per the ROADMAP.
Where It Fits
iqdb-flat is a Phase-3 index. It builds on:
iqdb-types— vectors, ids, metadataiqdb-distance— the distance kernelsiqdb-index— implements theIndextraitiqdb-eval— uses it to generate ground truth
It is unblocked once iqdb-index exists; no external dependency.
Contributing
See dev/DIRECTIVES.md for engineering standards and the definition of done. Before a PR: cargo fmt --all, cargo clippy --all-targets --all-features -- -D warnings, and cargo test --all-features must be clean.