reflex/vectordb/mod.rs
1//! Qdrant vector database integration.
2//!
3//! - [`QdrantClient`] is the direct client.
4//! - [`bq`] adds binary-quantization utilities and a BQ-optimized client.
5
6/// Binary quantization helpers and BQ client.
7pub mod bq;
8/// Direct Qdrant client and trait.
9pub mod client;
10/// Vector DB error types.
11pub mod error;
12#[cfg(any(test, feature = "mock"))]
13/// In-memory vector DB mock (enabled with `mock` feature).
14pub mod mock;
15/// Shared vector DB model types.
16pub mod model;
17/// Full-precision rescoring utilities.
18pub mod rescoring;
19
20#[cfg(test)]
21mod tests;
22
23pub use client::{QdrantClient, VectorDbClient};
24pub use error::VectorDbError;
25#[cfg(any(test, feature = "mock"))]
26pub use mock::{MockVectorDbClient, cosine_similarity};
27pub use model::{
28 SearchResult, VectorPoint, embedding_bytes_to_f32, f32_to_embedding_bytes, generate_point_id,
29};
30
31/// Default non-BQ collection name.
32pub const DEFAULT_COLLECTION_NAME: &str = "reflex_cache";
33
34/// Default vector size for non-BQ collections.
35pub const DEFAULT_VECTOR_SIZE: u64 = crate::constants::DEFAULT_VECTOR_SIZE_U64;
36
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
38/// Write-consistency mode for Qdrant upserts/deletes.
39pub enum WriteConsistency {
40 /// Wait for the operation to be fully indexed and searchable.
41 /// Slow, but ensures read-after-write consistency.
42 /// Maps to `wait=true`.
43 Strong,
44 /// Return immediately after the server acknowledges receipt.
45 /// Fast, but data may not be searchable immediately.
46 /// Maps to `wait=false`.
47 Eventual,
48}
49
50impl From<WriteConsistency> for bool {
51 fn from(c: WriteConsistency) -> bool {
52 matches!(c, WriteConsistency::Strong)
53 }
54}