Skip to main content

uqa_execution/query/table_sources/
retrieval.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7use uqa_core::ScoredEntry;
8use uqa_sql::{SQLError, SQLParam, ScalarExpr};
9pub enum DirectVectorRetrieval {
10    Knn {
11        top_k: usize,
12    },
13    Calibrated {
14        field: String,
15        query_vector: Vec<f32>,
16        top_k: usize,
17        threshold: Option<f64>,
18    },
19}
20/// Retrieval access is selected by the statement snapshot; committed reads are requested only for tuple rechecks.
21pub trait RetrievalAccess: Sync {
22    fn direct_vector_retrieval(
23        &self,
24        predicate: &ScalarExpr,
25        params: &[SQLParam],
26    ) -> Result<Option<DirectVectorRetrieval>, SQLError>;
27    fn knn_entries(
28        &self,
29        table: &str,
30        field: &str,
31        query: &[f32],
32        top_k: usize,
33        committed: bool,
34    ) -> Result<Vec<ScoredEntry>, SQLError>;
35    fn retrieval_entries(
36        &self,
37        table: &str,
38        predicate: &ScalarExpr,
39        params: &[SQLParam],
40        committed: bool,
41    ) -> Result<Option<Vec<ScoredEntry>>, SQLError>;
42}