Coverage Report

Created: 2026-05-26 05: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/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.84k
inline std::string compound_operator_to_string(TExprOpcode::type op) {
36
5.84k
    if (op == TExprOpcode::COMPOUND_AND) {
37
1.02k
        return "and";
38
4.81k
    } else if (op == TExprOpcode::COMPOUND_OR) {
39
4.32k
        return "or";
40
4.32k
    } else {
41
485
        return "not";
42
485
    }
43
5.84k
}
44
45
class VCompoundPred : public VectorizedFnCall {
46
    ENABLE_FACTORY_CREATOR(VCompoundPred);
47
48
public:
49
5.84k
    VCompoundPred(const TExprNode& node) : VectorizedFnCall(node) {
50
5.84k
        _op = node.opcode;
51
5.84k
        _fn.name.function_name = compound_operator_to_string(_op);
52
5.84k
        _expr_name = fmt::format("VCompoundPredicate[{}](arguments={},return={})",
53
5.84k
                                 _fn.name.function_name, get_child_names(), _data_type->get_name());
54
5.84k
    }
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
5.16k
    Status evaluate_inverted_index(VExprContext* context, uint32_t segment_num_rows) override {
63
5.16k
        segment_v2::InvertedIndexResultBitmap res;
64
5.16k
        bool all_pass = true;
65
66
5.16k
        switch (_op) {
67
3.29k
        case TExprOpcode::COMPOUND_OR: {
68
6.38k
            for (const auto& child : _children) {
69
6.38k
                if (Status st = child->evaluate_inverted_index(context, segment_num_rows);
70
6.38k
                    !st.ok()) {
71
175
                    LOG(ERROR) << "expr:" << child->expr_name()
72
175
                               << " evaluate_inverted_index error:" << st.to_string();
73
175
                    all_pass = false;
74
175
                    continue;
75
175
                }
76
6.20k
                auto inverted_index_context = context->get_index_context();
77
6.20k
                if (inverted_index_context->has_index_result_for_expr(child.get())) {
78
3.23k
                    const auto* index_result =
79
3.23k
                            inverted_index_context->get_index_result_for_expr(child.get());
80
3.23k
                    if (res.is_empty()) {
81
2.24k
                        res = *index_result;
82
2.24k
                    } else {
83
992
                        res |= *index_result;
84
992
                    }
85
3.24k
                    if (inverted_index_context->get_score_runtime() == nullptr) {
86
3.24k
                        if (res.get_data_bitmap()->cardinality() == segment_num_rows) {
87
353
                            break; // Early exit if result is full
88
353
                        }
89
3.24k
                    }
90
3.23k
                } else {
91
2.97k
                    all_pass = false;
92
2.97k
                }
93
6.20k
            }
94
3.29k
            break;
95
0
        }
96
5.85k
        case TExprOpcode::COMPOUND_AND: {
97
1.51k
            for (const auto& child : _children) {
98
1.51k
                if (Status st = child->evaluate_inverted_index(context, segment_num_rows);
99
1.51k
                    !st.ok()) {
100
33
                    LOG(ERROR) << "expr:" << child->expr_name()
101
33
                               << " evaluate_inverted_index error:" << st.to_string();
102
33
                    all_pass = false;
103
33
                    continue;
104
33
                }
105
1.48k
                if (context->get_index_context()->has_index_result_for_expr(child.get())) {
106
260
                    const auto* index_result =
107
260
                            context->get_index_context()->get_index_result_for_expr(child.get());
108
260
                    if (res.is_empty()) {
109
194
                        res = *index_result;
110
194
                    } else {
111
66
                        res &= *index_result;
112
66
                    }
113
114
260
                    if (res.get_data_bitmap()->isEmpty()) {
115
114
                        break; // Early exit if result is empty
116
114
                    }
117
1.22k
                } else {
118
1.22k
                    all_pass = false;
119
1.22k
                }
120
1.48k
            }
121
804
            break;
122
0
        }
123
1.36k
        case TExprOpcode::COMPOUND_NOT: {
124
1.05k
            const auto& child = _children[0];
125
1.05k
            Status st = child->evaluate_inverted_index(context, segment_num_rows);
126
1.05k
            if (!st.ok()) {
127
36
                LOG(ERROR) << "expr:" << child->expr_name()
128
36
                           << " evaluate_inverted_index error:" << st.to_string();
129
36
                return st;
130
36
            }
131
132
1.01k
            if (context->get_index_context()->has_index_result_for_expr(child.get())) {
133
642
                const auto* index_result =
134
642
                        context->get_index_context()->get_index_result_for_expr(child.get());
135
642
                roaring::Roaring full_result;
136
642
                full_result.addRange(0, segment_num_rows);
137
642
                res = index_result->op_not(&full_result);
138
642
            } else {
139
372
                all_pass = false;
140
372
            }
141
1.01k
            break;
142
1.05k
        }
143
0
        default:
144
0
            return Status::NotSupported(
145
0
                    "Compound operator must be AND, OR, or NOT to execute with inverted index.");
146
5.16k
        }
147
148
5.13k
        if (all_pass && !res.is_empty()) {
149
2.03k
            context->get_index_context()->set_index_result_for_expr(this, res);
150
2.03k
        }
151
5.13k
        return Status::OK();
152
5.16k
    }
153
154
    Status execute_column_impl(VExprContext* context, const Block* block, const Selector* selector,
155
38.3k
                               size_t count, ColumnPtr& result_column) const override {
156
38.3k
        if (fast_execute(context, selector, count, result_column)) {
157
94
            return Status::OK();
158
94
        }
159
38.2k
        if (get_num_children() == 1 || _has_const_child()) {
160
875
            return VectorizedFnCall::execute_column_impl(context, block, selector, count,
161
875
                                                         result_column);
162
875
        }
163
164
37.4k
        ColumnPtr lhs_column;
165
37.4k
        RETURN_IF_ERROR(_children[0]->execute_column(context, block, selector, count, lhs_column));
166
37.4k
        lhs_column = lhs_column->convert_to_full_column_if_const();
167
37.4k
        size_t size = lhs_column->size();
168
169
37.4k
        bool lhs_is_nullable = lhs_column->is_nullable();
170
37.4k
        auto [lhs_data_column, lhs_null_map] =
171
37.4k
                _get_raw_data_and_null_map(lhs_column, lhs_is_nullable);
172
37.4k
        size_t filted = simd::count_zero_num((int8_t*)lhs_data_column, size);
173
37.4k
        bool lhs_all_true = (filted == 0);
174
37.4k
        bool lhs_all_false = (filted == size);
175
176
37.4k
        bool lhs_all_is_not_null = false;
177
37.4k
        if (lhs_is_nullable) {
178
24.6k
            filted = simd::count_zero_num((int8_t*)lhs_null_map, size);
179
24.6k
            lhs_all_is_not_null = (filted == size);
180
24.6k
        }
181
182
37.4k
        ColumnPtr rhs_column = nullptr;
183
37.4k
        const uint8_t* __restrict rhs_data_column = nullptr;
184
37.4k
        const uint8_t* __restrict rhs_null_map = nullptr;
185
37.4k
        bool rhs_is_nullable = false;
186
37.4k
        bool rhs_all_true = false;
187
37.4k
        bool rhs_all_false = false;
188
37.4k
        bool rhs_all_is_not_null = false;
189
37.4k
        bool result_is_nullable = _data_type->is_nullable();
190
191
37.4k
        auto get_rhs_colum = [&]() {
192
29.3k
            if (!rhs_column) {
193
29.3k
                RETURN_IF_ERROR(
194
29.3k
                        _children[1]->execute_column(context, block, selector, count, rhs_column));
195
29.3k
                rhs_column = rhs_column->convert_to_full_column_if_const();
196
29.3k
                rhs_is_nullable = rhs_column->is_nullable();
197
29.3k
                auto rhs_nullable_column = _get_raw_data_and_null_map(rhs_column, rhs_is_nullable);
198
29.3k
                rhs_data_column = rhs_nullable_column.first;
199
29.3k
                rhs_null_map = rhs_nullable_column.second;
200
29.3k
                size_t filted = simd::count_zero_num((int8_t*)rhs_data_column, size);
201
29.3k
                rhs_all_true = (filted == 0);
202
29.3k
                rhs_all_false = (filted == size);
203
29.3k
                if (rhs_is_nullable) {
204
23.5k
                    filted = simd::count_zero_num((int8_t*)rhs_null_map, size);
205
23.5k
                    rhs_all_is_not_null = (filted == size);
206
23.5k
                }
207
29.3k
            }
208
29.3k
            return Status::OK();
209
29.3k
        };
210
211
37.4k
        auto return_result_column_id = [&](ColumnPtr& arg_column) {
212
33.3k
            result_column = std::move(*arg_column).mutate();
213
33.3k
            if (result_is_nullable && !result_column->is_nullable()) {
214
3.05k
                result_column = make_nullable(result_column);
215
3.05k
            }
216
33.3k
        };
217
218
37.4k
        auto create_null_map_column = [&](ColumnPtr& null_map_column,
219
37.4k
                                          const uint8_t* __restrict null_map_data) {
220
6.84k
            if (null_map_data == nullptr) {
221
707
                null_map_column = ColumnUInt8::create(size, 0);
222
707
                null_map_data =
223
707
                        assert_cast<const ColumnUInt8*>(null_map_column.get())->get_data().data();
224
707
            }
225
6.84k
            return null_map_data;
226
6.84k
        };
227
228
37.4k
        auto vector_vector = [&]<bool is_and_op>() {
229
621
            MutableColumnPtr mutable_result_column;
230
621
            uint8_t* __restrict result_data_column = nullptr;
231
621
            const uint8_t* __restrict other_data_column = rhs_data_column;
232
621
            if (lhs_column->use_count() == 1) {
233
615
                mutable_result_column = IColumn::mutate(std::move(lhs_column));
234
615
                result_data_column =
235
615
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
236
615
            } 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
621
            do_not_null_pred<is_and_op>(result_data_column, other_data_column, size);
248
621
            result_column = std::move(mutable_result_column);
249
621
        };
_ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE_clILb1EEEDav
Line
Count
Source
228
493
        auto vector_vector = [&]<bool is_and_op>() {
229
493
            MutableColumnPtr mutable_result_column;
230
493
            uint8_t* __restrict result_data_column = nullptr;
231
493
            const uint8_t* __restrict other_data_column = rhs_data_column;
232
493
            if (lhs_column->use_count() == 1) {
233
493
                mutable_result_column = IColumn::mutate(std::move(lhs_column));
234
493
                result_data_column =
235
493
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
236
493
            } 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
493
            do_not_null_pred<is_and_op>(result_data_column, other_data_column, size);
248
493
            result_column = std::move(mutable_result_column);
249
493
        };
_ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE_clILb0EEEDav
Line
Count
Source
228
128
        auto vector_vector = [&]<bool is_and_op>() {
229
128
            MutableColumnPtr mutable_result_column;
230
128
            uint8_t* __restrict result_data_column = nullptr;
231
128
            const uint8_t* __restrict other_data_column = rhs_data_column;
232
128
            if (lhs_column->use_count() == 1) {
233
122
                mutable_result_column = IColumn::mutate(std::move(lhs_column));
234
122
                result_data_column =
235
122
                        assert_cast<ColumnUInt8*>(mutable_result_column.get())->get_data().data();
236
122
            } 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
128
            do_not_null_pred<is_and_op>(result_data_column, other_data_column, size);
248
128
            result_column = std::move(mutable_result_column);
249
128
        };
250
37.4k
        auto vector_vector_null = [&]<bool is_and_op>() {
251
3.42k
            auto col_res = ColumnUInt8::create(size);
252
3.42k
            auto col_nulls = ColumnUInt8::create(size);
253
254
3.42k
            auto* __restrict res_datas = col_res->get_data().data();
255
3.42k
            auto* __restrict res_nulls = col_nulls->get_data().data();
256
3.42k
            ColumnPtr temp_null_map = nullptr;
257
            // maybe both children are nullable / or one of children is nullable
258
3.42k
            auto* __restrict lhs_null_map_tmp = create_null_map_column(temp_null_map, lhs_null_map);
259
3.42k
            auto* __restrict rhs_null_map_tmp = create_null_map_column(temp_null_map, rhs_null_map);
260
3.42k
            auto* __restrict lhs_data_column_tmp = lhs_data_column;
261
3.42k
            auto* __restrict rhs_data_column_tmp = rhs_data_column;
262
263
3.42k
            do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, rhs_data_column_tmp,
264
3.42k
                                    rhs_null_map_tmp, res_datas, res_nulls, size);
265
266
3.42k
            result_column = ColumnNullable::create(std::move(col_res), std::move(col_nulls));
267
3.42k
        };
_ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE0_clILb1EEEDav
Line
Count
Source
250
1.43k
        auto vector_vector_null = [&]<bool is_and_op>() {
251
1.43k
            auto col_res = ColumnUInt8::create(size);
252
1.43k
            auto col_nulls = ColumnUInt8::create(size);
253
254
1.43k
            auto* __restrict res_datas = col_res->get_data().data();
255
1.43k
            auto* __restrict res_nulls = col_nulls->get_data().data();
256
1.43k
            ColumnPtr temp_null_map = nullptr;
257
            // maybe both children are nullable / or one of children is nullable
258
1.43k
            auto* __restrict lhs_null_map_tmp = create_null_map_column(temp_null_map, lhs_null_map);
259
1.43k
            auto* __restrict rhs_null_map_tmp = create_null_map_column(temp_null_map, rhs_null_map);
260
1.43k
            auto* __restrict lhs_data_column_tmp = lhs_data_column;
261
1.43k
            auto* __restrict rhs_data_column_tmp = rhs_data_column;
262
263
1.43k
            do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, rhs_data_column_tmp,
264
1.43k
                                    rhs_null_map_tmp, res_datas, res_nulls, size);
265
266
1.43k
            result_column = ColumnNullable::create(std::move(col_res), std::move(col_nulls));
267
1.43k
        };
