Coverage Report

Created: 2026-07-25 15:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
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
58
inline std::string compound_operator_to_string(TExprOpcode::type op) {
38
58
    if (op == TExprOpcode::COMPOUND_AND) {
39
32
        return "and";
40
32
    } else if (op == TExprOpcode::COMPOUND_OR) {
41
24
        return "or";
42
24
    } else {
43
2
        return "not";
44
2
    }
45
58
}
46
47
class VCompoundPred : public VectorizedFnCall {
48
    ENABLE_FACTORY_CREATOR(VCompoundPred);
49
50
public:
51
58
    VCompoundPred(const TExprNode& node) : VectorizedFnCall(node) {
52
58
        _op = node.opcode;
53
58
        _fn.name.function_name = compound_operator_to_string(_op);
54
58
        _expr_name = fmt::format("VCompoundPredicate[{}](arguments={},return={})",
55
58
                                 _fn.name.function_name, get_child_names(), _data_type->get_name());
56
58
    }
57
58
#ifdef BE_TEST
59
4
    VCompoundPred() = default;
60
#endif
61
62
36
    const std::string& expr_name() const override { return _expr_name; }
63
0
    Status clone_node(VExprSPtr* cloned_expr) const override {
64
0
        DORIS_CHECK(cloned_expr != nullptr);
65
0
        *cloned_expr = VCompoundPred::create_shared(clone_texpr_node());
66
0
        return Status::OK();
67
0
    }
68
69
42
    bool can_evaluate_zonemap_filter() const override {
70
42
        switch (_op) {
71
40
        case TExprOpcode::COMPOUND_AND:
72
80
            return std::ranges::any_of(_children, [](const VExprSPtr& child) {
73
80
                return child->can_evaluate_zonemap_filter();
74
80
            });
75
2
        case TExprOpcode::COMPOUND_OR:
76
4
            return !_children.empty() && std::ranges::all_of(_children, [](const VExprSPtr& child) {
77
4
                return child->can_evaluate_zonemap_filter();
78
4
            });
79
0
        case TExprOpcode::COMPOUND_NOT:
80
0
            return false;
81
0
        default:
82
0
            return false;
83
42
        }
84
42
    }
85
86
10
    ZoneMapFilterResult evaluate_zonemap_filter(const ZoneMapEvalContext& ctx) const override {
87
10
        switch (_op) {
88
4
        case TExprOpcode::COMPOUND_AND: {
89
8
            for (const auto& child : _children) {
90
8
                if (!child->can_evaluate_zonemap_filter()) {
91
2
                    continue;
92
2
                }
93
6
                if (child->evaluate_zonemap_filter(ctx) == ZoneMapFilterResult::kNoMatch) {
94
4
                    return ZoneMapFilterResult::kNoMatch;
95
4
                }
96
6
            }
97
0
            return ZoneMapFilterResult::kMayMatch;
98
4
        }
99
4
        case TExprOpcode::COMPOUND_OR: {
100
8
            for (const auto& child : _children) {
101
8
                DORIS_CHECK(child->can_evaluate_zonemap_filter());
102
8
                if (child->evaluate_zonemap_filter(ctx) != ZoneMapFilterResult::kNoMatch) {
103
2
                    return ZoneMapFilterResult::kMayMatch;
104
2
                }
105
8
            }
106
2
            return ZoneMapFilterResult::kNoMatch;
107
4
        }
108
2
        case TExprOpcode::COMPOUND_NOT:
109
2
            return unsupported_zonemap_filter(ctx);
110
0
        default:
111
0
            return unsupported_zonemap_filter(ctx);
112
10
        }
113
10
    }
114
115
60
    bool can_evaluate_dictionary_filter() const override {
116
60
        switch (_op) {
117
60
        case TExprOpcode::COMPOUND_AND:
118
66
            return std::ranges::any_of(_children, [](const VExprSPtr& child) {
119
66
                return child->can_evaluate_dictionary_filter();
120
66
            });
121
0
        case TExprOpcode::COMPOUND_OR:
122
0
            return !_children.empty() && std::ranges::all_of(_children, [](const VExprSPtr& child) {
123
0
                return child->can_evaluate_dictionary_filter();
124
0
            });
125
0
        default:
126
0
            return false;
127
60
        }
128
60
    }
129
130
14
    bool is_safe_to_execute_on_selected_rows() const override {
131
        // Boolean composition introduces no data-dependent failure of its own. Reuse the generic
132
        // child walk so AND/OR remain eligible only when every nested expression is independently
133
        // safe; applying VectorizedFnCall's scalar-function allowlist to this structural node would
134
        // incorrectly disable selected-row execution for otherwise safe predicates.
135
14
        return VExpr::is_safe_to_execute_on_selected_rows();
136
14
    }
137
138
    ZoneMapFilterResult evaluate_dictionary_filter(
139
42
            const DictionaryEvalContext& ctx) const override {
140
42
        switch (_op) {
141
42
        case TExprOpcode::COMPOUND_AND:
142
58
            for (const auto& child : _children) {
143
58
                if (!child->can_evaluate_dictionary_filter()) {
144
16
                    continue;
145
16
                }
146
42
                if (child->evaluate_dictionary_filter(ctx) == ZoneMapFilterResult::kNoMatch) {
147
26
                    return ZoneMapFilterResult::kNoMatch;
148
26
                }
149
42
            }
150
16
            return ZoneMapFilterResult::kMayMatch;
151
0
        case TExprOpcode::COMPOUND_OR:
152
0
            for (const auto& child : _children) {
153
0
                DORIS_CHECK(child->can_evaluate_dictionary_filter());
154
0
                if (child->evaluate_dictionary_filter(ctx) != ZoneMapFilterResult::kNoMatch) {
155
0
                    return ZoneMapFilterResult::kMayMatch;
156
0
                }
157
0
            }
158
0
            return ZoneMapFilterResult::kNoMatch;
159
0
        default:
160
0
            return ZoneMapFilterResult::kUnsupported;
161
42
        }
162
42
    }
163
164
12
    bool can_evaluate_bloom_filter() const override {
165
12
        switch (_op) {
166
12
        case TExprOpcode::COMPOUND_AND:
167
24
            return std::ranges::any_of(_children, [](const VExprSPtr& child) {
168
24
                return child->can_evaluate_bloom_filter();
169
24
            });
170
0
        case TExprOpcode::COMPOUND_OR:
171
0
            return !_children.empty() && std::ranges::all_of(_children, [](const VExprSPtr& child) {
172
0
                return child->can_evaluate_bloom_filter();
173
0
            });
174
0
        default:
175
0
            return false;
176
12
        }
177
12
    }
178
179
0
    ZoneMapFilterResult evaluate_bloom_filter(const BloomFilterEvalContext& ctx) const override {
180
0
        switch (_op) {
181
0
        case TExprOpcode::COMPOUND_AND:
182
0
            for (const auto& child : _children) {
183
0
                if (!child->can_evaluate_bloom_filter()) {
184
0
                    continue;
185
0
                }
186
0
                if (child->evaluate_bloom_filter(ctx) == ZoneMapFilterResult::kNoMatch) {
187
0
                    return ZoneMapFilterResult::kNoMatch;
188
0
                }
189
0
            }
190
0
            return ZoneMapFilterResult::kMayMatch;
191
0
        case TExprOpcode::COMPOUND_OR:
192
0
            for (const auto& child : _children) {
193
0
                DORIS_CHECK(child->can_evaluate_bloom_filter());
194
0
                if (child->evaluate_bloom_filter(ctx) != ZoneMapFilterResult::kNoMatch) {
195
0
                    return ZoneMapFilterResult::kMayMatch;
196
0
                }
197
0
            }
198
0
            return ZoneMapFilterResult::kNoMatch;
199
0
        default:
200
0
            return ZoneMapFilterResult::kUnsupported;
201
0
        }
202
0
    }
203
204
0
    Status evaluate_inverted_index(VExprContext* context, uint32_t segment_num_rows) override {
205
0
        segment_v2::InvertedIndexResultBitmap res;
206
0
        bool all_pass = true;
207
208
0
        switch (_op) {
209
0
        case TExprOpcode::COMPOUND_OR: {
210
0
            for (const auto& child : _children) {
211
0
                if (Status st = child->evaluate_inverted_index(context, segment_num_rows);
212
0
                    !st.ok()) {
213
0
                    LOG(ERROR) << "expr:" << child->expr_name()
214
0
                               << " evaluate_inverted_index error:" << st.to_string();
215
0
                    all_pass = false;
216
0
                    continue;
217
0
                }
218
0
                auto inverted_index_context = context->get_index_context();
219
0
                if (inverted_index_context->has_index_result_for_expr(child.get())) {
220
0
                    const auto* index_result =
221
0
                            inverted_index_context->get_index_result_for_expr(child.get());
222
0
                    if (res.is_empty()) {
223
0
                        res = *index_result;
224
0
                    } else {
225
0
                        res |= *index_result;
226
0
                    }
227
0
                    if (inverted_index_context->get_score_runtime() == nullptr) {
228
0
                        if (res.get_data_bitmap()->cardinality() == segment_num_rows) {
229
0
                            break; // Early exit if result is full
230
0
                        }
231
0
                    }
232
0
                } else {
233
0
                    all_pass = false;
234
0
                }
235
0
            }
236
0
            break;
237
0
        }
238
0
        case TExprOpcode::COMPOUND_AND: {
239
0
            for (const auto& child : _children) {
240
0
                if (Status st = child->evaluate_inverted_index(context, segment_num_rows);
241
0
                    !st.ok()) {
242
0
                    LOG(ERROR) << "expr:" << child->expr_name()
243
0
                               << " evaluate_inverted_index error:" << st.to_string();
244
0
                    all_pass = false;
245
0
                    continue;
246
0
                }
247
0
                if (context->get_index_context()->has_index_result_for_expr(child.get())) {
248
0
                    const auto* index_result =
249
0
                            context->get_index_context()->get_index_result_for_expr(child.get());
250
0
                    if (res.is_empty()) {
251
0
                        res = *index_result;
252
0
                    } else {
253
0
                        res &= *index_result;
254
0
                    }
255
256
0
                    if (res.get_data_bitmap()->isEmpty()) {
257
0
                        break; // Early exit if result is empty
258
0
                    }
259
0
                } else {
260
0
                    all_pass = false;
261
0
                }
262
0
            }
263
0
            break;
264
0
        }
265
0
        case TExprOpcode::COMPOUND_NOT: {
266
0
            const auto& child = _children[0];
267
0
            Status st = child->evaluate_inverted_index(context, segment_num_rows);
268
0
            if (!st.ok()) {
269
0
                LOG(ERROR) << "expr:" << child->expr_name()
270
0
                           << " evaluate_inverted_index error:" << st.to_string();
271
0
                return st;
272
0
            }
273
274
0
            if (context->get_index_context()->has_index_result_for_expr(child.get())) {
275
0
                const auto* index_result =
276
0
                        context->get_index_context()->get_index_result_for_expr(child.get());
277
0
                roaring::Roaring full_result;
278
0
                full_result.addRange(0, segment_num_rows);
279
0
                res = index_result->op_not(&full_result);
280
0
            } else {
281
0
                all_pass = false;
282
0
            }
283
0
            break;
284
0
        }
285
0
        default:
286
0
            return Status::NotSupported(
287
0
                    "Compound operator must be AND, OR, or NOT to execute with inverted index.");
288
0
        }
289
290
0
        if (all_pass && !res.is_empty()) {
291
0
            context->get_index_context()->set_index_result_for_expr(this, res);
292
0
        }
293
0
        return Status::OK();
294
0
    }
295
296
    Status execute_column_impl(VExprContext* context, const Block* block, const Selector* selector,
297
2
                               size_t count, ColumnPtr& result_column) const override {
298
2
        if (fast_execute(context, selector, count, result_column)) {
299
0
            return Status::OK();
300
0
        }
301
2
        if (get_num_children() == 1 || _has_const_child()) {
302
0
            return VectorizedFnCall::execute_column_impl(context, block, selector, count,
303
0
                                                         result_column);
304
0
        }
305
306
2
        ColumnPtr lhs_column;
307
2
        RETURN_IF_ERROR(_children[0]->execute_column(context, block, selector, count, lhs_column));
308
2
        lhs_column = lhs_column->convert_to_full_column_if_const();
309
2
        size_t size = lhs_column->size();
310
311
2
        bool lhs_is_nullable = lhs_column->is_nullable();
312
2
        auto [lhs_data_column, lhs_null_map] =
313
2
                _get_raw_data_and_null_map(lhs_column, lhs_is_nullable);
314
2
        size_t filted = simd::count_zero_num((int8_t*)lhs_data_column, size);
315
2
        bool lhs_all_true = (filted == 0);
316
2
        bool lhs_all_false = (filted == size);
317
318
2
        bool lhs_all_is_not_null = false;
319
2
        if (lhs_is_nullable) {
320
2
            filted = simd::count_zero_num((int8_t*)lhs_null_map, size);
321
2
            lhs_all_is_not_null = (filted == size);
322
2
        }
323
324
2
        ColumnPtr rhs_column = nullptr;
325
2
        const uint8_t* __restrict rhs_data_column = nullptr;
326
2
        const uint8_t* __restrict rhs_null_map = nullptr;
327
2
        bool rhs_is_nullable = false;
328
2
        bool rhs_all_true = false;
329
2
        bool rhs_all_false = false;
330
2
        bool rhs_all_is_not_null = false;
331
2
        bool result_is_nullable = _data_type->is_nullable();
332
333
2
        auto get_rhs_colum = [&]() {
334
2
            if (!rhs_column) {
335
2
                RETURN_IF_ERROR(
336
2
                        _children[1]->execute_column(context, block, selector, count, rhs_column));
337
0
                rhs_column = rhs_column->convert_to_full_column_if_const();
338
0
                rhs_is_nullable = rhs_column->is_nullable();
339
0
                auto rhs_nullable_column = _get_raw_data_and_null_map(rhs_column, rhs_is_nullable);
340
0
                rhs_data_column = rhs_nullable_column.first;
341
0
                rhs_null_map = rhs_nullable_column.second;
342
0
                size_t filted = simd::count_zero_num((int8_t*)rhs_data_column, size);
343
0
                rhs_all_true = (filted == 0);
344
0
                rhs_all_false = (filted == size);
345
0
                if (rhs_is_nullable) {
346
0
                    filted = simd::count_zero_num((int8_t*)rhs_null_map, size);
347
0
                    rhs_all_is_not_null = (filted == size);
348
0
                }
349
0
            }
350
0
            return Status::OK();
351
2
        };
352
353
2
        auto return_result_column_id = [&](ColumnPtr& arg_column) {
354
0
            result_column = std::move(*arg_column).mutate();
355
0
            if (result_is_nullable && !result_column->is_nullable()) {
356
0
                result_column = make_nullable(result_column);
357
0
            }
358
0
        };
359
360
2
        auto create_null_map_column = [&](ColumnPtr& null_map_column,
361
2
                                          const uint8_t* __restrict null_map_data) {
362
0
            if (null_map_data == nullptr) {
363
0
                null_map_column = ColumnUInt8::create(size, 0);
364
0
                null_map_data =
365
0
                        assert_cast<const ColumnUInt8*>(null_map_column.get())->get_data().data();
366
0
            }
367
0
            return null_map_data;
368
0
        };
369
370
2
        auto vector_vector = [&]<bool is_and_op>() {
371
0
            MutableColumnPtr mutable_result_column;
372
0
            uint8_t* __restrict result_data_column = nullptr;
373
0
            const uint8_t* __restrict other_data_column = rhs_data_column;
374
0
            if (lhs_column->use_count() == 1) {
375
0
                mutable_result_column = IColumn::mutate(std::move(lhs_column));
376
0
                result_data_column =
377
0
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
378
0
            } else if (rhs_column->use_count() == 1) {
379
0
                mutable_result_column = IColumn::mutate(std::move(rhs_column));
380
0
                result_data_column =
381
0
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
382
0
                other_data_column = lhs_data_column;
383
0
            } else {
384
0
                mutable_result_column = lhs_column->clone_resized(size);
385
0
                result_data_column =
386
0
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
387
0
            }
388
389
0
            do_not_null_pred<is_and_op>(result_data_column, other_data_column, size);
390
0
            result_column = std::move(mutable_result_column);
391
0
        };
Unexecuted instantiation: _ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE_clILb1EEEDav
Unexecuted instantiation: _ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE_clILb0EEEDav
392
2
        auto vector_vector_null = [&]<bool is_and_op>() {
393
0
            auto col_res = ColumnUInt8::create(size);
394
0
            auto col_nulls = ColumnUInt8::create(size);
395
396
0
            auto* __restrict res_datas = col_res->get_data().data();
397
0
            auto* __restrict res_nulls = col_nulls->get_data().data();
398
0
            ColumnPtr temp_null_map = nullptr;
399
            // maybe both children are nullable / or one of children is nullable
400
0
            auto* __restrict lhs_null_map_tmp = create_null_map_column(temp_null_map, lhs_null_map);
401
0
            auto* __restrict rhs_null_map_tmp = create_null_map_column(temp_null_map, rhs_null_map);
402
0
            auto* __restrict lhs_data_column_tmp = lhs_data_column;
403
0
            auto* __restrict rhs_data_column_tmp = rhs_data_column;
404
405
0
            do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, rhs_data_column_tmp,
406
0
                                    rhs_null_map_tmp, res_datas, res_nulls, size);
407
408
0
            result_column = ColumnNullable::create(std::move(col_res), std::move(col_nulls));
409
0
        };
Unexecuted instantiation: _ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE0_clILb1EEEDav
Unexecuted instantiation: _ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE0_clILb0EEEDav
410
411
        // false and NULL ----> 0
412
        // true  and NULL ----> NULL
413
2
        if (_op == TExprOpcode::COMPOUND_AND) {
414
            //1. not null column: all data is false
415
            //2. nullable column: null map all is not null
416
2
            if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
417
                // false and any = false, return lhs
418
0
                return_result_column_id(lhs_column);
419
2
            } else {
420
2
                RETURN_IF_ERROR(get_rhs_colum());
421
422
0
                if ((lhs_all_true && !lhs_is_nullable) ||    //not null column
423
0
                    (lhs_all_true && lhs_all_is_not_null)) { //nullable column
424
                                                             // true and any = any, return rhs
425
426
0
                    return_result_column_id(rhs_column);
427
0
                } else if ((rhs_all_false && !rhs_is_nullable) ||
428
0
                           (rhs_all_false && rhs_all_is_not_null)) {
429
                    // any and false = false, return rhs
430
0
                    return_result_column_id(rhs_column);
431
0
                } else if ((rhs_all_true && !rhs_is_nullable) ||
432
0
                           (rhs_all_true && rhs_all_is_not_null)) {
433
                    // any and true = any, return lhs
434
0
                    return_result_column_id(lhs_column);
435
0
                } else {
436
0
                    if (!result_is_nullable) {
437
0
                        vector_vector.template operator()<true>();
438
0
                    } else {
439
0
                        vector_vector_null.template operator()<true>();
440
0
                    }
441
0
                }
442
0
            }
443
2
        } else if (_op == TExprOpcode::COMPOUND_OR) {
444
            // true  or NULL ----> 1
445
            // false or NULL ----> NULL
446
0
            if ((lhs_all_true && !lhs_is_nullable) || (lhs_all_true && lhs_all_is_not_null)) {
447
                // true or any = true, return lhs
448
0
                return_result_column_id(lhs_column);
449
0
            } else {
450
0
                RETURN_IF_ERROR(get_rhs_colum());
451
0
                if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
452
                    // false or any = any, return rhs
453
0
                    return_result_column_id(rhs_column);
454
0
                } else if ((rhs_all_true && !rhs_is_nullable) ||
455
0
                           (rhs_all_true && rhs_all_is_not_null)) {
456
                    // any or true = true, return rhs
457
0
                    return_result_column_id(rhs_column);
458
0
                } else if ((rhs_all_false && !rhs_is_nullable) ||
459
0
                           (rhs_all_false && rhs_all_is_not_null)) {
460
                    // any or false = any, return lhs
461
0
                    return_result_column_id(lhs_column);
462
0
                } else {
463
0
                    if (!result_is_nullable) {
464
0
                        vector_vector.template operator()<false>();
465
0
                    } else {
466
0
                        vector_vector_null.template operator()<false>();
467
0
                    }
468
0
                }
469
0
            }
