Coverage Report

Created: 2026-05-26 07:14

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/status.h"
25
#include "core/assert_cast.h"
26
#include "core/column/column.h"
27
#include "core/column/column_nullable.h"
28
#include "exprs/vectorized_fn_call.h"
29
#include "exprs/vexpr_context.h"
30
#include "exprs/vexpr_fwd.h"
31
#include "util/simd/bits.h"
32
33
namespace doris {
34
35
5.87k
inline std::string compound_operator_to_string(TExprOpcode::type op) {
36
5.87k
    if (op == TExprOpcode::COMPOUND_AND) {
37
1.02k
        return "and";
38
4.85k
    } else if (op == TExprOpcode::COMPOUND_OR) {
39
4.36k
        return "or";
40
4.36k
    } else {
41
485
        return "not";
42
485
    }
43
5.87k
}
44
45
class VCompoundPred : public VectorizedFnCall {
46
    ENABLE_FACTORY_CREATOR(VCompoundPred);
47
48
public:
49
5.87k
    VCompoundPred(const TExprNode& node) : VectorizedFnCall(node) {
50
5.87k
        _op = node.opcode;
51
5.87k
        _fn.name.function_name = compound_operator_to_string(_op);
52
5.87k
        _expr_name = fmt::format("VCompoundPredicate[{}](arguments={},return={})",
53
5.87k
                                 _fn.name.function_name, get_child_names(), _data_type->get_name());
54
5.87k
    }
55
56
#ifdef BE_TEST
57
    VCompoundPred() = default;
58
#endif
59
60
10.2k
    const std::string& expr_name() const override { return _expr_name; }
61
62
4.92k
    Status evaluate_inverted_index(VExprContext* context, uint32_t segment_num_rows) override {
63
4.92k
        segment_v2::InvertedIndexResultBitmap res;
64
4.92k
        bool all_pass = true;
65
66
4.92k
        switch (_op) {
67
3.23k
        case TExprOpcode::COMPOUND_OR: {
68
6.24k
            for (const auto& child : _children) {
69
6.24k
                if (Status st = child->evaluate_inverted_index(context, segment_num_rows);
70
6.24k
                    !st.ok()) {
71
177
                    LOG(ERROR) << "expr:" << child->expr_name()
72
177
                               << " evaluate_inverted_index error:" << st.to_string();
73
177
                    all_pass = false;
74
177
                    continue;
75
177
                }
76
6.06k
                auto inverted_index_context = context->get_index_context();
77
6.06k
                if (inverted_index_context->has_index_result_for_expr(child.get())) {
78
3.24k
                    const auto* index_result =
79
3.24k
                            inverted_index_context->get_index_result_for_expr(child.get());
80
3.24k
                    if (res.is_empty()) {
81
2.24k
                        res = *index_result;
82
2.24k
                    } else {
83
1.00k
                        res |= *index_result;
84
1.00k
                    }
85
3.24k
                    if (inverted_index_context->get_score_runtime() == nullptr) {
86
3.24k
                        if (res.get_data_bitmap()->cardinality() == segment_num_rows) {
87
355
                            break; // Early exit if result is full
88
355
                        }
89
3.24k
                    }
90
3.24k
                } else {
91
2.82k
                    all_pass = false;
92
2.82k
                }
93
6.06k
            }
94
3.23k
            break;
95
0
        }
96
5.71k
        case TExprOpcode::COMPOUND_AND: {
97
1.18k
            for (const auto& child : _children) {
98
1.18k
                if (Status st = child->evaluate_inverted_index(context, segment_num_rows);
99
1.18k
                    !st.ok()) {
100
32
                    LOG(ERROR) << "expr:" << child->expr_name()
101
32
                               << " evaluate_inverted_index error:" << st.to_string();
102
32
                    all_pass = false;
103
32
                    continue;
104
32
                }
105
1.15k
                if (context->get_index_context()->has_index_result_for_expr(child.get())) {
106
259
                    const auto* index_result =
107
259
                            context->get_index_context()->get_index_result_for_expr(child.get());
108
259
                    if (res.is_empty()) {
109
193
                        res = *index_result;
110
193
                    } else {
111
66
                        res &= *index_result;
112
66
                    }
113
114
259
                    if (res.get_data_bitmap()->isEmpty()) {
115
114
                        break; // Early exit if result is empty
116
114
                    }
117
893
                } else {
118
893
                    all_pass = false;
119
893
                }
120
1.15k
            }
121
640
            break;
122
0
        }
123
1.04k
        case TExprOpcode::COMPOUND_NOT: {
124
1.04k
            const auto& child = _children[0];
125
1.04k
            Status st = child->evaluate_inverted_index(context, segment_num_rows);
126
1.04k
            if (!st.ok()) {
127
35
                LOG(ERROR) << "expr:" << child->expr_name()
128
35
                           << " evaluate_inverted_index error:" << st.to_string();
129
35
                return st;
130
35
            }
131
132
1.01k
            if (context->get_index_context()->has_index_result_for_expr(child.get())) {
133
640
                const auto* index_result =
134
640
                        context->get_index_context()->get_index_result_for_expr(child.get());
135
640
                roaring::Roaring full_result;
136
640
                full_result.addRange(0, segment_num_rows);
137
640
                res = index_result->op_not(&full_result);
138
640
            } else {
139
374
                all_pass = false;
140
374
            }
141
1.01k
            break;
142
1.04k
        }
143
0
        default:
144
0
            return Status::NotSupported(
145
0
                    "Compound operator must be AND, OR, or NOT to execute with inverted index.");
146
4.92k
        }
147
148
4.92k
        if (all_pass && !res.is_empty()) {
149
2.03k
            context->get_index_context()->set_index_result_for_expr(this, res);
150
2.03k
        }
151
4.92k
        return Status::OK();
152
4.92k
    }
153
154
    Status execute_column_impl(VExprContext* context, const Block* block, const Selector* selector,
155
47.1k
                               size_t count, ColumnPtr& result_column) const override {
156
47.1k
        if (fast_execute(context, selector, count, result_column)) {
157
94
            return Status::OK();
158
94
        }
159
47.0k
        if (get_num_children() == 1 || _has_const_child()) {
160
837
            return VectorizedFnCall::execute_column_impl(context, block, selector, count,
161
837
                                                         result_column);
162
837
        }
163
164
46.1k
        ColumnPtr lhs_column;
165
46.1k
        RETURN_IF_ERROR(_children[0]->execute_column(context, block, selector, count, lhs_column));
166
46.1k
        lhs_column = lhs_column->convert_to_full_column_if_const();
167
46.1k
        size_t size = lhs_column->size();
168
169
46.1k
        bool lhs_is_nullable = lhs_column->is_nullable();
170
46.1k
        auto [lhs_data_column, lhs_null_map] =
171
46.1k
                _get_raw_data_and_null_map(lhs_column, lhs_is_nullable);
172
46.1k
        size_t filted = simd::count_zero_num((int8_t*)lhs_data_column, size);
173
46.1k
        bool lhs_all_true = (filted == 0);
174
46.1k
        bool lhs_all_false = (filted == size);
175
176
46.1k
        bool lhs_all_is_not_null = false;
177
46.1k
        if (lhs_is_nullable) {
178
34.3k
            filted = simd::count_zero_num((int8_t*)lhs_null_map, size);
179
34.3k
            lhs_all_is_not_null = (filted == size);
180
34.3k
        }
181
182
46.1k
        ColumnPtr rhs_column = nullptr;
183
46.1k
        const uint8_t* __restrict rhs_data_column = nullptr;
184
46.1k
        const uint8_t* __restrict rhs_null_map = nullptr;
185
46.1k
        bool rhs_is_nullable = false;
186
46.1k
        bool rhs_all_true = false;
187
46.1k
        bool rhs_all_false = false;
188
46.1k
        bool rhs_all_is_not_null = false;
189
46.1k
        bool result_is_nullable = _data_type->is_nullable();
190
191
46.1k
        auto get_rhs_colum = [&]() {
192
33.4k
            if (!rhs_column) {
193
33.4k
                RETURN_IF_ERROR(
194
33.4k
                        _children[1]->execute_column(context, block, selector, count, rhs_column));
195
33.4k
                rhs_column = rhs_column->convert_to_full_column_if_const();
196
33.4k
                rhs_is_nullable = rhs_column->is_nullable();
197
33.4k
                auto rhs_nullable_column = _get_raw_data_and_null_map(rhs_column, rhs_is_nullable);
198
33.4k
                rhs_data_column = rhs_nullable_column.first;
199
33.4k
                rhs_null_map = rhs_nullable_column.second;
200
33.4k
                size_t filted = simd::count_zero_num((int8_t*)rhs_data_column, size);
201
33.4k
                rhs_all_true = (filted == 0);
202
33.4k
                rhs_all_false = (filted == size);
203
33.4k
                if (rhs_is_nullable) {
204
27.7k
                    filted = simd::count_zero_num((int8_t*)rhs_null_map, size);
205
27.7k
                    rhs_all_is_not_null = (filted == size);
206
27.7k
                }
207
33.4k
            }
208
33.4k
            return Status::OK();
209
33.4k
        };
210
211
46.1k
        auto return_result_column_id = [&](ColumnPtr& arg_column) {
212
41.4k
            result_column = std::move(*arg_column).mutate();
213
41.4k
            if (result_is_nullable && !result_column->is_nullable()) {
214
2.64k
                result_column = make_nullable(result_column);
215
2.64k
            }
216
41.4k
        };
217
218
46.1k
        auto create_null_map_column = [&](ColumnPtr& null_map_column,
219
46.1k
                                          const uint8_t* __restrict null_map_data) {
220
8.60k
            if (null_map_data == nullptr) {
221
589
                null_map_column = ColumnUInt8::create(size, 0);
222
589
                null_map_data =
223
589
                        assert_cast<const ColumnUInt8*>(null_map_column.get())->get_data().data();
224
589
            }
225
8.60k
            return null_map_data;
226
8.60k
        };
227
228
46.1k
        auto vector_vector = [&]<bool is_and_op>() {
229
410
            MutableColumnPtr mutable_result_column;
230
410
            uint8_t* __restrict result_data_column = nullptr;
231
410
            const uint8_t* __restrict other_data_column = rhs_data_column;
232
410
            if (lhs_column->use_count() == 1) {
233
404
                mutable_result_column = IColumn::mutate(std::move(lhs_column));
234
404
                result_data_column =
235
404
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
236
404
            } else if (rhs_column->use_count() == 1) {
237
1
                mutable_result_column = IColumn::mutate(std::move(rhs_column));
238
1
                result_data_column =
239
1
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
240
1
                other_data_column = lhs_data_column;
241
5
            } else {
242
5
                mutable_result_column = lhs_column->clone_resized(size);
243
5
                result_data_column =
244
5
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
245
5
            }
246
247
410
            do_not_null_pred<is_and_op>(result_data_column, other_data_column, size);
248
410
            result_column = std::move(mutable_result_column);
249
410
        };
_ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE_clILb1EEEDav
Line
Count
Source
228
311
        auto vector_vector = [&]<bool is_and_op>() {
229
311
            MutableColumnPtr mutable_result_column;
230
311
            uint8_t* __restrict result_data_column = nullptr;
231
311
            const uint8_t* __restrict other_data_column = rhs_data_column;
232
311
            if (lhs_column->use_count() == 1) {
233
311
                mutable_result_column = IColumn::mutate(std::move(lhs_column));
234
311
                result_data_column =
235
311
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
236
311
            } else if (rhs_column->use_count() == 1) {
237
0
                mutable_result_column = IColumn::mutate(std::move(rhs_column));
238
0
                result_data_column =
239
0
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
240
0
                other_data_column = lhs_data_column;
241
0
            } else {
242
0
                mutable_result_column = lhs_column->clone_resized(size);
243
0
                result_data_column =
244
0
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
245
0
            }
246
247
311
            do_not_null_pred<is_and_op>(result_data_column, other_data_column, size);
248
311
            result_column = std::move(mutable_result_column);
249
311
        };
_ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE_clILb0EEEDav
Line
Count
Source
228
99
        auto vector_vector = [&]<bool is_and_op>() {
229
99
            MutableColumnPtr mutable_result_column;
230
99
            uint8_t* __restrict result_data_column = nullptr;
231
99
            const uint8_t* __restrict other_data_column = rhs_data_column;
232
99
            if (lhs_column->use_count() == 1) {
233
93
                mutable_result_column = IColumn::mutate(std::move(lhs_column));
234
93
                result_data_column =
235
93
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
236
93
            } else if (rhs_column->use_count() == 1) {
237
1
                mutable_result_column = IColumn::mutate(std::move(rhs_column));
238
1
                result_data_column =
239
1
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
240
1
                other_data_column = lhs_data_column;
241
5
            } else {
242
5
                mutable_result_column = lhs_column->clone_resized(size);
243
5
                result_data_column =
244
5
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
245
5
            }
246
247
99
            do_not_null_pred<is_and_op>(result_data_column, other_data_column, size);
248
99
            result_column = std::move(mutable_result_column);
249
99
        };
250
46.1k
        auto vector_vector_null = [&]<bool is_and_op>() {
251
4.30k
            auto col_res = ColumnUInt8::create(size);
252
4.30k
            auto col_nulls = ColumnUInt8::create(size);
253
254
4.30k
            auto* __restrict res_datas = col_res->get_data().data();
255
4.30k
            auto* __restrict res_nulls = col_nulls->get_data().data();
256
4.30k
            ColumnPtr temp_null_map = nullptr;
257
            // maybe both children are nullable / or one of children is nullable
258
4.30k
            auto* __restrict lhs_null_map_tmp = create_null_map_column(temp_null_map, lhs_null_map);
259
4.30k
            auto* __restrict rhs_null_map_tmp = create_null_map_column(temp_null_map, rhs_null_map);
260
4.30k
            auto* __restrict lhs_data_column_tmp = lhs_data_column;
261
4.30k
            auto* __restrict rhs_data_column_tmp = rhs_data_column;
262
263
4.30k
            do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, rhs_data_column_tmp,
264
4.30k
                                    rhs_null_map_tmp, res_datas, res_nulls, size);
265
266
4.30k
            result_column = ColumnNullable::create(std::move(col_res), std::move(col_nulls));
267
4.30k
        };
_ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE0_clILb1EEEDav
Line
Count
Source
250
1.12k
        auto vector_vector_null = [&]<bool is_and_op>() {
251
1.12k
            auto col_res = ColumnUInt8::create(size);
252
1.12k
            auto col_nulls = ColumnUInt8::create(size);
253
254
1.12k
            auto* __restrict res_datas = col_res->get_data().data();
255
1.12k
            auto* __restrict res_nulls = col_nulls->get_data().data();
256
1.12k
            ColumnPtr temp_null_map = nullptr;
257
            // maybe both children are nullable / or one of children is nullable
258
1.12k
            auto* __restrict lhs_null_map_tmp = create_null_map_column(temp_null_map, lhs_null_map);
259
1.12k
            auto* __restrict rhs_null_map_tmp = create_null_map_column(temp_null_map, rhs_null_map);
260
1.12k
            auto* __restrict lhs_data_column_tmp = lhs_data_column;
261
1.12k
            auto* __restrict rhs_data_column_tmp = rhs_data_column;
262
263
1.12k
            do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, rhs_data_column_tmp,
264
1.12k
                                    rhs_null_map_tmp, res_datas, res_nulls, size);
265
266
1.12k
            result_column = ColumnNullable::create(std::move(col_res), std::move(col_nulls));
267
1.12k
        };
_ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE0_clILb0EEEDav
Line
Count
Source
250
3.17k
        auto vector_vector_null = [&]<bool is_and_op>() {
251
3.17k
            auto col_res = ColumnUInt8::create(size);
252
3.17k
            auto col_nulls = ColumnUInt8::create(size);
253
254
3.17k
            auto* __restrict res_datas = col_res->get_data().data();
255
3.17k
            auto* __restrict res_nulls = col_nulls->get_data().data();
256
3.17k
            ColumnPtr temp_null_map = nullptr;
257
            // maybe both children are nullable / or one of children is nullable
258
3.17k
            auto* __restrict lhs_null_map_tmp = create_null_map_column(temp_null_map, lhs_null_map);
259
3.17k
            auto* __restrict rhs_null_map_tmp = create_null_map_column(temp_null_map, rhs_null_map);
260
3.17k
            auto* __restrict lhs_data_column_tmp = lhs_data_column;
261
3.17k
            auto* __restrict rhs_data_column_tmp = rhs_data_column;
262
263
3.17k
            do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, rhs_data_column_tmp,
264
3.17k
                                    rhs_null_map_tmp, res_datas, res_nulls, size);
265
266
3.17k
            result_column = ColumnNullable::create(std::move(col_res), std::move(col_nulls));
267
3.17k
        };
