nodedb_vector/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2
3//! Vector search primitives shared by Origin, Lite, and WASM: HNSW + Vamana
4//! indexes, scalar / SIMD distance kernels, the quantization codec frontier
5//! (SQ8, PQ, IVF-PQ, OPQ, RaBitQ, BBQ, Ternary BitNet 1.58, Binary), the
6//! VectorCollection runtime with mmap NVMe segments and background builder,
7//! and the cost-model planner inputs (target_recall, oversample, ef_search,
8//! query_dim, meta_token_budget, quantization).
9//!
10//! This crate has no platform-required cargo features for v0.1.0 — SIMD
11//! kernels are gated by `#[cfg(target_arch)]` and dispatch happens at
12//! runtime. The optional `acorn-baseline` feature retains the old ACORN-1
13//! filtered-traversal heuristic for benchmarking against NaviX; not for
14//! production use.
15
16pub mod batch_distance;
17pub mod codec_index;
18pub mod delta;
19pub mod distance;
20pub mod dtype;
21pub mod error;
22pub mod hnsw;
23pub mod hybrid;
24pub mod matryoshka;
25pub mod multivec;
26pub mod quantize;
27pub mod rerank;
28#[cfg(test)]
29mod test_support;
30pub mod vamana;
31
32pub use distance::DistanceMetric;
33pub use error::VectorError;
34pub use hnsw::{HnswIndex, HnswParams, SearchResult};
35pub use nodedb_types::Surrogate;
36pub use quantize::Sq8Codec;
37
38// NaviX adaptive-local filtered traversal (VLDB 2025).
39pub mod navix;
40
41// SIEVE workload-driven subindex collection for stable predicates (SIEVE 2025).
42pub mod sieve;
43
44// Cost-based multidimensional vector query planner.
45pub mod planner;
46
47// Origin-only modules (always compiled for native targets).
48pub mod adaptive_filter;
49pub mod flat;
50pub mod index_config;
51
52// IVF-PQ index (large datasets).
53pub mod ivf;
54
55// NVMe mmap tier (requires libc + memmap2; not available on wasm32).
56#[cfg(not(target_arch = "wasm32"))]
57pub mod mmap_segment;
58
59// Storage abstraction for HNSW vector data (Origin + Lite impls).
60#[cfg(not(target_arch = "wasm32"))]
61pub mod segment_backing;
62
63// Background HNSW builder thread (depends on collection; not on wasm32).
64#[cfg(not(target_arch = "wasm32"))]
65pub mod builder;
66
67// Full VectorCollection with segment lifecycle (not on wasm32).
68#[cfg(not(target_arch = "wasm32"))]
69pub mod collection;
70
71// Re-exports for unconditionally compiled types.
72pub use adaptive_filter::{
73 FilterStrategy, FilterThresholds, adaptive_search, estimate_selectivity, select_strategy,
74};
75#[cfg(not(target_arch = "wasm32"))]
76pub use builder::{BuildSender, CompleteReceiver};
77#[cfg(not(target_arch = "wasm32"))]
78pub use collection::{BuildComplete, BuildKind, BuildRequest, StorageTier, VectorCollection};
79pub use flat::FlatIndex;
80pub use index_config::{IndexConfig, IndexType};
81pub use ivf::{IvfPqIndex, IvfPqParams};
82#[cfg(not(target_arch = "wasm32"))]
83pub use segment_backing::{PlainMmapBacking, VectorSegmentBacking};