From 80a0d12e088a0c7878e1aa7a17fbf8a5a19d0f0d Mon Sep 17 00:00:00 2001 From: Josip Mrden Date: Fri, 23 Jun 2023 13:33:18 +0200 Subject: [PATCH] Add template to cost estimator --- src/query/plan/cost_estimator.hpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/query/plan/cost_estimator.hpp b/src/query/plan/cost_estimator.hpp index 9fe824f7c..04af448a9 100644 --- a/src/query/plan/cost_estimator.hpp +++ b/src/query/plan/cost_estimator.hpp @@ -296,8 +296,10 @@ class CostEstimator : public HierarchicalLogicalOperatorVisitor { } bool PreVisit(Apply &op) override { + // Get the cost of the main branch op.input_->Accept(*this); + // Estimate cost on the subquery branch independently, use a copy auto last_scope = scopes_.back(); double subquery_cost = EstimateCostOnBranch(&op.subquery_, last_scope); @@ -385,14 +387,8 @@ class CostEstimator : public HierarchicalLogicalOperatorVisitor { return scope.symbol_stats[symbol.name()]; } - void SaveStatsFor(const Symbol &symbol, storage::LabelIndexStats index_stats) { - scopes_.back().symbol_stats[symbol.name()] = SymbolStatistics{ - .cardinality = index_stats.count, - .degree = index_stats.avg_degree, - }; - } - - void SaveStatsFor(const Symbol &symbol, storage::LabelPropertyIndexStats index_stats) { + template + void SaveStatsFor(const Symbol &symbol, T index_stats) { scopes_.back().symbol_stats[symbol.name()] = SymbolStatistics{ .cardinality = index_stats.count, .degree = index_stats.avg_degree,