forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_multi_children_phy_operator.cpp
More file actions
98 lines (87 loc) · 2.76 KB
/
ob_multi_children_phy_operator.cpp
File metadata and controls
98 lines (87 loc) · 2.76 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
/**
* 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.
*/
#define USING_LOG_PREFIX SQL_ENG
#include "sql/engine/ob_multi_children_phy_operator.h"
#include "sql/engine/ob_physical_plan.h"
using namespace oceanbase::sql;
using namespace oceanbase::common;
ObMultiChildrenPhyOperator::ObMultiChildrenPhyOperator(common::ObIAllocator& alloc)
: ObPhyOperator(alloc), child_array_(NULL), child_num_(0)
{}
ObMultiChildrenPhyOperator::~ObMultiChildrenPhyOperator()
{}
void ObMultiChildrenPhyOperator::reset()
{
child_array_ = NULL;
child_num_ = 0;
ObPhyOperator::reset();
}
void ObMultiChildrenPhyOperator::reuse()
{
child_array_ = NULL;
child_num_ = 0;
ObPhyOperator::reuse();
}
int ObMultiChildrenPhyOperator::set_child(int32_t child_idx, ObPhyOperator& child_operator)
{
int ret = OB_SUCCESS;
CK(OB_NOT_NULL(child_array_));
CK(child_idx >= 0);
CK(child_idx < child_num_);
if (OB_SUCC(ret)) {
child_array_[child_idx] = &child_operator;
child_operator.set_parent(this);
}
return ret;
}
int ObMultiChildrenPhyOperator::create_child_array(int64_t child_op_size)
{
int ret = OB_SUCCESS;
if (child_op_size > 0) {
void* ptr = NULL;
size_t buf_size = static_cast<size_t>(child_op_size * sizeof(ObPhyOperator*));
CK(OB_NOT_NULL(my_phy_plan_));
if (OB_ISNULL(ptr = my_phy_plan_->get_allocator().alloc(buf_size))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("create child array failed", K(ret), K(child_op_size));
} else {
memset(ptr, 0, buf_size);
child_array_ = static_cast<ObPhyOperator**>(ptr);
child_num_ = static_cast<int32_t>(child_op_size);
}
}
return ret;
}
ObPhyOperator* ObMultiChildrenPhyOperator::get_child(int32_t child_idx) const
{
ObPhyOperator* ret = NULL;
if (OB_LIKELY(child_idx >= 0 && child_idx < child_num_)) {
ret = child_array_[child_idx];
}
return ret;
}
int ObMultiChildrenPhyOperator::accept(ObPhyOperatorVisitor& visitor) const
{
int ret = OB_SUCCESS;
CK(child_num_ >= 0);
// pre-visit
OZ(visitor.pre_visit(*this));
// visit children
for (int64_t i = 0; OB_SUCC(ret) && i < child_num_; ++i) {
CK(child_array_[i]);
OZ(child_array_[i]->accept(visitor));
}
// post-visit
OZ(visitor.post_visit(*this));
return ret;
}
OB_SERIALIZE_MEMBER((ObMultiChildrenPhyOperator, ObPhyOperator), child_num_);