268
269
        // false and NULL ----> 0
270
        // true  and NULL ----> NULL
271
46.1k
        if (_op == TExprOpcode::COMPOUND_AND) {
272
            //1. not null column: all data is false
273
            //2. nullable column: null map all is not null
274
12.5k
            if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
275
                // false and any = false, return lhs
276
8.72k
                return_result_column_id(lhs_column);
277
8.72k
            } else {
278
3.86k
                RETURN_IF_ERROR(get_rhs_colum());
279
280
3.86k
                if ((lhs_all_true && !lhs_is_nullable) ||    //not null column
281
3.86k
                    (lhs_all_true && lhs_all_is_not_null)) { //nullable column
282
                                                             // true and any = any, return rhs
283
284
864
                    return_result_column_id(rhs_column);
285
2.99k
                } else if ((rhs_all_false && !rhs_is_nullable) ||
286
2.99k
                           (rhs_all_false && rhs_all_is_not_null)) {
287
                    // any and false = false, return rhs
288
560
                    return_result_column_id(rhs_column);
289
2.43k
                } else if ((rhs_all_true && !rhs_is_nullable) ||
290
2.43k
                           (rhs_all_true && rhs_all_is_not_null)) {
291
                    // any and true = any, return lhs
292
1.00k
                    return_result_column_id(lhs_column);
293
1.43k
                } else {
294
1.43k
                    if (!result_is_nullable) {
295
311
                        vector_vector.template operator()<true>();
296
1.12k
                    } else {
297
1.12k
                        vector_vector_null.template operator()<true>();
298
1.12k
                    }
299
1.43k
                }
300
3.86k
            }
