MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
optimizer_context.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11#pragma once
12#include "common/lang/memory.h"
13#include "catalog/catalog.h"
14#include "sql/optimizer/cascade/cost_model.h"
15#include "sql/optimizer/cascade/tasks/cascade_task.h"
16#include "sql/optimizer/cascade/pending_tasks.h"
17#include "sql/operator/operator_node.h"
18#include "sql/optimizer/cascade/property_set.h"
19
20class Memo;
21class RuleSet;
27{
28public:
30
32
33 Memo &get_memo();
34
35 RuleSet &get_rule_set();
36
37 void push_task(CascadeTask *task) { task_pool_->push(task); }
38
39 CostModel *get_cost_model() { return &cost_model_; }
40
41 void set_task_pool(PendingTasks *pending_tasks)
42 {
43 if (task_pool_ != nullptr) {
44 delete task_pool_;
45 }
46 task_pool_ = pending_tasks;
47 }
48
49 void record_operator_node_in_memo(unique_ptr<OperatorNode> &&node);
50
51 GroupExpr *make_group_expression(OperatorNode *node);
52
53 bool record_node_into_group(OperatorNode *node, GroupExpr **gexpr) { return record_node_into_group(node, gexpr, -1); }
54
55 bool record_node_into_group(OperatorNode *node, GroupExpr **gexpr, int target_group);
56
57 double get_cost_upper_bound() const { return cost_upper_bound_; }
58
59private:
60 Memo *memo_;
61 RuleSet *rule_set_;
62 CostModel cost_model_;
63 PendingTasks *task_pool_;
64 double cost_upper_bound_;
65};
Definition: cascade_task.h:32
cost model in cost-based optimization(CBO)
Definition: cost_model.h:19
Definition: group_expr.h:25
: memorization
Definition: memo.h:29
Definition: operator_node.h:69
Definition: optimizer_context.h:27
This collection of undone cascade tasks is currently stored as a stack.
Definition: pending_tasks.h:21
Definition: rules.h:167