forked from oceanbase/seekdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathob_join_vec_op.cpp
More file actions
131 lines (120 loc) · 4.86 KB
/
Copy pathob_join_vec_op.cpp
File metadata and controls
131 lines (120 loc) · 4.86 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
/*
* Copyright (c) 2025 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define USING_LOG_PREFIX SQL_ENG
#include "sql/engine/join/ob_join_vec_op.h"
namespace oceanbase
{
using namespace common;
namespace sql
{
OB_SERIALIZE_MEMBER((ObJoinVecSpec, ObOpSpec),
join_type_, other_join_conds_);
#define VEC_FORMAT_SWITCH_CASE(VEC_FORMAT, vec_ptr, brs) \
case VEC_FORMAT: { \
for (int64_t i = 0; i < brs.size_; ++i) { \
if (vec_ptr->is_null(i) || !vec_ptr->get_bool(i)) { \
brs.set_skip(i); \
} \
} \
break; \
}
int ObJoinVecOp::inner_rescan()
{
return ObOperator::inner_rescan();
}
int ObJoinVecOp::blank_row_batch(const ExprFixedArray &exprs, int64_t batch_size)
{
int ret = OB_SUCCESS;
for (int64_t col_idx = 0; OB_SUCC(ret) && col_idx < exprs.count(); col_idx++) {
if (OB_FAIL(exprs.at(col_idx)->init_vector_default(eval_ctx_, batch_size))) {
LOG_WARN("fail to init vector", K(ret));
} else {
ObIVector *vec = exprs.at(col_idx)->get_vector(eval_ctx_);
if (OB_UNLIKELY(VEC_UNIFORM_CONST == exprs.at(col_idx)->get_format(eval_ctx_))) {
reinterpret_cast<ObUniformFormat<true> *>(vec)->set_null(0);
} else if (VEC_UNIFORM == exprs.at(col_idx)->get_format(eval_ctx_)) {
reinterpret_cast<ObUniformFormat<false> *>(vec)->set_all_null(batch_size);
} else {
reinterpret_cast<ObBitmapNullVectorBase *>(vec)->get_nulls()->set_all(batch_size);
reinterpret_cast<ObBitmapNullVectorBase *>(vec)->set_has_null();
}
exprs.at(col_idx)->set_evaluated_projected(eval_ctx_);
}
}
return ret;
}
//TODO shengle here need CONST_UNIFORM_FORMAT == !is_batch_result
// and exprs must not CONST_UNIFORM_FORMAT
void ObJoinVecOp::blank_row_batch_one(const ExprFixedArray &exprs)
{
clear_datum_eval_flag();
for (int64_t i = 0; i < exprs.count(); i++) {
ObIVector *vec = exprs.at(i)->get_vector(eval_ctx_);
VectorFormat format = exprs.at(i)->get_format(eval_ctx_);
if (OB_UNLIKELY(is_uniform_format(format))) {
reinterpret_cast<ObUniformBase *>(vec)->set_null(eval_ctx_.get_batch_idx());
} else {
reinterpret_cast<ObBitmapNullVectorBase *>(vec)->set_null(eval_ctx_.get_batch_idx());
}
exprs.at(i)->set_evaluated_flag(eval_ctx_);
}
}
int ObJoinVecOp::calc_other_conds(const ObBitVector &skip, bool &is_match)
{
int ret = OB_SUCCESS;
is_match = true;
const ObIArray<ObExpr *> &conds = get_spec().other_join_conds_;
const int64_t batch_idx = eval_ctx_.get_batch_idx();
EvalBound eval_bound(eval_ctx_.get_batch_size(), batch_idx, batch_idx + 1, false);
ObIVector *res_vec = nullptr;
ARRAY_FOREACH(conds, i) {
if (OB_FAIL(conds.at(i)->eval_vector(eval_ctx_, skip, eval_bound))) {
LOG_WARN("fail to calc other join condition", K(ret), K(*conds.at(i)));
} else if (OB_ISNULL(res_vec = conds.at(i)->get_vector(eval_ctx_))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("failed to get source vector", K(ret), K(res_vec));
} else if (res_vec->is_null(batch_idx) || 0 == res_vec->get_int(batch_idx)) {
is_match = false;
break;
}
}
return ret;
}
int ObJoinVecOp::batch_calc_other_conds(ObBatchRows &brs)
{
int ret = OB_SUCCESS;
const ObIArray<ObExpr *> &conds = get_spec().other_join_conds_;
ARRAY_FOREACH(conds, i) {
if (OB_FAIL(conds.at(i)->eval_vector(eval_ctx_, brs))) {
LOG_WARN("fail to calc other join condition", K(ret), K(*conds.at(i)));
} else {
VectorHeader &vec_header = conds.at(i)->get_vector_header(eval_ctx_);
common::ObIVector *vec = conds.at(i)->get_vector(eval_ctx_);
switch(vec_header.format_) {
VEC_FORMAT_SWITCH_CASE(VEC_FIXED, static_cast<ObFixedLengthBase *>(vec), brs);
VEC_FORMAT_SWITCH_CASE(VEC_UNIFORM, static_cast<ObUniformFormat<false> *>(vec), brs);
VEC_FORMAT_SWITCH_CASE(VEC_UNIFORM_CONST, static_cast<ObUniformFormat<true> *>(vec), brs);
default: {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected vector format", K(ret), K(vec_header.format_));
}
}
}
}
return ret;
}
} // namespace sql
} // namespace oceanbase