MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
filter_stmt.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//
12// Created by Wangyunlai on 2022/5/22.
13//
14
15#pragma once
16
17#include "common/lang/unordered_map.h"
18#include "common/lang/vector.h"
19#include "sql/expr/expression.h"
20#include "sql/parser/parse_defs.h"
21#include "sql/stmt/stmt.h"
22
23class Db;
24class Table;
25class FieldMeta;
26
28{
29 bool is_attr;
30 Field field;
31 Value value;
32
33 void init_attr(const Field &field)
34 {
35 is_attr = true;
36 this->field = field;
37 }
38
39 void init_value(const Value &value)
40 {
41 is_attr = false;
42 this->value = value;
43 }
44};
45
47{
48public:
49 FilterUnit() = default;
50 ~FilterUnit() {}
51
52 void set_comp(CompOp comp) { comp_ = comp; }
53
54 CompOp comp() const { return comp_; }
55
56 void set_left(const FilterObj &obj) { left_ = obj; }
57 void set_right(const FilterObj &obj) { right_ = obj; }
58
59 const FilterObj &left() const { return left_; }
60 const FilterObj &right() const { return right_; }
61
62private:
63 CompOp comp_ = NO_OP;
64 FilterObj left_;
65 FilterObj right_;
66};
67
73{
74public:
75 FilterStmt() = default;
76 virtual ~FilterStmt();
77
78public:
79 const vector<FilterUnit *> &filter_units() const { return filter_units_; }
80
81public:
82 static RC create(Db *db, Table *default_table, unordered_map<string, Table *> *tables,
83 const ConditionSqlNode *conditions, int condition_num, FilterStmt *&stmt);
84
85 static RC create_filter_unit(Db *db, Table *default_table, unordered_map<string, Table *> *tables,
86 const ConditionSqlNode &condition, FilterUnit *&filter_unit);
87
88private:
89 vector<FilterUnit *> filter_units_; // 默认当前都是AND关系
90};
一个DB实例负责管理一批表
Definition: db.h:46
字段元数据
Definition: field_meta.h:30
字段
Definition: field.h:25
Filter/谓词/过滤语句
Definition: filter_stmt.h:73
Definition: filter_stmt.h:47
Definition: table.h:42
属性的值
Definition: value.h:30
CompOp
描述比较运算符
Definition: parse_defs.h:47
表示一个条件比较
Definition: parse_defs.h:66
Definition: filter_stmt.h:28