_ZZNK5doris13VCompoundPred19execute_column_implEPNS_12VExprContextEPKNS_5BlockEPKNS_8PODArrayIjLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEmRNS_3COWINS_7IColumnEE13immutable_ptrISE_EEENKUlTnbvE0_clILb0EEEDav
Line
Count
Source
250
1.99k
        auto vector_vector_null = [&]<bool is_and_op>() {
251
1.99k
            auto col_res = ColumnUInt8::create(size);
252
1.99k
            auto col_nulls = ColumnUInt8::create(size);
253
254
1.99k
            auto* __restrict res_datas = col_res->get_data().data();
255
1.99k
            auto* __restrict res_nulls = col_nulls->get_data().data();
256
1.99k
            ColumnPtr temp_null_map = nullptr;
257
            // maybe both children are nullable / or one of children is nullable
258
1.99k
            auto* __restrict lhs_null_map_tmp = create_null_map_column(temp_null_map, lhs_null_map);
259
1.99k
            auto* __restrict rhs_null_map_tmp = create_null_map_column(temp_null_map, rhs_null_map);
260
1.99k
            auto* __restrict lhs_data_column_tmp = lhs_data_column;
261
1.99k
            auto* __restrict rhs_data_column_tmp = rhs_data_column;
262
263
1.99k
            do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, rhs_data_column_tmp,
264
1.99k
                                    rhs_null_map_tmp, res_datas, res_nulls, size);