301
33.6k
        } else if (_op == TExprOpcode::COMPOUND_OR) {
302
            // true  or NULL ----> 1
303
            // false or NULL ----> NULL
304
33.5k
            if ((lhs_all_true && !lhs_is_nullable) || (lhs_all_true && lhs_all_is_not_null)) {
305
                // true or any = true, return lhs
306
4.02k
                return_result_column_id(lhs_column);
307
29.5k
            } else {
308
29.5k
                RETURN_IF_ERROR(get_rhs_colum());
309
29.5k
                if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
310
                    // false or any = any, return rhs
311
24.3k
                    return_result_column_id(rhs_column);
312
24.3k
                } else if ((rhs_all_true && !rhs_is_nullable) ||
313
5.19k
                           (rhs_all_true && rhs_all_is_not_null)) {
314
                    // any or true = true, return rhs
315
634
                    return_result_column_id(rhs_column);
316
4.55k
                } else if ((rhs_all_false && !rhs_is_nullable) ||
317
4.55k
                           (rhs_all_false && rhs_all_is_not_null)) {
318
                    // any or false = any, return lhs
319
1.28k
                    return_result_column_id(lhs_column);
320
3.27k
                } else {
321
3.27k
                    if (!result_is_nullable) {
322
99
                        vector_vector.template operator()<false>();
323
3.17k
                    } else {
324
3.17k
                        vector_vector_null.template operator()<false>();
325
3.17k
                    }
326
3.27k
                }
327
29.5k
            }