470
0
        } else {
471
0
            return Status::InternalError("Compound operator must be AND or OR.");
472
0
        }
473
474
2
        DCHECK_EQ(result_column->size(), count);
475
0
        return Status::OK();
476
2
    }
477
478
0
    double execute_cost() const override {
479
0
        double cost = 0.3;
480
0
        for (const auto& child : _children) {
481
0
            cost += child->execute_cost();
482
0
        }
483
0
        return cost;
484
0
    }
485
486
private:
487
0
    static inline constexpr uint8_t apply_and_null(UInt8 a, UInt8 l_null, UInt8 b, UInt8 r_null) {
488
        // (<> && false) is false, (true && NULL) is NULL
489
0
        return (l_null & r_null) | (r_null & (l_null ^ a)) | (l_null & (r_null ^ b));
490
0
    }
491
0
    static inline constexpr uint8_t apply_or_null(UInt8 a, UInt8 l_null, UInt8 b, UInt8 r_null) {
492
        // (<> || true) is true, (false || NULL) is NULL
493
0
        return (l_null & r_null) | (r_null & (r_null ^ a)) | (l_null & (l_null ^ b));
494
0
    }
495
496
    template <bool is_and>
497
    void static do_not_null_pred(uint8_t* __restrict lhs, const uint8_t* __restrict rhs,
498
0
                                 size_t size) {
499
#ifdef NDEBUG
500
#if defined(__clang__)
501
#pragma clang loop vectorize(enable)
502
#elif defined(__GNUC__) && (__GNUC__ >= 5)
503
#pragma GCC ivdep
504
#endif
505
#endif
506
0
        for (size_t i = 0; i < size; ++i) {
507
0
            if constexpr (is_and) {
508
0
                lhs[i] &= rhs[i];
509
0
            } else {
510
0
                lhs[i] |= rhs[i];
511
0
            }
512
0
        }
513
0
    }