265
266
1.99k
            result_column = ColumnNullable::create(std::move(col_res), std::move(col_nulls));
267
1.99k
        };
268
269
        // false and NULL ----> 0
270
        // true  and NULL ----> NULL
271
37.4k
        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
7.69k
            if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
275
                // false and any = false, return lhs
276
3.95k
                return_result_column_id(lhs_column);
277
3.95k
            } else {
278
3.73k
                RETURN_IF_ERROR(get_rhs_colum());
279
280
3.73k
                if ((lhs_all_true && !lhs_is_nullable) ||    //not null column
281
3.73k
                    (lhs_all_true && lhs_all_is_not_null)) { //nullable column
282
                                                             // true and any = any, return rhs
283
284
686
                    return_result_column_id(rhs_column);
285
3.05k
                } else if ((rhs_all_false && !rhs_is_nullable) ||
286
3.05k
                           (rhs_all_false && rhs_all_is_not_null)) {
287
                    // any and false = false, return rhs
288
229
                    return_result_column_id(rhs_column);
289
2.82k
                } else if ((rhs_all_true && !rhs_is_nullable) ||
290
2.82k
                           (rhs_all_true && rhs_all_is_not_null)) {
291
                    // any and true = any, return lhs
292
900
                    return_result_column_id(lhs_column);
293
1.92k
                } else {
294
1.92k
                    if (!result_is_nullable) {
295
493
                        vector_vector.template operator()<true>();
296
1.43k
                    } else {
297
1.43k
                        vector_vector_null.template operator()<true>();
298
1.43k
                    }
299
1.92k
                }
300
3.73k
            }