328
33.5k
        } else {
329
23
            return Status::InternalError("Compound operator must be AND or OR.");
330
23
        }
331
332
46.1k
        DCHECK_EQ(result_column->size(), count);
333
46.1k
        return Status::OK();
334
46.1k
    }
335
336
1.18k
    double execute_cost() const override {
337
1.18k
        double cost = 0.3;
338
1.91k
        for (const auto& child : _children) {
339
1.91k
            cost += child->execute_cost();
340
1.91k
        }
341
1.18k
        return cost;
342
1.18k
    }
343
344
private:
345
154k
    static inline constexpr uint8_t apply_and_null(UInt8 a, UInt8 l_null, UInt8 b, UInt8 r_null) {
346
        // (<> && false) is false, (true && NULL) is NULL
347
154k
        return (l_null & r_null) | (r_null & (l_null ^ a)) | (l_null & (r_null ^ b));
348
154k
    }
349
524k
    static inline constexpr uint8_t apply_or_null(UInt8 a, UInt8 l_null, UInt8 b, UInt8 r_null) {
350
        // (<> || true) is true, (false || NULL) is NULL
351
524k
        return (l_null & r_null) | (r_null & (r_null ^ a)) | (l_null & (l_null ^ b));
352
524k
    }
353
354
    template <bool is_and>
