linkrs_query/optimizer/cost_based/aggregate_strategy/
context.rs1#[derive(Debug, Clone)]
5pub struct AggregateContext {
6 pub input_rows: u64,
8 pub group_keys: Vec<String>,
10 pub agg_function_count: usize,
12 pub memory_limit: u64,
14 pub input_is_sorted: bool,
16 pub sort_keys_match_group_keys: bool,
18 pub is_deterministic: bool,
20 pub complexity_score: u32,
22 pub table_name: Option<String>,
24}
25
26impl AggregateContext {
27 pub fn new(input_rows: u64, group_keys: Vec<String>, agg_function_count: usize) -> Self {
29 Self {
30 input_rows,
31 group_keys,
32 agg_function_count,
33 memory_limit: 0,
34 input_is_sorted: false,
35 sort_keys_match_group_keys: false,
36 is_deterministic: true,
37 complexity_score: 0,
38 table_name: None,
39 }
40 }
41
42 pub fn with_memory_limit(mut self, memory_limit: u64) -> Self {
44 self.memory_limit = memory_limit;
45 self
46 }
47
48 pub fn with_sorted_input(mut self, sort_keys_match: bool) -> Self {
50 self.input_is_sorted = true;
51 self.sort_keys_match_group_keys = sort_keys_match;
52 self
53 }
54
55 pub fn with_expression_analysis(
57 mut self,
58 is_deterministic: bool,
59 complexity_score: u32,
60 ) -> Self {
61 self.is_deterministic = is_deterministic;
62 self.complexity_score = complexity_score;
63 self
64 }
65
66 pub fn with_table_name(mut self, table_name: Option<String>) -> Self {
68 self.table_name = table_name;
69 self
70 }
71}