301
29.7k
        } else if (_op == TExprOpcode::COMPOUND_OR) {
302
            // true  or NULL ----> 1
303
            // false or NULL ----> NULL
304
29.7k
            if ((lhs_all_true && !lhs_is_nullable) || (lhs_all_true && lhs_all_is_not_null)) {
305
                // true or any = true, return lhs
306
4.11k
                return_result_column_id(lhs_column);
307
25.6k
            } else {
308
25.6k
                RETURN_IF_ERROR(get_rhs_colum());
309
25.6k
                if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
310
                    // false or any = any, return rhs
311
21.6k
                    return_result_column_id(rhs_column);
312
21.6k
                } else if ((rhs_all_true && !rhs_is_nullable) ||
313
3.95k
                           (rhs_all_true && rhs_all_is_not_null)) {
314
                    // any or true = true, return rhs
315
733
                    return_result_column_id(rhs_column);
316
3.21k
                } else if ((rhs_all_false && !rhs_is_nullable) ||
317
3.21k
                           (rhs_all_false && rhs_all_is_not_null)) {
318
                    // any or false = any, return lhs
319
1.09k
                    return_result_column_id(lhs_column);
320
2.11k
                } else {
321
2.11k
                    if (!result_is_nullable) {
322
128
                        vector_vector.template operator()<false>();
323
1.99k
                    } else {
324
1.99k
                        vector_vector_null.template operator()<false>();
325
1.99k
                    }
326
2.11k
                }
327
25.6k
            }
