be/src/exprs/vcompound_pred.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | #include <gen_cpp/Opcodes_types.h> |
20 | | |
21 | | #include <algorithm> |
22 | | #include <cstdint> |
23 | | |
24 | | #include "common/logging.h" |
25 | | #include "common/status.h" |
26 | | #include "core/assert_cast.h" |
27 | | #include "core/column/column.h" |
28 | | #include "core/column/column_nullable.h" |
29 | | #include "exprs/vectorized_fn_call.h" |
30 | | #include "exprs/vexpr_context.h" |
31 | | #include "exprs/vexpr_fwd.h" |
32 | | #include "storage/index/zone_map/zonemap_eval_context.h" |
33 | | #include "util/simd/bits.h" |
34 | | |
35 | | namespace doris { |
36 | | |
37 | 10.7k | inline std::string compound_operator_to_string(TExprOpcode::type op) { |
38 | 10.7k | if (op == TExprOpcode::COMPOUND_AND) { |
39 | 2.15k | return "and"; |
40 | 8.59k | } else if (op == TExprOpcode::COMPOUND_OR) { |
41 | 7.89k | return "or"; |
42 | 7.89k | } else { |
43 | 699 | return "not"; |
44 | 699 | } |
45 | 10.7k | } |
46 | | |
47 | | class VCompoundPred : public VectorizedFnCall { |
48 | | ENABLE_FACTORY_CREATOR(VCompoundPred); |
49 | | |
50 | | public: |
51 | 10.7k | VCompoundPred(const TExprNode& node) : VectorizedFnCall(node) { |
52 | 10.7k | _op = node.opcode; |
53 | 10.7k | _fn.name.function_name = compound_operator_to_string(_op); |
54 | 10.7k | _expr_name = fmt::format("VCompoundPredicate[{}](arguments={},return={})", |
55 | 10.7k | _fn.name.function_name, get_child_names(), _data_type->get_name()); |
56 | 10.7k | } |
57 | | |
58 | | #ifdef BE_TEST |
59 | | VCompoundPred() = default; |
60 | | #endif |
61 | | |
62 | 16.7k | const std::string& expr_name() const override { return _expr_name; } |
63 | 4.33k | Status clone_node(VExprSPtr* cloned_expr) const override { |
64 | 4.33k | DORIS_CHECK(cloned_expr != nullptr); |
65 | 4.33k | *cloned_expr = VCompoundPred::create_shared(clone_texpr_node()); |
66 | 4.33k | return Status::OK(); |
67 | 4.33k | } |
68 | | |
69 | | bool can_execute_on_raw_fixed_values(const DataTypePtr& data_type, |
70 | 44 | int column_id) const override { |
71 | 44 | return !_children.empty() && |
72 | 44 | (_op == TExprOpcode::COMPOUND_AND || _op == TExprOpcode::COMPOUND_OR) && |
73 | 57 | std::ranges::all_of(_children, [&](const VExprSPtr& child) { |
74 | 57 | return child->can_execute_on_raw_fixed_values(data_type, column_id); |
75 | 57 | }); |
76 | 44 | } |
77 | | |
78 | | Status execute_on_raw_fixed_values(const uint8_t* values, size_t num_values, size_t value_width, |
79 | | const DataTypePtr& data_type, int column_id, |
80 | 2 | uint8_t* matches) const override { |
81 | 2 | if (!can_execute_on_raw_fixed_values(data_type, column_id)) { |
82 | 0 | return Status::NotSupported("Compound predicate cannot evaluate raw fixed values"); |
83 | 0 | } |
84 | 2 | return _execute_raw_compound( |
85 | 4 | num_values, matches, [&](const VExprSPtr& child, uint8_t* child_matches) { |
86 | 4 | return child->execute_on_raw_fixed_values(values, num_values, value_width, |
87 | 4 | data_type, column_id, child_matches); |
88 | 4 | }); |
89 | 2 | } |
90 | | |
91 | | bool can_execute_on_raw_binary_values(const DataTypePtr& data_type, |
92 | 60 | int column_id) const override { |
93 | 60 | return !_children.empty() && |
94 | 60 | (_op == TExprOpcode::COMPOUND_AND || _op == TExprOpcode::COMPOUND_OR) && |
95 | 110 | std::ranges::all_of(_children, [&](const VExprSPtr& child) { |
96 | 110 | return child->can_execute_on_raw_binary_values(data_type, column_id); |
97 | 110 | }); |
98 | 60 | } |
99 | | |
100 | | Status execute_on_raw_binary_values(const StringRef* values, size_t num_values, |
101 | | const DataTypePtr& data_type, int column_id, |
102 | 8 | uint8_t* matches) const override { |
103 | 8 | if (!can_execute_on_raw_binary_values(data_type, column_id)) { |
104 | 0 | return Status::NotSupported("Compound predicate cannot evaluate raw binary values"); |
105 | 0 | } |
106 | 8 | return _execute_raw_compound( |
107 | 16 | num_values, matches, [&](const VExprSPtr& child, uint8_t* child_matches) { |
108 | 16 | return child->execute_on_raw_binary_values(values, num_values, data_type, |
109 | 16 | column_id, child_matches); |
110 | 16 | }); |
111 | 8 | } |
112 | | |
113 | 52 | bool raw_predicate_result_for_null() const override { |
114 | 52 | if (_op != TExprOpcode::COMPOUND_AND && _op != TExprOpcode::COMPOUND_OR) { |
115 | | // A Boolean keep bit cannot distinguish FALSE from UNKNOWN, so negating a child's |
116 | | // collapsed result is not SQL-correct. NOT remains residual and rejects NULL here. |
117 | 0 | return false; |
118 | 0 | } |
119 | 52 | if (_op == TExprOpcode::COMPOUND_AND) { |
120 | 3 | return std::ranges::all_of(_children, [](const VExprSPtr& child) { |
121 | 3 | return child->raw_predicate_result_for_null(); |
122 | 3 | }); |
123 | 3 | } |
124 | 98 | return std::ranges::any_of(_children, [](const VExprSPtr& child) { |
125 | 98 | return child->raw_predicate_result_for_null(); |
126 | 98 | }); |
127 | 52 | } |
128 | | |
129 | 16.5k | bool can_evaluate_zonemap_filter() const override { |
130 | 16.5k | switch (_op) { |
131 | 3.10k | case TExprOpcode::COMPOUND_AND: |
132 | 3.77k | return std::ranges::any_of(_children, [](const VExprSPtr& child) { |
133 | 3.77k | return child->can_evaluate_zonemap_filter(); |
134 | 3.77k | }); |
135 | 10.2k | case TExprOpcode::COMPOUND_OR: |
136 | 17.3k | return !_children.empty() && std::ranges::all_of(_children, [](const VExprSPtr& child) { |
137 | 17.3k | return child->can_evaluate_zonemap_filter(); |
138 | 17.3k | }); |
139 | 3.13k | case TExprOpcode::COMPOUND_NOT: |
140 | 3.13k | return false; |
141 | 0 | default: |
142 | 0 | return false; |
143 | 16.5k | } |
144 | 16.5k | } |
145 | | |
146 | 2.92k | ZoneMapFilterResult evaluate_zonemap_filter(const ZoneMapEvalContext& ctx) const override { |
147 | 2.92k | switch (_op) { |
148 | 416 | case TExprOpcode::COMPOUND_AND: { |
149 | 744 | for (const auto& child : _children) { |
150 | 744 | if (!child->can_evaluate_zonemap_filter()) { |
151 | 90 | continue; |
152 | 90 | } |
153 | 654 | if (child->evaluate_zonemap_filter(ctx) == ZoneMapFilterResult::kNoMatch) { |
154 | 156 | return ZoneMapFilterResult::kNoMatch; |
155 | 156 | } |
156 | 654 | } |
157 | 260 | return ZoneMapFilterResult::kMayMatch; |
158 | 416 | } |
159 | 2.51k | case TExprOpcode::COMPOUND_OR: { |
160 | 4.18k | for (const auto& child : _children) { |
161 | 4.18k | DORIS_CHECK(child->can_evaluate_zonemap_filter()); |
162 | 4.18k | if (child->evaluate_zonemap_filter(ctx) != ZoneMapFilterResult::kNoMatch) { |
163 | 2.12k | return ZoneMapFilterResult::kMayMatch; |
164 | 2.12k | } |
165 | 4.18k | } |
166 | 390 | return ZoneMapFilterResult::kNoMatch; |
167 | 2.51k | } |
168 | 1 | case TExprOpcode::COMPOUND_NOT: |
169 | 1 | return unsupported_zonemap_filter(ctx); |
170 | 0 | default: |
171 | 0 | return unsupported_zonemap_filter(ctx); |
172 | 2.92k | } |
173 | 2.92k | } |
174 | | |
175 | 364 | bool can_evaluate_dictionary_filter() const override { |
176 | 364 | switch (_op) { |
177 | 134 | case TExprOpcode::COMPOUND_AND: |
178 | 137 | return std::ranges::any_of(_children, [](const VExprSPtr& child) { |
179 | 137 | return child->can_evaluate_dictionary_filter(); |
180 | 137 | }); |
181 | 230 | case TExprOpcode::COMPOUND_OR: |
182 | 432 | return !_children.empty() && std::ranges::all_of(_children, [](const VExprSPtr& child) { |
183 | 432 | return child->can_evaluate_dictionary_filter(); |
184 | 432 | }); |
185 | 0 | default: |
186 | 0 | return false; |
187 | 364 | } |
188 | 364 | } |
189 | | |
190 | 2.06k | bool is_safe_to_execute_on_selected_rows() const override { |
191 | | // Boolean composition introduces no data-dependent failure of its own. Reuse the generic |
192 | | // child walk so AND/OR remain eligible only when every nested expression is independently |
193 | | // safe; applying VectorizedFnCall's scalar-function allowlist to this structural node would |
194 | | // incorrectly disable selected-row execution for otherwise safe predicates. |
195 | 2.06k | return VExpr::is_safe_to_execute_on_selected_rows(); |
196 | 2.06k | } |
197 | | |
198 | | ZoneMapFilterResult evaluate_dictionary_filter( |
199 | 21 | const DictionaryEvalContext& ctx) const override { |
200 | 21 | switch (_op) { |
201 | 21 | case TExprOpcode::COMPOUND_AND: |
202 | 29 | for (const auto& child : _children) { |
203 | 29 | if (!child->can_evaluate_dictionary_filter()) { |
204 | 8 | continue; |
205 | 8 | } |
206 | 21 | if (child->evaluate_dictionary_filter(ctx) == ZoneMapFilterResult::kNoMatch) { |
207 | 13 | return ZoneMapFilterResult::kNoMatch; |
208 | 13 | } |
209 | 21 | } |
210 | 8 | return ZoneMapFilterResult::kMayMatch; |
211 | 0 | case TExprOpcode::COMPOUND_OR: |
212 | 0 | for (const auto& child : _children) { |
213 | 0 | DORIS_CHECK(child->can_evaluate_dictionary_filter()); |
214 | 0 | if (child->evaluate_dictionary_filter(ctx) != ZoneMapFilterResult::kNoMatch) { |
215 | 0 | return ZoneMapFilterResult::kMayMatch; |
216 | 0 | } |
217 | 0 | } |
218 | 0 | return ZoneMapFilterResult::kNoMatch; |
219 | 0 | default: |
220 | 0 | return ZoneMapFilterResult::kUnsupported; |
221 | 21 | } |
222 | 21 | } |
223 | | |
224 | 305 | bool can_evaluate_bloom_filter() const override { |
225 | 305 | switch (_op) { |
226 | 96 | case TExprOpcode::COMPOUND_AND: |
227 | 112 | return std::ranges::any_of(_children, [](const VExprSPtr& child) { |
228 | 112 | return child->can_evaluate_bloom_filter(); |
229 | 112 | }); |
230 | 209 | case TExprOpcode::COMPOUND_OR: |
231 | 335 | return !_children.empty() && std::ranges::all_of(_children, [](const VExprSPtr& child) { |
232 | 335 | return child->can_evaluate_bloom_filter(); |
233 | 335 | }); |
234 | 0 | default: |
235 | 0 | return false; |
236 | 305 | } |
237 | 305 | } |
238 | | |
239 | 0 | ZoneMapFilterResult evaluate_bloom_filter(const BloomFilterEvalContext& ctx) const override { |
240 | 0 | switch (_op) { |
241 | 0 | case TExprOpcode::COMPOUND_AND: |
242 | 0 | for (const auto& child : _children) { |
243 | 0 | if (!child->can_evaluate_bloom_filter()) { |
244 | 0 | continue; |
245 | 0 | } |
246 | 0 | if (child->evaluate_bloom_filter(ctx) == ZoneMapFilterResult::kNoMatch) { |
247 | 0 | return ZoneMapFilterResult::kNoMatch; |
248 | 0 | } |
249 | 0 | } |
250 | 0 | return ZoneMapFilterResult::kMayMatch; |
251 | 0 | case TExprOpcode::COMPOUND_OR: |
252 | 0 | for (const auto& child : _children) { |
253 | 0 | DORIS_CHECK(child->can_evaluate_bloom_filter()); |
254 | 0 | if (child->evaluate_bloom_filter(ctx) != ZoneMapFilterResult::kNoMatch) { |
255 | 0 | return ZoneMapFilterResult::kMayMatch; |
256 | 0 | } |
257 | 0 | } |
258 | 0 | return ZoneMapFilterResult::kNoMatch; |
259 | 0 | default: |
260 | 0 | return ZoneMapFilterResult::kUnsupported; |
261 | 0 | } |
262 | 0 | } |
263 | | |
264 | 5.05k | Status evaluate_inverted_index(VExprContext* context, uint32_t segment_num_rows) override { |
265 | 5.05k | segment_v2::InvertedIndexResultBitmap res; |
266 | 5.05k | bool all_pass = true; |
267 | | |
268 | 5.05k | switch (_op) { |
269 | 3.04k | case TExprOpcode::COMPOUND_OR: { |
270 | 5.87k | for (const auto& child : _children) { |
271 | 5.87k | if (Status st = child->evaluate_inverted_index(context, segment_num_rows); |
272 | 5.87k | !st.ok()) { |
273 | 176 | LOG(ERROR) << "expr:" << child->expr_name() |
274 | 176 | << " evaluate_inverted_index error:" << st.to_string(); |
275 | 176 | all_pass = false; |
276 | 176 | continue; |
277 | 176 | } |
278 | 5.70k | auto inverted_index_context = context->get_index_context(); |
279 | 5.70k | if (inverted_index_context->has_index_result_for_expr(child.get())) { |
280 | 3.01k | const auto* index_result = |
281 | 3.01k | inverted_index_context->get_index_result_for_expr(child.get()); |
282 | 3.01k | if (res.is_empty()) { |
283 | 2.02k | res = *index_result; |
284 | 2.02k | } else { |
285 | 987 | res |= *index_result; |
286 | 987 | } |
287 | 3.01k | if (inverted_index_context->get_score_runtime() == nullptr) { |
288 | 3.01k | if (res.get_data_bitmap()->cardinality() == segment_num_rows) { |
289 | 354 | break; // Early exit if result is full |
290 | 354 | } |
291 | 3.01k | } |
292 | 3.01k | } else { |
293 | 2.68k | all_pass = false; |
294 | 2.68k | } |
295 | 5.70k | } |
296 | 3.04k | break; |
297 | 0 | } |
298 | 5.34k | case TExprOpcode::COMPOUND_AND: { |
299 | 1.37k | for (const auto& child : _children) { |
300 | 1.37k | if (Status st = child->evaluate_inverted_index(context, segment_num_rows); |
301 | 1.37k | !st.ok()) { |
302 | 27 | LOG(ERROR) << "expr:" << child->expr_name() |
303 | 27 | << " evaluate_inverted_index error:" << st.to_string(); |
304 | 27 | all_pass = false; |
305 | 27 | continue; |
306 | 27 | } |
307 | 1.34k | if (context->get_index_context()->has_index_result_for_expr(child.get())) { |
308 | 234 | const auto* index_result = |
309 | 234 | context->get_index_context()->get_index_result_for_expr(child.get()); |
310 | 234 | if (res.is_empty()) { |
311 | 173 | res = *index_result; |
312 | 173 | } else { |
313 | 61 | res &= *index_result; |
314 | 61 | } |
315 | | |
316 | 234 | if (res.get_data_bitmap()->isEmpty()) { |
317 | 90 | break; // Early exit if result is empty |
318 | 90 | } |
319 | 1.11k | } else { |
320 | 1.11k | all_pass = false; |
321 | 1.11k | } |
322 | 1.34k | } |
323 | 730 | break; |
324 | 0 | } |
325 | 1.26k | case TExprOpcode::COMPOUND_NOT: { |
326 | 1.26k | const auto& child = _children[0]; |
327 | 1.26k | Status st = child->evaluate_inverted_index(context, segment_num_rows); |
328 | 1.26k | if (!st.ok()) { |
329 | 40 | LOG(ERROR) << "expr:" << child->expr_name() |
330 | 40 | << " evaluate_inverted_index error:" << st.to_string(); |
331 | 40 | return st; |
332 | 40 | } |
333 | | |
334 | 1.22k | if (context->get_index_context()->has_index_result_for_expr(child.get())) { |
335 | 677 | const auto* index_result = |
336 | 677 | context->get_index_context()->get_index_result_for_expr(child.get()); |
337 | 677 | roaring::Roaring full_result; |
338 | 677 | full_result.addRange(0, segment_num_rows); |
339 | 677 | res = index_result->op_not(&full_result); |
340 | 677 | } else { |
341 | 550 | all_pass = false; |
342 | 550 | } |
343 | 1.22k | break; |
344 | 1.26k | } |
345 | 0 | default: |
346 | 0 | return Status::NotSupported( |
347 | 0 | "Compound operator must be AND, OR, or NOT to execute with inverted index."); |
348 | 5.05k | } |
349 | | |
350 | 5.03k | if (all_pass && !res.is_empty()) { |
351 | 2.03k | context->get_index_context()->set_index_result_for_expr(this, res); |
352 | 2.03k | } |
353 | 5.03k | return Status::OK(); |
354 | 5.05k | } |
355 | | |
356 | | Status execute_column_impl(VExprContext* context, const Block* block, const Selector* selector, |
357 | 31.8k | size_t count, ColumnPtr& result_column) const override { |
358 | 31.8k | if (fast_execute(context, selector, count, result_column)) { |
359 | 91 | return Status::OK(); |
360 | 91 | } |
361 | 31.7k | if (get_num_children() == 1 || _has_const_child()) { |
362 | 1.21k | return VectorizedFnCall::execute_column_impl(context, block, selector, count, |
363 | 1.21k | result_column); |
364 | 1.21k | } |
365 | | |
366 | 30.5k | ColumnPtr lhs_column; |
367 | 30.5k | RETURN_IF_ERROR(_children[0]->execute_column(context, block, selector, count, lhs_column)); |
368 | 30.5k | lhs_column = lhs_column->convert_to_full_column_if_const(); |
369 | 30.5k | size_t size = lhs_column->size(); |
370 | | |
371 | 30.5k | bool lhs_is_nullable = lhs_column->is_nullable(); |
372 | 30.5k | auto [lhs_data_column, lhs_null_map] = |
373 | 30.5k | _get_raw_data_and_null_map(lhs_column, lhs_is_nullable); |
374 | 30.5k | size_t filted = simd::count_zero_num((int8_t*)lhs_data_column, size); |
375 | 30.5k | bool lhs_all_true = (filted == 0); |
376 | 30.5k | bool lhs_all_false = (filted == size); |
377 | | |
378 | 30.5k | bool lhs_all_is_not_null = false; |
379 | 30.5k | if (lhs_is_nullable) { |
380 | 16.4k | filted = simd::count_zero_num((int8_t*)lhs_null_map, size); |
381 | 16.4k | lhs_all_is_not_null = (filted == size); |
382 | 16.4k | } |
383 | | |
384 | 30.5k | ColumnPtr rhs_column = nullptr; |
385 | 30.5k | const uint8_t* __restrict rhs_data_column = nullptr; |
386 | 30.5k | const uint8_t* __restrict rhs_null_map = nullptr; |
387 | 30.5k | bool rhs_is_nullable = false; |
388 | 30.5k | bool rhs_all_true = false; |
389 | 30.5k | bool rhs_all_false = false; |
390 | 30.5k | bool rhs_all_is_not_null = false; |
391 | 30.5k | bool result_is_nullable = _data_type->is_nullable(); |
392 | | |
393 | 30.5k | auto get_rhs_colum = [&]() { |
394 | 23.6k | if (!rhs_column) { |
395 | 23.6k | RETURN_IF_ERROR( |
396 | 23.6k | _children[1]->execute_column(context, block, selector, count, rhs_column)); |
397 | 23.6k | rhs_column = rhs_column->convert_to_full_column_if_const(); |
398 | 23.6k | rhs_is_nullable = rhs_column->is_nullable(); |
399 | 23.6k | auto rhs_nullable_column = _get_raw_data_and_null_map(rhs_column, rhs_is_nullable); |
400 | 23.6k | rhs_data_column = rhs_nullable_column.first; |
401 | 23.6k | rhs_null_map = rhs_nullable_column.second; |
402 | 23.6k | size_t filted = simd::count_zero_num((int8_t*)rhs_data_column, size); |
403 | 23.6k | rhs_all_true = (filted == 0); |
404 | 23.6k | rhs_all_false = (filted == size); |
405 | 23.6k | if (rhs_is_nullable) { |
406 | 18.1k | filted = simd::count_zero_num((int8_t*)rhs_null_map, size); |
407 | 18.1k | rhs_all_is_not_null = (filted == size); |
408 | 18.1k | } |
409 | 23.6k | } |
410 | 23.6k | return Status::OK(); |
411 | 23.6k | }; |
412 | | |
413 | 30.5k | auto return_result_column_id = [&](ColumnPtr& arg_column) { |
414 | 25.7k | result_column = std::move(*arg_column).mutate(); |
415 | 25.7k | if (result_is_nullable && !result_column->is_nullable()) { |
416 | 3.40k | result_column = make_nullable(result_column); |
417 | 3.40k | } |
418 | 25.7k | }; |
419 | | |
420 | 30.5k | auto create_null_map_column = [&](ColumnPtr& null_map_column, |
421 | 30.5k | const uint8_t* __restrict null_map_data) { |
422 | 8.35k | if (null_map_data == nullptr) { |
423 | 786 | null_map_column = ColumnUInt8::create(size, 0); |
424 | 786 | null_map_data = |
425 | 786 | assert_cast<const ColumnUInt8*>(null_map_column.get())->get_data().data(); |
426 | 786 | } |
427 | 8.35k | return null_map_data; |
428 | 8.35k | }; |
429 | | |
430 | 30.5k | auto vector_vector = [&]<bool is_and_op>() { |
431 | 612 | MutableColumnPtr mutable_result_column; |
432 | 612 | uint8_t* __restrict result_data_column = nullptr; |
433 | 612 | const uint8_t* __restrict other_data_column = rhs_data_column; |
434 | 612 | if (lhs_column->use_count() == 1) { |
435 | 603 | mutable_result_column = IColumn::mutate(std::move(lhs_column)); |
436 | 603 | result_data_column = |
437 | 603 | assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data(); |
438 | 603 | } else if (rhs_column->use_count() == 1) { |
439 | 4 | mutable_result_column = IColumn::mutate(std::move(rhs_column)); |
440 | 4 | result_data_column = |
441 | 4 | assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data(); |
442 | 4 | other_data_column = lhs_data_column; |
443 | 5 | } else { |
444 | 5 | mutable_result_column = lhs_column->clone_resized(size); |
445 | 5 | result_data_column = |
446 | 5 | assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data(); |
447 | 5 | } |
448 | | |
449 | 612 | do_not_null_pred<is_and_op>(result_data_column, other_data_column, size); |
450 | 612 | result_column = std::move(mutable_result_column); |
451 | 612 | }; _ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE_clILb1EEEDav Line | Count | Source | 430 | 465 | auto vector_vector = [&]<bool is_and_op>() { | 431 | 465 | MutableColumnPtr mutable_result_column; | 432 | 465 | uint8_t* __restrict result_data_column = nullptr; | 433 | 465 | const uint8_t* __restrict other_data_column = rhs_data_column; | 434 | 465 | if (lhs_column->use_count() == 1) { | 435 | 465 | mutable_result_column = IColumn::mutate(std::move(lhs_column)); | 436 | 465 | result_data_column = | 437 | 465 | assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data(); | 438 | 465 | } else if (rhs_column->use_count() == 1) { | 439 | 0 | mutable_result_column = IColumn::mutate(std::move(rhs_column)); | 440 | 0 | result_data_column = | 441 | 0 | assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data(); | 442 | 0 | other_data_column = lhs_data_column; | 443 | 0 | } else { | 444 | 0 | mutable_result_column = lhs_column->clone_resized(size); | 445 | 0 | result_data_column = | 446 | 0 | assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data(); | 447 | 0 | } | 448 | | | 449 | 465 | do_not_null_pred<is_and_op>(result_data_column, other_data_column, size); | 450 | 465 | result_column = std::move(mutable_result_column); | 451 | 465 | }; |
_ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE_clILb0EEEDav Line | Count | Source | 430 | 147 | auto vector_vector = [&]<bool is_and_op>() { | 431 | 147 | MutableColumnPtr mutable_result_column; | 432 | 147 | uint8_t* __restrict result_data_column = nullptr; | 433 | 147 | const uint8_t* __restrict other_data_column = rhs_data_column; | 434 | 147 | if (lhs_column->use_count() == 1) { | 435 | 138 | mutable_result_column = IColumn::mutate(std::move(lhs_column)); | 436 | 138 | result_data_column = | 437 | 138 | assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data(); | 438 | 138 | } else if (rhs_column->use_count() == 1) { | 439 | 4 | mutable_result_column = IColumn::mutate(std::move(rhs_column)); | 440 | 4 | result_data_column = | 441 | 4 | assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data(); | 442 | 4 | other_data_column = lhs_data_column; | 443 | 5 | } else { | 444 | 5 | mutable_result_column = lhs_column->clone_resized(size); | 445 | 5 | result_data_column = | 446 | 5 | assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data(); | 447 | 5 | } | 448 | | | 449 | 147 | do_not_null_pred<is_and_op>(result_data_column, other_data_column, size); | 450 | 147 | result_column = std::move(mutable_result_column); | 451 | 147 | }; |
|
452 | 30.5k | auto vector_vector_null = [&]<bool is_and_op>() { |
453 | 4.17k | auto col_res = ColumnUInt8::create(size); |
454 | 4.17k | auto col_nulls = ColumnUInt8::create(size); |
455 | | |
456 | 4.17k | auto* __restrict res_datas = col_res->get_data().data(); |
457 | 4.17k | auto* __restrict res_nulls = col_nulls->get_data().data(); |
458 | 4.17k | ColumnPtr temp_null_map = nullptr; |
459 | | // maybe both children are nullable / or one of children is nullable |
460 | 4.17k | auto* __restrict lhs_null_map_tmp = create_null_map_column(temp_null_map, lhs_null_map); |
461 | 4.17k | auto* __restrict rhs_null_map_tmp = create_null_map_column(temp_null_map, rhs_null_map); |
462 | 4.17k | auto* __restrict lhs_data_column_tmp = lhs_data_column; |
463 | 4.17k | auto* __restrict rhs_data_column_tmp = rhs_data_column; |
464 | | |
465 | 4.17k | do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, rhs_data_column_tmp, |
466 | 4.17k | rhs_null_map_tmp, res_datas, res_nulls, size); |
467 | | |
468 | 4.17k | result_column = ColumnNullable::create(std::move(col_res), std::move(col_nulls)); |
469 | 4.17k | }; _ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE0_clILb1EEEDav Line | Count | Source | 452 | 605 | auto vector_vector_null = [&]<bool is_and_op>() { | 453 | 605 | auto col_res = ColumnUInt8::create(size); | 454 | 605 | auto col_nulls = ColumnUInt8::create(size); | 455 | | | 456 | 605 | auto* __restrict res_datas = col_res->get_data().data(); | 457 | 605 | auto* __restrict res_nulls = col_nulls->get_data().data(); | 458 | 605 | ColumnPtr temp_null_map = nullptr; | 459 | | // maybe both children are nullable / or one of children is nullable | 460 | 605 | auto* __restrict lhs_null_map_tmp = create_null_map_column(temp_null_map, lhs_null_map); | 461 | 605 | auto* __restrict rhs_null_map_tmp = create_null_map_column(temp_null_map, rhs_null_map); | 462 | 605 | auto* __restrict lhs_data_column_tmp = lhs_data_column; | 463 | 605 | auto* __restrict rhs_data_column_tmp = rhs_data_column; | 464 | | | 465 | 605 | do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, rhs_data_column_tmp, | 466 | 605 | rhs_null_map_tmp, res_datas, res_nulls, size); | 467 | | | 468 | 605 | result_column = ColumnNullable::create(std::move(col_res), std::move(col_nulls)); | 469 | 605 | }; |
_ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE0_clILb0EEEDav Line | Count | Source | 452 | 3.56k | auto vector_vector_null = [&]<bool is_and_op>() { | 453 | 3.56k | auto col_res = ColumnUInt8::create(size); | 454 | 3.56k | auto col_nulls = ColumnUInt8::create(size); | 455 | | | 456 | 3.56k | auto* __restrict res_datas = col_res->get_data().data(); | 457 | 3.56k | auto* __restrict res_nulls = col_nulls->get_data().data(); | 458 | 3.56k | ColumnPtr temp_null_map = nullptr; | 459 | | // maybe both children are nullable / or one of children is nullable | 460 | 3.56k | auto* __restrict lhs_null_map_tmp = create_null_map_column(temp_null_map, lhs_null_map); | 461 | 3.56k | auto* __restrict rhs_null_map_tmp = create_null_map_column(temp_null_map, rhs_null_map); | 462 | 3.56k | auto* __restrict lhs_data_column_tmp = lhs_data_column; | 463 | 3.56k | auto* __restrict rhs_data_column_tmp = rhs_data_column; | 464 | | | 465 | 3.56k | do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, rhs_data_column_tmp, | 466 | 3.56k | rhs_null_map_tmp, res_datas, res_nulls, size); | 467 | | | 468 | 3.56k | result_column = ColumnNullable::create(std::move(col_res), std::move(col_nulls)); | 469 | 3.56k | }; |
|
470 | | |
471 | | // false and NULL ----> 0 |
472 | | // true and NULL ----> NULL |
473 | 30.5k | if (_op == TExprOpcode::COMPOUND_AND) { |
474 | | //1. not null column: all data is false |
475 | | //2. nullable column: null map all is not null |
476 | 4.70k | if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) { |
477 | | // false and any = false, return lhs |
478 | 2.40k | return_result_column_id(lhs_column); |
479 | 2.40k | } else { |
480 | 2.30k | RETURN_IF_ERROR(get_rhs_colum()); |
481 | | |
482 | 2.30k | if ((lhs_all_true && !lhs_is_nullable) || //not null column |
483 | 2.30k | (lhs_all_true && lhs_all_is_not_null)) { //nullable column |
484 | | // true and any = any, return rhs |
485 | | |
486 | 734 | return_result_column_id(rhs_column); |
487 | 1.56k | } else if ((rhs_all_false && !rhs_is_nullable) || |
488 | 1.56k | (rhs_all_false && rhs_all_is_not_null)) { |
489 | | // any and false = false, return rhs |
490 | 238 | return_result_column_id(rhs_column); |
491 | 1.32k | } else if ((rhs_all_true && !rhs_is_nullable) || |
492 | 1.32k | (rhs_all_true && rhs_all_is_not_null)) { |
493 | | // any and true = any, return lhs |
494 | 259 | return_result_column_id(lhs_column); |
495 | 1.07k | } else { |
496 | 1.07k | if (!result_is_nullable) { |
497 | 465 | vector_vector.template operator()<true>(); |
498 | 605 | } else { |
499 | 605 | vector_vector_null.template operator()<true>(); |
500 | 605 | } |
501 | 1.07k | } |
502 | 2.30k | } |
503 | 25.8k | } else if (_op == TExprOpcode::COMPOUND_OR) { |
504 | | // true or NULL ----> 1 |
505 | | // false or NULL ----> NULL |
506 | 25.8k | if ((lhs_all_true && !lhs_is_nullable) || (lhs_all_true && lhs_all_is_not_null)) { |
507 | | // true or any = true, return lhs |
508 | 4.53k | return_result_column_id(lhs_column); |
509 | 21.3k | } else { |
510 | 21.3k | RETURN_IF_ERROR(get_rhs_colum()); |
511 | 21.3k | if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) { |
512 | | // false or any = any, return rhs |
513 | 16.1k | return_result_column_id(rhs_column); |
514 | 16.1k | } else if ((rhs_all_true && !rhs_is_nullable) || |
515 | 5.15k | (rhs_all_true && rhs_all_is_not_null)) { |
516 | | // any or true = true, return rhs |
517 | 782 | return_result_column_id(rhs_column); |
518 | 4.36k | } else if ((rhs_all_false && !rhs_is_nullable) || |
519 | 4.36k | (rhs_all_false && rhs_all_is_not_null)) { |
520 | | // any or false = any, return lhs |
521 | 645 | return_result_column_id(lhs_column); |
522 | 3.72k | } else { |
523 | 3.72k | if (!result_is_nullable) { |
524 | 147 | vector_vector.template operator()<false>(); |
525 | 3.57k | } else { |
526 | 3.57k | vector_vector_null.template operator()<false>(); |
527 | 3.57k | } |
528 | 3.72k | } |
529 | 21.3k | } |
530 | 18.4E | } else { |
531 | 18.4E | return Status::InternalError("Compound operator must be AND or OR."); |
532 | 18.4E | } |
533 | | |
534 | 30.5k | DCHECK_EQ(result_column->size(), count); |
535 | 30.5k | return Status::OK(); |
536 | 30.5k | } |
537 | | |
538 | 1.05k | double execute_cost() const override { |
539 | 1.05k | double cost = 0.3; |
540 | 1.71k | for (const auto& child : _children) { |
541 | 1.71k | cost += child->execute_cost(); |
542 | 1.71k | } |
543 | 1.05k | return cost; |
544 | 1.05k | } |
545 | | |
546 | | private: |
547 | | template <typename ExecuteChild> |
548 | | Status _execute_raw_compound(size_t num_values, uint8_t* matches, |
549 | 10 | ExecuteChild&& execute_child) const { |
550 | 10 | if (_op == TExprOpcode::COMPOUND_AND) { |
551 | 2 | for (const auto& child : _children) { |
552 | 2 | RETURN_IF_ERROR(execute_child(child, matches)); |
553 | 2 | } |
554 | 1 | return Status::OK(); |
555 | 1 | } |
556 | | |
557 | | // Each execution context owns its expression tree. Retaining masks on the OR node avoids |
558 | | // N+1 row-sized allocations for every decoder fragment, while nested OR nodes keep |
559 | | // independent buffers and therefore cannot overwrite their parent's in-flight state. |
560 | 9 | _raw_combined_scratch.resize(num_values); |
561 | 9 | std::ranges::fill(_raw_combined_scratch, 0); |
562 | 18 | for (const auto& child : _children) { |
563 | | // resize_fill() initializes only newly appended bytes; explicitly reset a reused mask |
564 | | // so matches from an earlier page fragment cannot leak into this OR evaluation. |
565 | 18 | _raw_child_scratch.resize(num_values); |
566 | 18 | std::ranges::fill(_raw_child_scratch, 1); |
567 | 18 | RETURN_IF_ERROR(execute_child(child, _raw_child_scratch.data())); |
568 | 154 | for (size_t row = 0; row < num_values; ++row) { |
569 | 136 | _raw_combined_scratch[row] |= _raw_child_scratch[row]; |
570 | 136 | } |
571 | 18 | } |
572 | | // Raw kernels receive an existing selection mask, so composition must preserve rows that |
573 | | // an earlier conjunct already rejected instead of replacing the caller's mask. |
574 | 77 | for (size_t row = 0; row < num_values; ++row) { |
575 | 68 | matches[row] &= _raw_combined_scratch[row]; |
576 | 68 | } |
577 | 9 | constexpr size_t MAX_RETAINED_RAW_MASK_BYTES = 1UL << 20; |
578 | 9 | if (_raw_combined_scratch.capacity() > MAX_RETAINED_RAW_MASK_BYTES) { |
579 | 0 | IColumn::Filter().swap(_raw_combined_scratch); |
580 | 0 | } |
581 | 9 | if (_raw_child_scratch.capacity() > MAX_RETAINED_RAW_MASK_BYTES) { |
582 | 0 | IColumn::Filter().swap(_raw_child_scratch); |
583 | 0 | } |
584 | 9 | return Status::OK(); |
585 | 9 | } _ZNK5doris13VCompoundPred21_execute_raw_compoundIZNKS0_27execute_on_raw_fixed_valuesEPKhmmRKSt10shared_ptrIKNS_9IDataTypeEEiPhEUlRKS4_INS_5VExprEESA_E_EENS_6StatusEmSA_OT_ Line | Count | Source | 549 | 2 | ExecuteChild&& execute_child) const { | 550 | 2 | if (_op == TExprOpcode::COMPOUND_AND) { | 551 | 2 | for (const auto& child : _children) { | 552 | 2 | RETURN_IF_ERROR(execute_child(child, matches)); | 553 | 2 | } | 554 | 1 | return Status::OK(); | 555 | 1 | } | 556 | | | 557 | | // Each execution context owns its expression tree. Retaining masks on the OR node avoids | 558 | | // N+1 row-sized allocations for every decoder fragment, while nested OR nodes keep | 559 | | // independent buffers and therefore cannot overwrite their parent's in-flight state. | 560 | 1 | _raw_combined_scratch.resize(num_values); | 561 | 1 | std::ranges::fill(_raw_combined_scratch, 0); | 562 | 2 | for (const auto& child : _children) { | 563 | | // resize_fill() initializes only newly appended bytes; explicitly reset a reused mask | 564 | | // so matches from an earlier page fragment cannot leak into this OR evaluation. | 565 | 2 | _raw_child_scratch.resize(num_values); | 566 | 2 | std::ranges::fill(_raw_child_scratch, 1); | 567 | 2 | RETURN_IF_ERROR(execute_child(child, _raw_child_scratch.data())); | 568 | 10 | for (size_t row = 0; row < num_values; ++row) { | 569 | 8 | _raw_combined_scratch[row] |= _raw_child_scratch[row]; | 570 | 8 | } | 571 | 2 | } | 572 | | // Raw kernels receive an existing selection mask, so composition must preserve rows that | 573 | | // an earlier conjunct already rejected instead of replacing the caller's mask. | 574 | 5 | for (size_t row = 0; row < num_values; ++row) { | 575 | 4 | matches[row] &= _raw_combined_scratch[row]; | 576 | 4 | } | 577 | 1 | constexpr size_t MAX_RETAINED_RAW_MASK_BYTES = 1UL << 20; | 578 | 1 | if (_raw_combined_scratch.capacity() > MAX_RETAINED_RAW_MASK_BYTES) { | 579 | 0 | IColumn::Filter().swap(_raw_combined_scratch); | 580 | 0 | } | 581 | 1 | if (_raw_child_scratch.capacity() > MAX_RETAINED_RAW_MASK_BYTES) { | 582 | 0 | IColumn::Filter().swap(_raw_child_scratch); | 583 | 0 | } | 584 | 1 | return Status::OK(); | 585 | 1 | } |
_ZNK5doris13VCompoundPred21_execute_raw_compoundIZNKS0_28execute_on_raw_binary_valuesEPKNS_9StringRefEmRKSt10shared_ptrIKNS_9IDataTypeEEiPhEUlRKS5_INS_5VExprEESB_E_EENS_6StatusEmSB_OT_ Line | Count | Source | 549 | 8 | ExecuteChild&& execute_child) const { | 550 | 8 | if (_op == TExprOpcode::COMPOUND_AND) { | 551 | 0 | for (const auto& child : _children) { | 552 | 0 | RETURN_IF_ERROR(execute_child(child, matches)); | 553 | 0 | } | 554 | 0 | return Status::OK(); | 555 | 0 | } | 556 | | | 557 | | // Each execution context owns its expression tree. Retaining masks on the OR node avoids | 558 | | // N+1 row-sized allocations for every decoder fragment, while nested OR nodes keep | 559 | | // independent buffers and therefore cannot overwrite their parent's in-flight state. | 560 | 8 | _raw_combined_scratch.resize(num_values); | 561 | 8 | std::ranges::fill(_raw_combined_scratch, 0); | 562 | 16 | for (const auto& child : _children) { | 563 | | // resize_fill() initializes only newly appended bytes; explicitly reset a reused mask | 564 | | // so matches from an earlier page fragment cannot leak into this OR evaluation. | 565 | 16 | _raw_child_scratch.resize(num_values); | 566 | 16 | std::ranges::fill(_raw_child_scratch, 1); | 567 | 16 | RETURN_IF_ERROR(execute_child(child, _raw_child_scratch.data())); | 568 | 144 | for (size_t row = 0; row < num_values; ++row) { | 569 | 128 | _raw_combined_scratch[row] |= _raw_child_scratch[row]; | 570 | 128 | } | 571 | 16 | } | 572 | | // Raw kernels receive an existing selection mask, so composition must preserve rows that | 573 | | // an earlier conjunct already rejected instead of replacing the caller's mask. | 574 | 72 | for (size_t row = 0; row < num_values; ++row) { | 575 | 64 | matches[row] &= _raw_combined_scratch[row]; | 576 | 64 | } | 577 | 8 | constexpr size_t MAX_RETAINED_RAW_MASK_BYTES = 1UL << 20; | 578 | 8 | if (_raw_combined_scratch.capacity() > MAX_RETAINED_RAW_MASK_BYTES) { | 579 | 0 | IColumn::Filter().swap(_raw_combined_scratch); | 580 | 0 | } | 581 | 8 | if (_raw_child_scratch.capacity() > MAX_RETAINED_RAW_MASK_BYTES) { | 582 | 0 | IColumn::Filter().swap(_raw_child_scratch); | 583 | 0 | } | 584 | 8 | return Status::OK(); | 585 | 8 | } |
|
586 | | |
587 | | mutable IColumn::Filter _raw_combined_scratch; |
588 | | mutable IColumn::Filter _raw_child_scratch; |
589 | | |
590 | 152k | static inline constexpr uint8_t apply_and_null(UInt8 a, UInt8 l_null, UInt8 b, UInt8 r_null) { |
591 | | // (<> && false) is false, (true && NULL) is NULL |
592 | 152k | return (l_null & r_null) | (r_null & (l_null ^ a)) | (l_null & (r_null ^ b)); |
593 | 152k | } |
594 | 502k | static inline constexpr uint8_t apply_or_null(UInt8 a, UInt8 l_null, UInt8 b, UInt8 r_null) { |
595 | | // (<> || true) is true, (false || NULL) is NULL |
596 | 502k | return (l_null & r_null) | (r_null & (r_null ^ a)) | (l_null & (l_null ^ b)); |
597 | 502k | } |
598 | | |
599 | | template <bool is_and> |
600 | | void static do_not_null_pred(uint8_t* __restrict lhs, const uint8_t* __restrict rhs, |
601 | 612 | size_t size) { |
602 | | #ifdef NDEBUG |
603 | | #if defined(__clang__) |
604 | | #pragma clang loop vectorize(enable) |
605 | | #elif defined(__GNUC__) && (__GNUC__ >= 5) |
606 | | #pragma GCC ivdep |
607 | | #endif |
608 | | #endif |
609 | 70.5k | for (size_t i = 0; i < size; ++i) { |
610 | 69.8k | if constexpr (is_and) { |
611 | 65.9k | lhs[i] &= rhs[i]; |
612 | 65.9k | } else { |
613 | 3.94k | lhs[i] |= rhs[i]; |
614 | 3.94k | } |
615 | 69.8k | } |
616 | 612 | } _ZN5doris13VCompoundPred16do_not_null_predILb1EEEvPhPKhm Line | Count | Source | 601 | 465 | size_t size) { | 602 | | #ifdef NDEBUG | 603 | | #if defined(__clang__) | 604 | | #pragma clang loop vectorize(enable) | 605 | | #elif defined(__GNUC__) && (__GNUC__ >= 5) | 606 | | #pragma GCC ivdep | 607 | | #endif | 608 | | #endif | 609 | 66.4k | for (size_t i = 0; i < size; ++i) { | 610 | 65.9k | if constexpr (is_and) { | 611 | 65.9k | lhs[i] &= rhs[i]; | 612 | | } else { | 613 | | lhs[i] |= rhs[i]; | 614 | | } | 615 | 65.9k | } | 616 | 465 | } |
_ZN5doris13VCompoundPred16do_not_null_predILb0EEEvPhPKhm Line | Count | Source | 601 | 147 | size_t size) { | 602 | | #ifdef NDEBUG | 603 | | #if defined(__clang__) | 604 | | #pragma clang loop vectorize(enable) | 605 | | #elif defined(__GNUC__) && (__GNUC__ >= 5) | 606 | | #pragma GCC ivdep | 607 | | #endif | 608 | | #endif | 609 | 4.09k | for (size_t i = 0; i < size; ++i) { | 610 | | if constexpr (is_and) { | 611 | | lhs[i] &= rhs[i]; | 612 | 3.94k | } else { | 613 | 3.94k | lhs[i] |= rhs[i]; | 614 | 3.94k | } | 615 | 3.94k | } | 616 | 147 | } |
|
617 | | |
618 | | template <bool is_and> |
619 | | void static do_null_pred(const uint8_t* __restrict lhs_data, const uint8_t* __restrict lhs_null, |
620 | | const uint8_t* __restrict rhs_data, const uint8_t* __restrict rhs_null, |
621 | | uint8_t* __restrict res_data, uint8_t* __restrict res_null, |
622 | 4.17k | size_t size) { |
623 | | #ifdef NDEBUG |
624 | | #if defined(__clang__) |
625 | | #pragma clang loop vectorize(enable) |
626 | | #elif defined(__GNUC__) && (__GNUC__ >= 5) |
627 | | #pragma GCC ivdep |
628 | | #endif |
629 | | #endif |
630 | 659k | for (size_t i = 0; i < size; ++i) { |
631 | 655k | if constexpr (is_and) { |
632 | 152k | res_null[i] = apply_and_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]); |
633 | 152k | res_data[i] = lhs_data[i] & rhs_data[i]; |
634 | 502k | } else { |
635 | 502k | res_null[i] = apply_or_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]); |
636 | 502k | res_data[i] = lhs_data[i] | rhs_data[i]; |
637 | 502k | } |
638 | 655k | } |
639 | 4.17k | } _ZN5doris13VCompoundPred12do_null_predILb1EEEvPKhS3_S3_S3_PhS4_m Line | Count | Source | 622 | 606 | size_t size) { | 623 | | #ifdef NDEBUG | 624 | | #if defined(__clang__) | 625 | | #pragma clang loop vectorize(enable) | 626 | | #elif defined(__GNUC__) && (__GNUC__ >= 5) | 627 | | #pragma GCC ivdep | 628 | | #endif | 629 | | #endif | 630 | 152k | for (size_t i = 0; i < size; ++i) { | 631 | 152k | if constexpr (is_and) { | 632 | 152k | res_null[i] = apply_and_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]); | 633 | 152k | res_data[i] = lhs_data[i] & rhs_data[i]; | 634 | | } else { | 635 | | res_null[i] = apply_or_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]); | 636 | | res_data[i] = lhs_data[i] | rhs_data[i]; | 637 | | } | 638 | 152k | } | 639 | 606 | } |
_ZN5doris13VCompoundPred12do_null_predILb0EEEvPKhS3_S3_S3_PhS4_m Line | Count | Source | 622 | 3.56k | size_t size) { | 623 | | #ifdef NDEBUG | 624 | | #if defined(__clang__) | 625 | | #pragma clang loop vectorize(enable) | 626 | | #elif defined(__GNUC__) && (__GNUC__ >= 5) | 627 | | #pragma GCC ivdep | 628 | | #endif | 629 | | #endif | 630 | 506k | for (size_t i = 0; i < size; ++i) { | 631 | | if constexpr (is_and) { | 632 | | res_null[i] = apply_and_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]); | 633 | | res_data[i] = lhs_data[i] & rhs_data[i]; | 634 | 502k | } else { | 635 | 502k | res_null[i] = apply_or_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]); | 636 | 502k | res_data[i] = lhs_data[i] | rhs_data[i]; | 637 | 502k | } | 638 | 502k | } | 639 | 3.56k | } |
|
640 | | |
641 | 30.5k | bool _has_const_child() const { |
642 | 30.5k | return std::ranges::any_of(_children, |
643 | 61.1k | [](const VExprSPtr& arg) -> bool { return arg->is_constant(); }); |
644 | 30.5k | } |
645 | | |
646 | | std::pair<const uint8_t*, const uint8_t*> _get_raw_data_and_null_map( |
647 | 54.1k | const ColumnPtr& column, bool has_nullable_column) const { |
648 | 54.1k | if (has_nullable_column) { |
649 | 34.5k | const auto* nullable_column = assert_cast<const ColumnNullable*>(column.get()); |
650 | 34.5k | auto* data_column = |
651 | 34.5k | assert_cast<const ColumnUInt8*>(nullable_column->get_nested_column_ptr().get()) |
652 | 34.5k | ->get_data() |
653 | 34.5k | .data(); |
654 | 34.5k | auto* null_map = nullable_column->get_null_map_column_ptr()->get_data().data(); |
655 | 34.5k | return std::make_pair(data_column, null_map); |
656 | 34.5k | } else { |
657 | 19.6k | auto* data_column = assert_cast<const ColumnUInt8*>(column.get())->get_data().data(); |
658 | 19.6k | return std::make_pair(data_column, nullptr); |
659 | 19.6k | } |
660 | 54.1k | } |
661 | | |
662 | | TExprOpcode::type _op; |
663 | | }; |
664 | | |
665 | | } // namespace doris |