AionDB v0.3 is live: vector search becomes a first-class engine surface with pgvector-style SQL, HNSW, IVF-flat, Qdrant-style filters, and published recall/latency benchmarks. See the v0.3 vector update.

aiondb-vector

Vector type support for the engine. Centralises distance functions, index descriptors, quantization codecs, and the planner-side backend registry used by similarity search. The runtime VectorValue itself lives in aiondb-core and is re-exported here.

cargo

[dependencies]
aiondb-vector = { path = "../aiondb-vector" }

modules

modulepurpose
distancedistance functions and the VectorDistance enum.
indexVectorIndexDescriptor and VectorIndexAlgorithmParams.
plannerbuild_vector_search_plan entry points.
planner_backendsbackend trait, registry, and built-in hnsw / ivf_flat backends.
quantizationscalar, binary, and product quantization codecs.
simdarchitecture dispatch for distance kernels (x86, arm, scalar fallback).
typesthin type helpers used by the planner.

key types

itemdescription
VectorValuere-export of the core vector value (element type plus dims).
VectorDistanceL2, Cosine, InnerProduct, Manhattan.
VectorIndexDescriptorcatalog index id, algorithm, params, distance metric.
VectorIndexAlgorithmParamsHnsw(HnswParams) or Custom(BTreeMap<String, String>).
VectorSearchAlgorithm, VectorSearchSpec, VectorSearchPlan, VectorDistanceMetricre-exports from aiondb-plan.
VectorSearchBackend, VectorSearchBackendRegistryextension point for new ANN algorithms.
QuantizationKindNone, Scalar, Binary, Product.
VectorQuantizer traitencode, decode, approx_l2.
ScalarQuantizer / ScalarCodeint8 scalar quantization. Wired into HNSW: trained at index build, used in the layer-0 hot loop, exact rescored against the retained raw vector.
BinaryQuantizer / BinaryCodesign-bit binary quantization, packed Vec<u64>. Wired into HNSW with raw-vector dropped, so the in-index rescore path does not run.
ProductQuantizer / ProductCodeproduct quantization with k-means subspace centroids. Wired into HNSW with subspace count picked by the storage engine (dims / 8 when divisible, else dims / 4, else dims / 2) and k = 256 centroids per subspace.
build_vector_search_plan, build_vector_search_plan_with_registryplanner entry points.
default_vector_search_backend_registryglobal registry pre-loaded with built-in backends.

distance functions

use aiondb_vector::distance::{
    cosine_distance, inner_product, l2_distance, manhattan_distance,
};

let a = [1.0_f32, 0.0, 0.0];
let b = [0.0_f32, 1.0, 0.0];

let _l2 = l2_distance(&a, &b);
let _cos = cosine_distance(&a, &b);
let _ip = inner_product(&a, &b);
let _l1 = manhattan_distance(&a, &b);

quantization runtime

Scalar (sq) and Product (pq) quantization codecs are now trained inside the HNSW storage engine and used end-to-end:

Binary quantization (bq) drops the raw vector entirely, so the in-index rescore path does not apply. The current recall floor on a 64-dim synthetic dataset is locked in by recall_at_k_with_binary_quantization_meets_threshold and will be revisited once heap-fetched rescoring is wired through the executor.

Live inserts arriving before the codebook has been trained (for example, an empty CREATE INDEX followed by individual inserts) fall back to raw f32 storage. Once the index accumulates 256 nodes the storage engine triggers a lazy training pass from the retained raw vectors, back-fills codes for every existing node, and switches subsequent inserts onto the quantized path - no explicit REINDEX required.

example

use aiondb_core::IndexId;
use aiondb_vector::{VectorDistance, VectorIndexDescriptor};

let descriptor = VectorIndexDescriptor::hnsw(
    IndexId::new(7),
    16,
    200,
    VectorDistance::Cosine,
);

assert!(matches!(descriptor.distance_metric, VectorDistance::Cosine));