328
29.7k
        } else {
329
1
            return Status::InternalError("Compound operator must be AND or OR.");
330
1
        }
331
332
37.4k
        DCHECK_EQ(result_column->size(), count);
333
37.4k
        return Status::OK();
334
37.4k
    }
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
161k
    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
161k
        return (l_null & r_null) | (r_null & (l_null ^ a)) | (l_null & (r_null ^ b));
348
161k
    }
349
525k
    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
525k
        return (l_null & r_null) | (r_null & (r_null ^ a)) | (l_null & (l_null ^ b));
352
525k
    }
353
354
    template <bool is_and>
355
    void static do_not_null_pred(uint8_t* __restrict lhs, const uint8_t* __restrict rhs,
356
621
                                 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.1k
        for (size_t i = 0; i < size; ++i) {
365
69.5k
            if constexpr (is_and) {
366
65.8k
                lhs[i] &= rhs[i];
367
65.8k
            } else {
368
3.71k
                lhs[i] |= rhs[i];
369
3.71k
            }
370
69.5k
        }
371
621
    }
_ZN5doris13VCompoundPred16do_not_null_predILb1EEEvPhPKhm
Line
Count
Source
356
493
                                 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.3k
        for (size_t i = 0; i < size; ++i) {
365
65.8k
            if constexpr (is_and) {
366
65.8k
                lhs[i] &= rhs[i];
367
            } else {
368
                lhs[i] |= rhs[i];
369
            }
370
65.8k
        }