Unexecuted instantiation: _ZN5doris13VCompoundPred16do_not_null_predILb1EEEvPhPKhm
Unexecuted instantiation: _ZN5doris13VCompoundPred16do_not_null_predILb0EEEvPhPKhm
514
515
    template <bool is_and>
516
    void static do_null_pred(const uint8_t* __restrict lhs_data, const uint8_t* __restrict lhs_null,
517
                             const uint8_t* __restrict rhs_data, const uint8_t* __restrict rhs_null,
518
                             uint8_t* __restrict res_data, uint8_t* __restrict res_null,
519
0
                             size_t size) {
520
#ifdef NDEBUG
521
#if defined(__clang__)
522
#pragma clang loop vectorize(enable)
523
#elif defined(__GNUC__) && (__GNUC__ >= 5)
524
#pragma GCC ivdep
525
#endif
526
#endif
527
0
        for (size_t i = 0; i < size; ++i) {
528
0
            if constexpr (is_and) {
529
0
                res_null[i] = apply_and_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
530
0
                res_data[i] = lhs_data[i] & rhs_data[i];
531
0
            } else {
532
0
                res_null[i] = apply_or_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
533
0
                res_data[i] = lhs_data[i] | rhs_data[i];
534
0
            }
535
0
        }
536
0
    }
