uqa_execution/query/block/
context.rs1use std::collections::BTreeMap;
10use uqa_core::{DocId, ScoredEntry, Value};
11use uqa_sql::{ast::ColumnDef, SQLError, SQLParam, ScalarExpr};
12use uqa_storage::document_store::Document;
13
14pub trait QueryDocumentRead: Sync {
15 fn document_ids(&self, table: &str) -> Result<Vec<DocId>, SQLError>;
16 fn document(&self, table: &str, doc_id: DocId) -> Result<Option<Document>, SQLError>;
17 fn document_fields(
18 &self,
19 table: &str,
20 ids: &[DocId],
21 fields: &[&str],
22 ) -> Result<BTreeMap<DocId, Vec<Value>>, SQLError>;
23 fn column_definitions(&self, table: &str) -> Result<Option<Vec<ColumnDef>>, String>;
24 fn command_overlay_holds(&self, table: &str) -> Result<bool, SQLError>;
26}
27
28pub trait RelationRetrieval: Sync {
30 fn prepare_accelerated<'a>(
31 &'a self,
32 table: &'a str,
33 signal_table: &'a str,
34 predicate: Option<&ScalarExpr>,
35 params: &'a [SQLParam],
36 ) -> Result<Option<crate::query::scored_input::ScoredEntriesProducer<'a>>, SQLError>;
37 fn optimized(
38 &self,
39 table: &str,
40 predicate: Option<&ScalarExpr>,
41 params: &[SQLParam],
42 ) -> Result<Option<Vec<ScoredEntry>>, SQLError>;
43 fn function(
44 &self,
45 table: &str,
46 signal_table: &str,
47 name: &str,
48 args: &[ScalarExpr],
49 params: &[SQLParam],
50 top_k: Option<usize>,
51 ) -> Result<Vec<ScoredEntry>, SQLError>;
52}