logical_operator.h 1.4 KB
Newer Older
羽飞's avatar
羽飞 已提交
1
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
羽飞's avatar
羽飞 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
         http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */

//
// Created by Wangyunlai on 2022/12/07.
//

#pragma once

#include <memory>
#include <vector>

#include "sql/expr/expression.h"

羽飞's avatar
羽飞 已提交
22 23
enum class LogicalOperatorType 
{
羽飞's avatar
羽飞 已提交
24 25 26 27
  TABLE_GET,
  PREDICATE,
  PROJECTION,
  JOIN,
羽飞's avatar
羽飞 已提交
28
  INSERT,
羽飞's avatar
羽飞 已提交
29 30 31 32 33 34 35 36
  DELETE,
  EXPLAIN,
};

/**
 * 逻辑算子描述当前执行计划要做什么
 * 可以看OptimizeStage中相关的代码
 */
羽飞's avatar
羽飞 已提交
37 38
class LogicalOperator 
{
羽飞's avatar
羽飞 已提交
39 40 41 42 43
public:
  LogicalOperator() = default;
  virtual ~LogicalOperator();

  virtual LogicalOperatorType type() const = 0;
L
Longda Feng 已提交
44

羽飞's avatar
羽飞 已提交
45
  void add_child(std::unique_ptr<LogicalOperator> oper);
L
Longda Feng 已提交
46 47 48 49 50 51 52 53 54
  std::vector<std::unique_ptr<LogicalOperator>> &children()
  {
    return children_;
  }
  std::vector<std::unique_ptr<Expression>> &expressions()
  {
    return expressions_;
  }

羽飞's avatar
羽飞 已提交
55 56 57 58
protected:
  std::vector<std::unique_ptr<LogicalOperator>> children_;
  std::vector<std::unique_ptr<Expression>> expressions_;
};