Skip to main content

nodedb_types/
vector_ann.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Runtime ANN tuning options threaded from SQL planner → Data Plane.
4//!
5//! Mirrors `nodedb_sql::types::VectorAnnOptions` but lives in `nodedb-types`
6//! so the wire-codec types in `nodedb` (which cannot depend on `nodedb-sql`)
7//! can serialize them across the SPSC bridge.
8
9#[derive(
10    Debug,
11    Clone,
12    Default,
13    PartialEq,
14    serde::Serialize,
15    serde::Deserialize,
16    zerompk::ToMessagePack,
17    zerompk::FromMessagePack,
18)]
19pub struct VectorAnnOptions {
20    pub quantization: Option<VectorQuantization>,
21    pub oversample: Option<u8>,
22    pub query_dim: Option<u32>,
23    pub meta_token_budget: Option<u8>,
24    pub ef_search_override: Option<usize>,
25    pub target_recall: Option<f32>,
26}
27
28#[derive(
29    Debug,
30    Clone,
31    Copy,
32    Default,
33    PartialEq,
34    Eq,
35    serde::Serialize,
36    serde::Deserialize,
37    zerompk::ToMessagePack,
38    zerompk::FromMessagePack,
39)]
40#[non_exhaustive]
41pub enum VectorQuantization {
42    #[default]
43    None,
44    Sq8,
45    Pq,
46    RaBitQ,
47    Bbq,
48    Binary,
49    Ternary,
50    Opq,
51}