355
    void static do_not_null_pred(uint8_t* __restrict lhs, const uint8_t* __restrict rhs,
356
411
                                 size_t size) {
357
#ifdef NDEBUG
358
#if defined(__clang__)
359
#pragma clang loop vectorize(enable)
360
#elif defined(__GNUC__) && (__GNUC__ >= 5)
361
#pragma GCC ivdep
362
#endif
363
#endif
364
70.9k
        for (size_t i = 0; i < size; ++i) {
365
70.5k
            if constexpr (is_and) {
366
66.3k
                lhs[i] &= rhs[i];
367
66.3k
            } else {
368
4.26k
                lhs[i] |= rhs[i];
369
4.26k
            }
370
70.5k
        }
371
411
    }
_ZN5doris13VCompoundPred16do_not_null_predILb1EEEvPhPKhm
Line
Count
Source
356
312
                                 size_t size) {
357
#ifdef NDEBUG
358
#if defined(__clang__)
359
#pragma clang loop vectorize(enable)
360
#elif defined(__GNUC__) && (__GNUC__ >= 5)
361
#pragma GCC ivdep
362
#endif
363
#endif
364
66.6k
        for (size_t i = 0; i < size; ++i) {
365
66.3k
            if constexpr (is_and) {
366
66.3k
                lhs[i] &= rhs[i];
367
            } else {
368
                lhs[i] |= rhs[i];
369
            }
370
66.3k
        }
371
312
    }
