Coverage Report

Created: 2026-07-28 14:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/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
#include "common/compile_check_begin.h"
37
38
29
inline std::string compound_operator_to_string(TExprOpcode::type op) {
39
29
    if (op == TExprOpcode::COMPOUND_AND) {
40
16
        return "and";
41
16
    } else if (op == TExprOpcode::COMPOUND_OR) {
42
12
        return "or";
43
12
    } else {
44
1
        return "not";
45
1
    }
46
29
}
47
48
class VCompoundPred : public VectorizedFnCall {
49
    ENABLE_FACTORY_CREATOR(VCompoundPred);
50
51
public:
52
29
    VCompoundPred(const TExprNode& node) : VectorizedFnCall(node) {
53
29
        _op = node.opcode;
54
29
        _fn.name.function_name = compound_operator_to_string(_op);
55
29
        _expr_name = fmt::format("VCompoundPredicate[{}](arguments={},return={})",
56
29
                                 _fn.name.function_name, get_child_names(), _data_type->get_name());
57
29
    }
58
59
#ifdef BE_TEST
60
2
    VCompoundPred() = default;
61
#endif
62
63
18
    const std::string& expr_name() const override { return _expr_name; }
64
0
    Status clone_node(VExprSPtr* cloned_expr) const override {
65
0
        DORIS_CHECK(cloned_expr != nullptr);
66
0
        *cloned_expr = VCompoundPred::create_shared(clone_texpr_node());
67
0
        return Status::OK();
68
0
    }
69
70
21
    bool can_evaluate_zonemap_filter() const override {
71
21
        switch (_op) {
72
20
        case TExprOpcode::COMPOUND_AND:
73
40
            return std::ranges::any_of(_children, [](const VExprSPtr& child) {
74
40
                return child->can_evaluate_zonemap_filter();
75
40
            });
76
1
        case TExprOpcode::COMPOUND_OR:
77
2
            return !_children.empty() && std::ranges::all_of(_children, [](const VExprSPtr& child) {
78
2
                return child->can_evaluate_zonemap_filter();
79
2
            });
80
0
        case TExprOpcode::COMPOUND_NOT:
81
0
            return false;
82
0
        default:
83
0
            return false;
84
21
        }
85
21
    }
86
87
5
    ZoneMapFilterResult evaluate_zonemap_filter(const ZoneMapEvalContext& ctx) const override {
88
5
        switch (_op) {
89
2
        case TExprOpcode::COMPOUND_AND: {
90
4
            for (const auto& child : _children) {
91
4
                if (!child->can_evaluate_zonemap_filter()) {
92
1
                    continue;
93
1
                }
94
3
                if (child->evaluate_zonemap_filter(ctx) == ZoneMapFilterResult::kNoMatch) {
95
2
                    return ZoneMapFilterResult::kNoMatch;
96
2
                }
97
3
            }
98
0
            return ZoneMapFilterResult::kMayMatch;
99
2
        }
100
2
        case TExprOpcode::COMPOUND_OR: {
101
4
            for (const auto& child : _children) {
102
4
                DORIS_CHECK(child->can_evaluate_zonemap_filter());
103
4
                if (child->evaluate_zonemap_filter(ctx) != ZoneMapFilterResult::kNoMatch) {
104
1
                    return ZoneMapFilterResult::kMayMatch;
105
1
                }
106
4
            }
107
1
            return ZoneMapFilterResult::kNoMatch;
108
2
        }
109
1
        case TExprOpcode::COMPOUND_NOT:
110
1
            return unsupported_zonemap_filter(ctx);
111
0
        default:
112
0
            return unsupported_zonemap_filter(ctx);
113
5
        }
114
5
    }
115
116
30
    bool can_evaluate_dictionary_filter() const override {
117
30
        switch (_op) {
118
30
        case TExprOpcode::COMPOUND_AND:
119
33
            return std::ranges::any_of(_children, [](const VExprSPtr& child) {
120
33
                return child->can_evaluate_dictionary_filter();
121
33
            });
122
0
        case TExprOpcode::COMPOUND_OR:
123
0
            return !_children.empty() && std::ranges::all_of(_children, [](const VExprSPtr& child) {
124
0
                return child->can_evaluate_dictionary_filter();
125
0
            });
126
0
        default:
127
0
            return false;
128
30
        }
129
30
    }
130
131
7
    bool is_safe_to_execute_on_selected_rows() const override {
132
        // Boolean composition introduces no data-dependent failure of its own. Reuse the generic
133
        // child walk so AND/OR remain eligible only when every nested expression is independently
134
        // safe; applying VectorizedFnCall's scalar-function allowlist to this structural node would
135
        // incorrectly disable selected-row execution for otherwise safe predicates.
136
7
        return VExpr::is_safe_to_execute_on_selected_rows();
137
7
    }
138
139
    ZoneMapFilterResult evaluate_dictionary_filter(
140
21
            const DictionaryEvalContext& ctx) const override {
141
21
        switch (_op) {
142
21
        case TExprOpcode::COMPOUND_AND:
143
29
            for (const auto& child : _children) {
144
29
                if (!child->can_evaluate_dictionary_filter()) {
145
8
                    continue;
146
8
                }
147
21
                if (child->evaluate_dictionary_filter(ctx) == ZoneMapFilterResult::kNoMatch) {
148
13
                    return ZoneMapFilterResult::kNoMatch;
149
13
                }
150
21
            }
151
8
            return ZoneMapFilterResult::kMayMatch;
152
0
        case TExprOpcode::COMPOUND_OR:
153
0
            for (const auto& child : _children) {
154
0
                DORIS_CHECK(child->can_evaluate_dictionary_filter());
155
0
                if (child->evaluate_dictionary_filter(ctx) != ZoneMapFilterResult::kNoMatch) {
156
0
                    return ZoneMapFilterResult::kMayMatch;
157
0
                }
158
0
            }
159
0
            return ZoneMapFilterResult::kNoMatch;
160
0
        default:
161
0
            return ZoneMapFilterResult::kUnsupported;
162
21
        }
163
21
    }
164
165
6
    bool can_evaluate_bloom_filter() const override {
166
6
        switch (_op) {
167
6
        case TExprOpcode::COMPOUND_AND:
168
12
            return std::ranges::any_of(_children, [](const VExprSPtr& child) {
169
12
                return child->can_evaluate_bloom_filter();
170
12
            });
171
0
        case TExprOpcode::COMPOUND_OR:
172
0
            return !_children.empty() && std::ranges::all_of(_children, [](const VExprSPtr& child) {
173
0
                return child->can_evaluate_bloom_filter();
174
0
            });
175
0
        default:
176
0
            return false;
177
6
        }
178
6
    }
179
180
0
    ZoneMapFilterResult evaluate_bloom_filter(const BloomFilterEvalContext& ctx) const override {
181
0
        switch (_op) {
182
0
        case TExprOpcode::COMPOUND_AND:
183
0
            for (const auto& child : _children) {
184
0
                if (!child->can_evaluate_bloom_filter()) {
185
0
                    continue;
186
0
                }
187
0
                if (child->evaluate_bloom_filter(ctx) == ZoneMapFilterResult::kNoMatch) {
188
0
                    return ZoneMapFilterResult::kNoMatch;
189
0
                }
190
0
            }
191
0
            return ZoneMapFilterResult::kMayMatch;
192
0
        case TExprOpcode::COMPOUND_OR:
193
0
            for (const auto& child : _children) {
194
0
                DORIS_CHECK(child->can_evaluate_bloom_filter());
195
0
                if (child->evaluate_bloom_filter(ctx) != ZoneMapFilterResult::kNoMatch) {
196
0
                    return ZoneMapFilterResult::kMayMatch;
197
0
                }
198
0
            }
199
0
            return ZoneMapFilterResult::kNoMatch;
200
0
        default:
201
0
            return ZoneMapFilterResult::kUnsupported;
202
0
        }
203
0
    }
204
205
0
    Status evaluate_inverted_index(VExprContext* context, uint32_t segment_num_rows) override {
206
0
        segment_v2::InvertedIndexResultBitmap res;
207
0
        bool all_pass = true;
208
209
0
        switch (_op) {
210
0
        case TExprOpcode::COMPOUND_OR: {
211
0
            for (const auto& child : _children) {
212
0
                if (Status st = child->evaluate_inverted_index(context, segment_num_rows);
213
0
                    !st.ok()) {
214
0
                    LOG(ERROR) << "expr:" << child->expr_name()
215
0
                               << " evaluate_inverted_index error:" << st.to_string();
216
0
                    all_pass = false;
217
0
                    continue;
218
0
                }
219
0
                auto inverted_index_context = context->get_index_context();
220
0
                if (inverted_index_context->has_index_result_for_expr(child.get())) {
221
0
                    const auto* index_result =
222
0
                            inverted_index_context->get_index_result_for_expr(child.get());
223
0
                    if (res.is_empty()) {
224
0
                        res = *index_result;
225
0
                    } else {
226
0
                        res |= *index_result;
227
0
                    }
228
0
                    if (inverted_index_context->get_score_runtime() == nullptr) {
229
0
                        if (res.get_data_bitmap()->cardinality() == segment_num_rows) {
230
0
                            break; // Early exit if result is full
231
0
                        }
232
0
                    }
233
0
                } else {
234
0
                    all_pass = false;
235
0
                }
236
0
            }
237
0
            break;
238
0
        }
239
0
        case TExprOpcode::COMPOUND_AND: {
240
0
            for (const auto& child : _children) {
241
0
                if (Status st = child->evaluate_inverted_index(context, segment_num_rows);
242
0
                    !st.ok()) {
243
0
                    LOG(ERROR) << "expr:" << child->expr_name()
244
0
                               << " evaluate_inverted_index error:" << st.to_string();
245
0
                    all_pass = false;
246
0
                    continue;
247
0
                }
248
0
                if (context->get_index_context()->has_index_result_for_expr(child.get())) {
249
0
                    const auto* index_result =
250
0
                            context->get_index_context()->get_index_result_for_expr(child.get());
251
0
                    if (res.is_empty()) {
252
0
                        res = *index_result;
253
0
                    } else {
254
0
                        res &= *index_result;
255
0
                    }
256
257
0
                    if (res.get_data_bitmap()->isEmpty()) {
258
0
                        break; // Early exit if result is empty
259
0
                    }
260
0
                } else {
261
0
                    all_pass = false;
262
0
                }
263
0
            }
264
0
            break;
265
0
        }
266
0
        case TExprOpcode::COMPOUND_NOT: {
267
0
            const auto& child = _children[0];
268
0
            Status st = child->evaluate_inverted_index(context, segment_num_rows);
269
0
            if (!st.ok()) {
270
0
                LOG(ERROR) << "expr:" << child->expr_name()
271
0
                           << " evaluate_inverted_index error:" << st.to_string();
272
0
                return st;
273
0
            }
274
275
0
            if (context->get_index_context()->has_index_result_for_expr(child.get())) {
276
0
                const auto* index_result =
277
0
                        context->get_index_context()->get_index_result_for_expr(child.get());
278
0
                roaring::Roaring full_result;
279
0
                full_result.addRange(0, segment_num_rows);
280
0
                res = index_result->op_not(&full_result);
281
0
            } else {
282
0
                all_pass = false;
283
0
            }
284
0
            break;
285
0
        }
286
0
        default:
287
0
            return Status::NotSupported(
288
0
                    "Compound operator must be AND, OR, or NOT to execute with inverted index.");
289
0
        }
290
291
0
        if (all_pass && !res.is_empty()) {
292
0
            context->get_index_context()->set_index_result_for_expr(this, res);
293
0
        }
294
0
        return Status::OK();
295
0
    }
296
297
    Status execute_column(VExprContext* context, const Block* block, Selector* selector,
298
1
                          size_t count, ColumnPtr& result_column) const override {
299
1
        if (fast_execute(context, selector, count, result_column)) {
300
0
            return Status::OK();
301
0
        }
302
1
        if (get_num_children() == 1 || _has_const_child()) {
303
0
            return VectorizedFnCall::execute_column(context, block, selector, count, result_column);
304
0
        }
305
306
1
        ColumnPtr lhs_column;
307
1
        RETURN_IF_ERROR(_children[0]->execute_column(context, block, selector, count, lhs_column));
308
1
        lhs_column = lhs_column->convert_to_full_column_if_const();
309
1
        size_t size = lhs_column->size();
310
311
1
        bool lhs_is_nullable = lhs_column->is_nullable();
312
1
        auto [lhs_data_column, lhs_null_map] =
313
1
                _get_raw_data_and_null_map(lhs_column, lhs_is_nullable);
314
1
        size_t filted = simd::count_zero_num((int8_t*)lhs_data_column, size);
315
1
        bool lhs_all_true = (filted == 0);
316
1
        bool lhs_all_false = (filted == size);
317
318
1
        bool lhs_all_is_not_null = false;
319
1
        if (lhs_is_nullable) {
320
1
            filted = simd::count_zero_num((int8_t*)lhs_null_map, size);
321
1
            lhs_all_is_not_null = (filted == size);
322
1
        }
323
324
1
        ColumnPtr rhs_column = nullptr;
325
1
        const uint8_t* __restrict rhs_data_column = nullptr;
326
1
        const uint8_t* __restrict rhs_null_map = nullptr;
327
1
        bool rhs_is_nullable = false;
328
1
        bool rhs_all_true = false;
329
1
        bool rhs_all_false = false;
330
1
        bool rhs_all_is_not_null = false;
331
1
        bool result_is_nullable = _data_type->is_nullable();
332
333
1
        auto get_rhs_colum = [&]() {
334
1
            if (!rhs_column) {
335
1
                RETURN_IF_ERROR(
336
1
                        _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
1
        };
352
353
1
        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
1
        auto create_null_map_column = [&](ColumnPtr& null_map_column,
361
1
                                          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
1
        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: _ZZNK5doris13VCompoundPred14execute_columnEPNS_12VExprContextEPKNS_5BlockEPNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISD_EEENKUlTnbvE_clILb1EEEDav
Unexecuted instantiation: _ZZNK5doris13VCompoundPred14execute_columnEPNS_12VExprContextEPKNS_5BlockEPNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISD_EEENKUlTnbvE_clILb0EEEDav
392
1
        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: _ZZNK5doris13VCompoundPred14execute_columnEPNS_12VExprContextEPKNS_5BlockEPNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISD_EEENKUlTnbvE0_clILb1EEEDav
Unexecuted instantiation: _ZZNK5doris13VCompoundPred14execute_columnEPNS_12VExprContextEPKNS_5BlockEPNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISD_EEENKUlTnbvE0_clILb0EEEDav
410
411
        // false and NULL ----> 0
412
        // true  and NULL ----> NULL
413
1
        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
1
            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
1
            } else {
420
1
                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
1
        } 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
1
        DCHECK_EQ(result_column->size(), count);
475
0
        return Status::OK();
476
1
    }
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
1
    bool _has_const_child() const {
539
1
        return std::ranges::any_of(_children,
540
2
                                   [](const VExprSPtr& arg) -> bool { return arg->is_constant(); });
541
1
    }
542
543
    std::pair<const uint8_t*, const uint8_t*> _get_raw_data_and_null_map(
544
1
            const ColumnPtr& column, bool has_nullable_column) const {
545
1
        if (has_nullable_column) {
546
1
            const auto* nullable_column = assert_cast<const ColumnNullable*>(column.get());
547
1
            auto* data_column =
548
1
                    assert_cast<const ColumnUInt8*>(nullable_column->get_nested_column_ptr().get())
549
1
                            ->get_data()
550
1
                            .data();
551
1
            auto* null_map = nullable_column->get_null_map_column_ptr()->get_data().data();
552
1
            return std::make_pair(data_column, null_map);
553
1
        } 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
1
    }
558
559
    TExprOpcode::type _op;
560
};
561
562
#include "common/compile_check_end.h"
563
} // namespace doris