reddb_engine/query/
logical_plan.rs1use std::collections::BTreeMap;
3
4#[derive(Debug, Clone, Default)]
6pub struct CanonicalLogicalPlan {
7 pub root: CanonicalLogicalNode,
8}
9
10#[derive(Debug, Clone, Default)]
12pub struct CanonicalLogicalNode {
13 pub operator: String,
14 pub source: Option<String>,
15 pub details: BTreeMap<String, String>,
16 pub estimated_rows: f64,
17 pub estimated_selectivity: f64,
18 pub estimated_confidence: f64,
19 pub operator_cost: f64,
20 pub children: Vec<CanonicalLogicalNode>,
21}
22
23#[derive(Debug, Clone, Default)]
25pub struct CardinalityEstimate {
26 pub rows: f64,
28 pub selectivity: f64,
30 pub confidence: f64,
32}
33
34impl CardinalityEstimate {
35 pub fn new(rows: f64, selectivity: f64) -> Self {
37 Self {
38 rows,
39 selectivity,
40 confidence: 1.0,
41 }
42 }
43
44 pub fn full_scan(table_size: f64) -> Self {
46 Self {
47 rows: table_size,
48 selectivity: 1.0,
49 confidence: 1.0,
50 }
51 }
52
53 pub fn with_filter(mut self, filter_selectivity: f64) -> Self {
55 self.rows *= filter_selectivity;
56 self.selectivity *= filter_selectivity;
57 self.confidence *= 0.9; self
59 }
60}
61
62#[derive(Debug, Clone)]
63pub struct AccessPathDecision {
64 pub path: &'static str,
65 pub index_hint: Option<String>,
66 pub reason: String,
67 pub warning: Option<String>,
68}