Coverage Report

Created: 2026-07-07 03:26

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