_ZN5doris13VCompoundPred16do_not_null_predILb0EEEvPhPKhm
Line
Count
Source
356
99
                                 size_t size) {
357
#ifdef NDEBUG
358
#if defined(__clang__)
359
#pragma clang loop vectorize(enable)
360
#elif defined(__GNUC__) && (__GNUC__ >= 5)
361
#pragma GCC ivdep
362
#endif
363
#endif
364
4.36k
        for (size_t i = 0; i < size; ++i) {
365
            if constexpr (is_and) {
366
                lhs[i] &= rhs[i];
367
4.26k
            } else {
368
4.26k
                lhs[i] |= rhs[i];
369
4.26k
            }
370
4.26k
        }
371
99
    }
372
373
    template <bool is_and>
374
    void static do_null_pred(const uint8_t* __restrict lhs_data, const uint8_t* __restrict lhs_null,
375
                             const uint8_t* __restrict rhs_data, const uint8_t* __restrict rhs_null,
376
                             uint8_t* __restrict res_data, uint8_t* __restrict res_null,
377
4.30k
                             size_t size) {
378
#ifdef NDEBUG
379
#if defined(__clang__)
380
#pragma clang loop vectorize(enable)
381
#elif defined(__GNUC__) && (__GNUC__ >= 5)
382
#pragma GCC ivdep
383
#endif
384
#endif
385
683k
        for (size_t i = 0; i < size; ++i) {
386
679k
            if constexpr (is_and) {
387
154k
                res_null[i] = apply_and_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
388
154k
                res_data[i] = lhs_data[i] & rhs_data[i];
389
524k
            } else {
390
524k
                res_null[i] = apply_or_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
391
524k
                res_data[i] = lhs_data[i] | rhs_data[i];
392
524k
            }
393
679k
        }
394
4.30k
    }
