forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_sql_temp_table.h
More file actions
140 lines (123 loc) · 4.66 KB
/
Copy pathob_sql_temp_table.h
File metadata and controls
140 lines (123 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* 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 PubL v2 for more details.
*/
#ifndef OCEANBASE_SQL_TEMP_TABLE_
#define OCEANBASE_SQL_TEMP_TABLE_
#include "sql/resolver/dml/ob_dml_stmt.h"
#include "sql/resolver/expr/ob_raw_expr.h"
#include "sql/optimizer/ob_sharding_info.h"
#include "observer/ob_server_struct.h"
namespace oceanbase
{
namespace sql
{
struct ObTempTableResultInfo
{
OB_UNIS_VERSION(1);
public:
ObTempTableResultInfo() : addr_(),
interm_result_ids_() {}
virtual ~ObTempTableResultInfo() {}
TO_STRING_KV(K_(addr),
K_(interm_result_ids));
//数据所在server
ObAddr addr_;
//数据集的key
ObSEArray<uint64_t, 2> interm_result_ids_;
};
class ObSqlTempTableCtx
{
OB_UNIS_VERSION(1);
public:
ObSqlTempTableCtx() : interm_result_infos_(),
temp_table_id_(0),
is_local_interm_result_(true) {}
virtual ~ObSqlTempTableCtx() {}
TO_STRING_KV(K_(interm_result_infos),
K_(temp_table_id),
K_(is_local_interm_result));
//结果集的分布信息:所在机器及KEY
ObSEArray<ObTempTableResultInfo, 2> interm_result_infos_;
//结果集所属的temp table
uint64_t temp_table_id_;
//结果集是否在本地
bool is_local_interm_result_;
};
typedef ObIArray<ObRawExpr *> ObRawExprCondition;
struct TableInfo {
TableInfo()
:table_filters_(),
table_item_(NULL),
upper_stmt_(NULL)
{}
virtual ~TableInfo(){}
TO_STRING_KV(
K_(table_filters),
K_(table_item),
K_(upper_stmt)
);
ObSEArray<ObRawExpr *, 4, common::ModulePageAllocator, true> table_filters_;
ObSEArray<ObRawExprCondition *, 4, common::ModulePageAllocator, true> filter_conditions_;
TableItem *table_item_;
ObDMLStmt* upper_stmt_;
};
class ObSqlTempTableInfo
{
public:
ObSqlTempTableInfo() : temp_table_id_(OB_INVALID_ID),
table_name_(),
table_query_(NULL),
table_plan_(NULL) {}
virtual ~ObSqlTempTableInfo() {}
void reset() {
temp_table_id_ = OB_INVALID_ID;
table_name_.reset();
table_query_ = NULL;
table_plan_ = NULL;
table_infos_.reset();
}
TO_STRING_KV(K_(temp_table_id),
K_(table_name),
K_(table_infos));
static int collect_temp_tables(ObIAllocator &allocator,
ObDMLStmt &stmt,
ObIArray<ObSqlTempTableInfo*> &temp_table_infos,
ObQueryCtx *query_ctx,
bool do_collect_filter);
static int collect_specified_temp_table(ObIAllocator &allocator,
ObSelectStmt *specified_query,
const ObIArray<ObDMLStmt *> &upper_stmts,
const ObIArray<TableItem *> &table_items,
ObSqlTempTableInfo &temp_table_info,
bool &all_has_filter);
static int collect_temp_table_filters(ObDMLStmt *stmt,
TableItem *table,
ObIArray<ObRawExpr*> &table_filters,
ObIArray<ObRawExprCondition*> &filter_conditions);
static int collect_table_filters_in_joined_table(JoinedTable *table,
uint64_t table_id,
const ObSqlBitSet<> &table_ids,
ObIArray<ObRawExpr*> &table_filters,
ObIArray<ObRawExprCondition*> &filter_conditions);
static int get_candi_exprs(const ObSqlBitSet<> &table_ids,
ObIArray<ObRawExpr*> &exprs,
ObIArray<ObRawExpr*> &candi_exprs,
ObIArray<ObRawExprCondition*> &candi_conditions);
public:
uint64_t temp_table_id_;
common::ObString table_name_;
ObSelectStmt *table_query_;
ObLogicalOperator *table_plan_;
ObSEArray<TableInfo, 8, common::ModulePageAllocator, true> table_infos_;
};
} /* ns sql*/
} /* ns oceanbase */
#endif //OCEANBASE_SQL_TEMP_TABLE_