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;
28pub mod vamana;
29
30pub use distance::DistanceMetric;
31pub use error::VectorError;
32pub use hnsw::{HnswIndex, HnswParams, SearchResult};
33pub use nodedb_types::Surrogate;
34pub use quantize::Sq8Codec;
35
36// NaviX adaptive-local filtered traversal (VLDB 2025).
37pub mod navix;
38
39// SIEVE workload-driven subindex collection for stable predicates (SIEVE 2025).
40pub mod sieve;
41
42// Cost-based multidimensional vector query planner.
43pub mod planner;
44
45// Origin-only modules (always compiled for native targets).
46pub mod adaptive_filter;
47pub mod flat;
48pub mod index_config;
49
50// IVF-PQ index (large datasets).
51pub mod ivf;
52
53// NVMe mmap tier (requires libc + memmap2; not available on wasm32).
54#[cfg(not(target_arch = "wasm32"))]
55pub mod mmap_segment;
56
57// Storage abstraction for HNSW vector data (Origin + Lite impls).
58#[cfg(not(target_arch = "wasm32"))]
59pub mod segment_backing;
60
61// Background HNSW builder thread (depends on collection; not on wasm32).
62#[cfg(not(target_arch = "wasm32"))]
63pub mod builder;
64
65// Full VectorCollection with segment lifecycle (not on wasm32).
66#[cfg(not(target_arch = "wasm32"))]
67pub mod collection;
68
69// Re-exports for unconditionally compiled types.
70pub use adaptive_filter::{
71 FilterStrategy, FilterThresholds, adaptive_search, estimate_selectivity, select_strategy,
72};
73#[cfg(not(target_arch = "wasm32"))]
74pub use builder::{BuildSender, CompleteReceiver};
75#[cfg(not(target_arch = "wasm32"))]
76pub use collection::{BuildComplete, BuildRequest, StorageTier, VectorCollection};
77pub use flat::FlatIndex;
78pub use index_config::{IndexConfig, IndexType};
79pub use ivf::{IvfPqIndex, IvfPqParams};
80#[cfg(not(target_arch = "wasm32"))]
81pub use segment_backing::{PlainMmapBacking, VectorSegmentBacking};