Coverage Report

Created: 2026-03-13 12:42

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