logical_operator.h 1.4 KB
Newer Older
羽飞's avatar
羽飞 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
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"

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

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

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

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

羽飞's avatar
羽飞 已提交
52 53 54 55
protected:
  std::vector<std::unique_ptr<LogicalOperator>> children_;
  std::vector<std::unique_ptr<Expression>> expressions_;
};