371
493
    }
_ZN5doris13VCompoundPred16do_not_null_predILb0EEEvPhPKhm
Line
Count
Source
356
128
                                 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
3.84k
        for (size_t i = 0; i < size; ++i) {
365
            if constexpr (is_and) {
366
                lhs[i] &= rhs[i];
367
3.71k
            } else {
368
3.71k
                lhs[i] |= rhs[i];
369
3.71k
            }
370
3.71k
        }
371
128
    }
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
3.42k
                             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
690k
        for (size_t i = 0; i < size; ++i) {
386
686k
            if constexpr (is_and) {
387
161k
                res_null[i] = apply_and_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
388
161k
                res_data[i] = lhs_data[i] & rhs_data[i];
389
525k
            } else {
390
525k
                res_null[i] = apply_or_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
391
525k
                res_data[i] = lhs_data[i] | rhs_data[i];
392
525k
            }
393
686k
        }
394
3.42k
    }
_ZN5doris13VCompoundPred12do_null_predILb1EEEvPKhS3_S3_S3_PhS4_m
Line
Count
Source
377
1.43k
                             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
162k
        for (size_t i = 0; i < size; ++i) {
386
161k
            if constexpr (is_and) {
387
161k
                res_null[i] = apply_and_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
388
161k
                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
161k
        }
394
1.43k
    }
_ZN5doris13VCompoundPred12do_null_predILb0EEEvPKhS3_S3_S3_PhS4_m
Line
Count
Source
377
1.99k
                             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
525k
            } else {
390
525k
                res_null[i] = apply_or_null(lhs_data[i], lhs_null[i], rhs_data[i], rhs_null[i]);
391
525k
                res_data[i] = lhs_data[i] | rhs_data[i];
392
525k
            }
393
525k
        }
394
1.99k
    }
395
396
37.4k
    bool _has_const_child() const {
397
37.4k
        return std::ranges::any_of(_children,
398
74.8k
                                   [](const VExprSPtr& arg) -> bool { return arg->is_constant(); });
399
37.4k
    }
400
401
    std::pair<const uint8_t*, const uint8_t*> _get_raw_data_and_null_map(
402
66.7k
            const ColumnPtr& column, bool has_nullable_column) const {
403
66.7k
        if (has_nullable_column) {
404
48.1k
            const auto* nullable_column = assert_cast<const ColumnNullable*>(column.get());
405
48.1k
            auto* data_column =
406
48.1k
                    assert_cast<const ColumnUInt8*>(nullable_column->get_nested_column_ptr().get())
407
48.1k
                            ->get_data()
408
48.1k
                            .data();
409
48.1k
            auto* null_map = assert_cast<const ColumnUInt8*>(
410
48.1k
                                     nullable_column->get_null_map_column_ptr().get())
411
48.1k
                                     ->get_data()
412
48.1k
                                     .data();
413
48.1k
            return std::make_pair(data_column, null_map);
414
48.1k
        } else {
415
18.6k
            auto* data_column = assert_cast<const ColumnUInt8*>(column.get())->get_data().data();
416
18.6k
            return std::make_pair(data_column, nullptr);
417
18.6k
        }
418
66.7k
    }
419
420
    TExprOpcode::type _op;
421
};
422
423
} // namespace doris