use crate::cascades::{CascadesOptimizer, Memo, RelNodeContext};
use crate::nodes::{ArcPredNode, NodeType};
pub struct Statistics(pub Box<dyn std::any::Any + Send + Sync + 'static>);
#[derive(Default, Clone, Debug, PartialOrd, PartialEq)]
pub struct Cost(pub Vec<f64>);
pub trait CostModel<T: NodeType, M: Memo<T>>: 'static + Send + Sync {
#[allow(clippy::too_many_arguments)]
fn compute_operation_cost(
&self,
node: &T,
predicates: &[ArcPredNode<T>],
children_stats: &[Option<&Statistics>],
children_costs: &[Cost],
context: Option<RelNodeContext>,
optimizer: Option<&CascadesOptimizer<T, M>>,
) -> Cost;
fn derive_statistics(
&self,
node: &T,
predicates: &[ArcPredNode<T>],
children_stats: &[&Statistics],
context: Option<RelNodeContext>,
optimizer: Option<&CascadesOptimizer<T, M>>,
) -> Statistics;
fn explain_cost(&self, cost: &Cost) -> String;
fn explain_statistics(&self, cost: &Statistics) -> String;
fn accumulate(&self, total_cost: &mut Cost, cost: &Cost);
fn sum(&self, operation_cost: &Cost, inputs_cost: &[Cost]) -> Cost {
let mut total_cost = operation_cost.clone();
for input in inputs_cost {
self.accumulate(&mut total_cost, input);
}
total_cost
}
fn zero(&self) -> Cost;
fn weighted_cost(&self, cost: &Cost) -> f64;
}