_ZN5doris13VCompoundPred12do_null_predILb1EEEvPKhS3_S3_S3_PhS4_m
Line
Count
Source
377
1.12k
                             size_t size) {
378
#ifdef NDEBUG
379
#if defined(__clang__)
380
#pragma clang loop vectorize(enable)
381
#elif defined(__GNUC__) && (__GNUC__ >= 5)
382
#pragma GCC ivdep
383
#endif
384
#endif
385
156k
        for (size_t i = 0; i < size; ++i) {
386
154k
            if constexpr (is_and) {
387
154k
                res_null[i] = apply_and_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
388
154k
                res_data[i] = lhs_data[i] & rhs_data[i];
389
            } else {
390
                res_null[i] = apply_or_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
391
                res_data[i] = lhs_data[i] | rhs_data[i];
392
            }
393
154k
        }
394
1.12k
    }
_ZN5doris13VCompoundPred12do_null_predILb0EEEvPKhS3_S3_S3_PhS4_m
Line
Count
Source
377
3.17k
                             size_t size) {
378
#ifdef NDEBUG
379
#if defined(__clang__)
380
#pragma clang loop vectorize(enable)
381
#elif defined(__GNUC__) && (__GNUC__ >= 5)
382
#pragma GCC ivdep
383
#endif
384
#endif
385
527k
        for (size_t i = 0; i < size; ++i) {
386
            if constexpr (is_and) {
387
                res_null[i] = apply_and_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
388
                res_data[i] = lhs_data[i] & rhs_data[i];
389
524k
            } else {
390
524k
                res_null[i] = apply_or_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
391
524k
                res_data[i] = lhs_data[i] | rhs_data[i];
392
524k
            }
393
524k
        }
394
3.17k
    }
395
396
46.2k
    bool _has_const_child() const {
397
46.2k
        return std::ranges::any_of(_children,
398
92.4k
                                   [](const VExprSPtr& arg) -> bool { return arg->is_constant(); });
399
46.2k
    }
400
401
    std::pair<const uint8_t*, const uint8_t*> _get_raw_data_and_null_map(
402
79.5k
            const ColumnPtr& column, bool has_nullable_column) const {
403
79.5k
        if (has_nullable_column) {
404
62.1k
            const auto* nullable_column = assert_cast<const ColumnNullable*>(column.get());
405
62.1k
            auto* data_column =
406
62.1k
                    assert_cast<const ColumnUInt8*>(nullable_column->get_nested_column_ptr().get())
407
62.1k
                            ->get_data()
408
62.1k
                            .data();
409
62.1k
            auto* null_map = nullable_column->get_null_map_column_ptr()->get_data().data();
410
62.1k
            return std::make_pair(data_column, null_map);
411
62.1k
        } else {
412
17.4k
            auto* data_column = assert_cast<const ColumnUInt8*>(column.get())->get_data().data();
413
17.4k
            return std::make_pair(data_column, nullptr);
414
17.4k
        }
415
79.5k
    }
416
417
    TExprOpcode::type _op;
418
};
419
420
} // namespace doris