Unexecuted instantiation: _ZN5doris13VCompoundPred12do_null_predILb1EEEvPKhS3_S3_S3_PhS4_m
Unexecuted instantiation: _ZN5doris13VCompoundPred12do_null_predILb0EEEvPKhS3_S3_S3_PhS4_m
537
538
2
    bool _has_const_child() const {
539
2
        return std::ranges::any_of(_children,
540
4
                                   [](const VExprSPtr& arg) -> bool { return arg->is_constant(); });
541
2
    }
542
543
    std::pair<const uint8_t*, const uint8_t*> _get_raw_data_and_null_map(
544
2
            const ColumnPtr& column, bool has_nullable_column) const {
545
2
        if (has_nullable_column) {
546
2
            const auto* nullable_column = assert_cast<const ColumnNullable*>(column.get());
547
2
            auto* data_column =
548
2
                    assert_cast<const ColumnUInt8*>(nullable_column->get_nested_column_ptr().get())
549
2
                            ->get_data()
550
2
                            .data();
551
2
            auto* null_map = nullable_column->get_null_map_column_ptr()->get_data().data();
552
2
            return std::make_pair(data_column, null_map);
553
2
        } else {
554
0
            auto* data_column = assert_cast<const ColumnUInt8*>(column.get())->get_data().data();
555
0
            return std::make_pair(data_column, nullptr);
556
0
        }
557
2
    }
558
559
    TExprOpcode::type _op;
560
};
561
562
} // namespace doris