Coverage Report

Created: 2026-06-04 15:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/vcondition_expr.cpp
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
#include "exprs/vcondition_expr.h"
19
20
#include <glog/logging.h>
21
22
#include "core/column/column.h"
23
#include "core/column/column_const.h"
24
#include "exprs/function_context.h"
25
#include "util/simd/bits.h"
26
27
namespace doris {
28
29
Status VConditionExpr::prepare(RuntimeState* state, const RowDescriptor& desc,
30
865
                               VExprContext* context) {
31
865
    RETURN_IF_ERROR_OR_PREPARED(VExpr::prepare(state, desc, context));
32
865
    _prepare_finished = true;
33
865
    return Status::OK();
34
865
}
35
36
Status VConditionExpr::open(RuntimeState* state, VExprContext* context,
37
4.14k
                            FunctionContext::FunctionStateScope scope) {
38
4.14k
    DCHECK(_prepare_finished);
39
4.14k
    RETURN_IF_ERROR(VExpr::open(state, context, scope));
40
4.14k
    _open_finished = true;
41
4.14k
    return Status::OK();
42
4.14k
}
43
44
4.15k
void VConditionExpr::close(VExprContext* context, FunctionContext::FunctionStateScope scope) {
45
4.15k
    DCHECK(_prepare_finished);
46
4.15k
    VExpr::close(context, scope);
47
4.15k
}
48
49
0
std::string VConditionExpr::debug_string() const {
50
0
    std::string result = expr_name() + "(";
51
0
    for (size_t i = 0; i < _children.size(); ++i) {
52
0
        if (i != 0) {
53
0
            result += ", ";
54
0
        }
55
0
        result += _children[i]->debug_string();
56
0
    }
57
0
    result += ")";
58
0
    return result;
59
0
}
60
61
3.34k
size_t VConditionExpr::count_true_with_notnull(const ColumnPtr& col) {
62
3.34k
    if (col->only_null()) {
63
26
        return 0;
64
26
    }
65
66
3.32k
    if (const auto* const_col = check_and_get_column<ColumnConst>(col.get())) {
67
        // if is null , get_bool will return false
68
        // bool get_bool(size_t n) const override {
69
        //     return is_null_at(n) ? false : _nested_column->get_bool(n);
70
        // }
71
87
        bool is_true = const_col->get_bool(0);
72
87
        return is_true ? col->size() : 0;
73
87
    }
74
75
3.23k
    auto count = col->size();
76
3.23k
    if (col->is_nullable()) {
77
2.18k
        const auto* nullable = assert_cast<const ColumnNullable*>(col.get());
78
2.18k
        const auto* __restrict null_data = nullable->get_null_map_data().data();
79
2.18k
        const auto* __restrict bool_data =
80
2.18k
                ((const ColumnUInt8&)(nullable->get_nested_column())).get_data().data();
81
82
2.18k
        size_t null_count = count - simd::count_zero_num((const int8_t*)null_data, count);
83
84
2.18k
        if (null_count == count) {
85
0
            return 0;
86
2.18k
        } else if (null_count == 0) {
87
2.13k
            size_t true_count = count - simd::count_zero_num((const int8_t*)bool_data, count);
88
2.13k
            return true_count;
89
2.13k
        } else {
90
            // In fact, the null_count maybe is different with true_count, but it's no impact
91
49
            return null_count;
92
49
        }
93
2.18k
    } else {
94
1.05k
        const auto* bool_col = assert_cast<const ColumnUInt8*>(col.get());
95
1.05k
        const auto* __restrict bool_data = bool_col->get_data().data();
96
1.05k
        return count - simd::count_zero_num((const int8_t*)bool_data, count);
97
1.05k
    }
98
3.23k
}
99
100
1.01k
ColumnPtr materialize_column_if_const(const ColumnPtr& column) {
101
1.01k
    return column->convert_to_full_column_if_const();
102
1.01k
}
103
104
0
ColumnPtr make_nullable_column_if_not(const ColumnPtr& column) {
105
0
    if (is_column_nullable(*column)) return column;
106
107
0
    return ColumnNullable::create(materialize_column_if_const(column),
108
0
                                  ColumnUInt8::create(column->size(), 0));
109
0
}
110
111
132
ColumnPtr get_nested_column(const ColumnPtr& column) {
112
132
    if (auto* nullable = check_and_get_column<ColumnNullable>(*column))
113
70
        return nullable->get_nested_column_ptr();
114
62
    else if (const auto* column_const = check_and_get_column<ColumnConst>(*column))
115
28
        return ColumnConst::create(get_nested_column(column_const->get_data_column_ptr()),
116
28
                                   column->size());
117
118
34
    return column;
119
132
}
120
121
Status VectorizedIfExpr::execute_generic(Block& block, const ColumnUInt8* cond_col,
122
                                         const ColumnWithTypeAndName& then_col_type_name,
123
                                         const ColumnWithTypeAndName& else_col_type_name,
124
194
                                         uint32_t result, size_t input_row_count) const {
125
194
    MutableColumnPtr result_column = block.get_by_position(result).type->create_column();
126
194
    result_column->reserve(input_row_count);
127
128
194
    const IColumn& then_col = *then_col_type_name.column;
129
194
    const IColumn& else_col = *else_col_type_name.column;
130
194
    bool then_is_const = is_column_const(then_col);
131
194
    bool else_is_const = is_column_const(else_col);
132
133
194
    const auto& cond_array = cond_col->get_data();
134
135
194
    if (then_is_const && else_is_const) {
136
27
        const IColumn& then_nested_column =
137
27
                assert_cast<const ColumnConst&>(then_col).get_data_column();
138
27
        const IColumn& else_nested_column =
139
27
                assert_cast<const ColumnConst&>(else_col).get_data_column();
140
134
        for (size_t i = 0; i < input_row_count; i++) {
141
107
            if (cond_array[i])
142
48
                result_column->insert_from(then_nested_column, 0);
143
59
            else
144
59
                result_column->insert_from(else_nested_column, 0);
145
107
        }
146
167
    } else if (then_is_const) {
147
152
        const IColumn& then_nested_column =
148
152
                assert_cast<const ColumnConst&>(then_col).get_data_column();
149
150
417
        for (size_t i = 0; i < input_row_count; i++) {
151
265
            if (cond_array[i])
152
53
                result_column->insert_from(then_nested_column, 0);
153
212
            else
154
212
                result_column->insert_from(else_col, i);
155
265
        }
156
152
    } else if (else_is_const) {
157
0
        const IColumn& else_nested_column =
158
0
                assert_cast<const ColumnConst&>(else_col).get_data_column();
159
160
0
        for (size_t i = 0; i < input_row_count; i++) {
161
0
            if (cond_array[i])
162
0
                result_column->insert_from(then_col, i);
163
0
            else
164
0
                result_column->insert_from(else_nested_column, 0);
165
0
        }
166
15
    } else {
167
69
        for (size_t i = 0; i < input_row_count; i++) {
168
54
            result_column->insert_from(cond_array[i] ? then_col : else_col, i);
169
54
        }
170
15
    }
171
194
    block.replace_by_position(result, std::move(result_column));
172
194
    return Status::OK();
173
194
}
174
175
Status VectorizedIfExpr::execute_for_null_then_else(Block& block,
176
                                                    const ColumnWithTypeAndName& arg_cond,
177
                                                    const ColumnWithTypeAndName& arg_then,
178
                                                    const ColumnWithTypeAndName& arg_else,
179
                                                    uint32_t result, size_t input_rows_count,
180
736
                                                    bool& handled) const {
181
736
    bool then_is_null = arg_then.column->only_null();
182
736
    bool else_is_null = arg_else.column->only_null();
183
184
736
    handled = false;
185
736
    if (!then_is_null && !else_is_null) {
186
696
        return Status::OK();
187
696
    }
188
189
40
    if (then_is_null && else_is_null) {
190
0
        block.get_by_position(result).column =
191
0
                block.get_by_position(result).type->create_column_const_with_default_value(
192
0
                        input_rows_count);
193
0
        handled = true;
194
0
        return Status::OK();
195
0
    }
196
197
40
    const auto* cond_col = check_and_get_column<ColumnUInt8>(arg_cond.column.get());
198
40
    const ColumnConst* cond_const_col =
199
40
            check_and_get_column_const<ColumnUInt8>(arg_cond.column.get());
200
201
    /// If then is NULL, we create Nullable column with null mask OR-ed with condition.
202
40
    if (then_is_null) {
203
4
        if (cond_col) {
204
4
            if (is_column_nullable(*arg_else.column)) { // if(cond, null, nullable)
205
4
                auto arg_else_column = arg_else.column;
206
4
                auto result_column = (*std::move(arg_else_column)).mutate();
207
4
                assert_cast<ColumnNullable&>(*result_column)
208
4
                        .apply_null_map(assert_cast<const ColumnUInt8&>(*arg_cond.column));
209
4
                block.replace_by_position(result, std::move(result_column));
210
4
            } else { // if(cond, null, not_nullable)
211
0
                block.replace_by_position(
212
0
                        result, ColumnNullable::create(materialize_column_if_const(arg_else.column),
213
0
                                                       arg_cond.column));
214
0
            }
215
4
        } else if (cond_const_col) {
216
0
            if (cond_const_col->get_value<TYPE_BOOLEAN>()) { // if(true, null, else)
217
0
                block.get_by_position(result).column =
218
0
                        block.get_by_position(result).type->create_column()->clone_resized(
219
0
                                input_rows_count);
220
0
            } else { // if(false, null, else)
221
0
                block.get_by_position(result).column = make_nullable_column_if_not(arg_else.column);
222
0
            }
223
0
        } else {
224
0
            return Status::InternalError(
225
0
                    "Illegal column {} of first argument of function {}. Must be ColumnUInt8 "
226
0
                    "or ColumnConstUInt8.",
227
0
                    arg_cond.column->get_name(), expr_name());
228
0
        }
229
36
    } else { /// If else is NULL, we create Nullable column with null mask OR-ed with negated condition.
230
36
        if (cond_col) {
231
36
            size_t size = input_rows_count;
232
233
36
            if (is_column_nullable(*arg_then.column)) { // if(cond, nullable, NULL)
234
36
                auto arg_then_column = arg_then.column;
235
36
                auto result_column = (*std::move(arg_then_column)).mutate();
236
36
                assert_cast<ColumnNullable&>(*result_column)
237
36
                        .apply_negated_null_map(assert_cast<const ColumnUInt8&>(*arg_cond.column));
238
36
                block.replace_by_position(result, std::move(result_column));
239
36
            } else { // if(cond, not_nullable, NULL)
240
0
                const auto& null_map_data = cond_col->get_data();
241
0
                auto negated_null_map = ColumnUInt8::create();
242
0
                auto& negated_null_map_data = negated_null_map->get_data();
243
0
                negated_null_map_data.resize(size);
244
245
0
                for (size_t i = 0; i < size; ++i) {
246
0
                    negated_null_map_data[i] = !null_map_data[i];
247
0
                }
248
249
0
                block.replace_by_position(
250
0
                        result, ColumnNullable::create(materialize_column_if_const(arg_then.column),
251
0
                                                       std::move(negated_null_map)));
252
0
            }
253
36
        } else if (cond_const_col) {
254
0
            if (cond_const_col->get_value<TYPE_BOOLEAN>()) { // if(true, then, NULL)
255
0
                block.get_by_position(result).column = make_nullable_column_if_not(arg_then.column);
256
0
            } else { // if(false, then, NULL)
257
0
                block.get_by_position(result).column =
258
0
                        block.get_by_position(result).type->create_column()->clone_resized(
259
0
                                input_rows_count);
260
0
            }
261
0
        } else {
262
0
            return Status::InternalError(
263
0
                    "Illegal column {} of first argument of function {}. Must be ColumnUInt8 "
264
0
                    "or ColumnConstUInt8.",
265
0
                    arg_cond.column->get_name(), expr_name());
266
0
        }
267
36
    }
268
40
    handled = true;
269
40
    return Status::OK();
270
40
}
271
272
Status VectorizedIfExpr::execute_for_nullable_then_else(Block& block,
273
                                                        const ColumnWithTypeAndName& arg_cond,
274
                                                        const ColumnWithTypeAndName& arg_then,
275
                                                        const ColumnWithTypeAndName& arg_else,
276
                                                        uint32_t result, size_t input_rows_count,
277
695
                                                        bool& handled) const {
278
695
    auto then_type_is_nullable = arg_then.type->is_nullable();
279
695
    auto else_type_is_nullable = arg_else.type->is_nullable();
280
695
    handled = false;
281
695
    if (!then_type_is_nullable && !else_type_is_nullable) {
282
644
        return Status::OK();
283
644
    }
284
285
51
    const auto* then_is_nullable = check_and_get_column<ColumnNullable>(*arg_then.column);
286
51
    const auto* else_is_nullable = check_and_get_column<ColumnNullable>(*arg_else.column);
287
51
    bool then_column_is_const_nullable = false;
288
51
    bool else_column_is_const_nullable = false;
289
51
    if (then_type_is_nullable && then_is_nullable == nullptr) {
290
        //this case is a const(nullable column)
291
0
        const auto& const_column = assert_cast<const ColumnConst&>(*arg_then.column);
292
0
        then_is_nullable =
293
0
                assert_cast<const ColumnNullable*>(const_column.get_data_column_ptr().get());
294
0
        then_column_is_const_nullable = true;
295
0
    }
296
297
51
    if (else_type_is_nullable && else_is_nullable == nullptr) {
298
        //this case is a const(nullable column)
299
0
        const auto& const_column = assert_cast<const ColumnConst&>(*arg_else.column);
300
0
        else_is_nullable =
301
0
                assert_cast<const ColumnNullable*>(const_column.get_data_column_ptr().get());
302
0
        else_column_is_const_nullable = true;
303
0
    }
304
305
    /** Calculate null mask of result and nested column separately.
306
      */
307
51
    ColumnPtr result_null_mask;
308
51
    {
309
        // get null map from column:
310
        // a. get_null_map_column_ptr() : it's a real nullable column, so could get it from nullable column
311
        // b. create a const_nullmap_column: it's a not nullable column or a const nullable column, contain a const value
312
51
        Block temporary_block;
313
51
        temporary_block.insert(arg_cond);
314
51
        ColumnPtr then_nested_null_map;
315
51
        if (then_type_is_nullable && !then_column_is_const_nullable) {
316
38
            then_nested_null_map = then_is_nullable->get_null_map_column_ptr();
317
38
        } else {
318
13
            then_nested_null_map =
319
13
                    DataTypeUInt8().create_column_const_with_default_value(input_rows_count);
320
13
        }
321
51
        temporary_block.insert(
322
51
                {then_nested_null_map, std::make_shared<DataTypeUInt8>(), "then_column_null_map"});
323
324
51
        ColumnPtr else_nested_null_map;
325
51
        if (else_type_is_nullable && !else_column_is_const_nullable) {
326
32
            else_nested_null_map = else_is_nullable->get_null_map_column_ptr();
327
32
        } else {
328
19
            else_nested_null_map =
329
19
                    DataTypeUInt8().create_column_const_with_default_value(input_rows_count);
330
19
        }
331
51
        temporary_block.insert(
332
51
                {else_nested_null_map, std::make_shared<DataTypeUInt8>(), "else_column_null_map"});
333
51
        temporary_block.insert(
334
51
                {nullptr, std::make_shared<DataTypeUInt8>(), "result_column_null_map"});
335
336
51
        RETURN_IF_ERROR(
337
51
                _execute_impl_internal(temporary_block, {0, 1, 2}, 3, temporary_block.rows()));
338
339
51
        result_null_mask = temporary_block.get_by_position(3).column;
340
51
    }
341
342
0
    ColumnPtr result_nested_column;
343
344
51
    {
345
51
        Block temporary_block(
346
51
                {arg_cond,
347
51
                 {get_nested_column(arg_then.column), remove_nullable(arg_then.type), ""},
348
51
                 {get_nested_column(arg_else.column), remove_nullable(arg_else.type), ""},
349
51
                 {nullptr, remove_nullable(block.get_by_position(result).type), ""}});
350
351
51
        RETURN_IF_ERROR(
352
51
                _execute_impl_internal(temporary_block, {0, 1, 2}, 3, temporary_block.rows()));
353
354
51
        result_nested_column = temporary_block.get_by_position(3).column;
355
51
    }
356
357
0
    auto column = ColumnNullable::create(materialize_column_if_const(result_nested_column),
358
51
                                         materialize_column_if_const(result_null_mask));
359
51
    block.replace_by_position(result, std::move(column));
360
51
    handled = true;
361
51
    return Status::OK();
362
51
}
363
364
Status VectorizedIfExpr::execute_for_null_condition(Block& block, const ColumnNumbers& arguments,
365
                                                    const ColumnWithTypeAndName& arg_cond,
366
                                                    const ColumnWithTypeAndName& arg_then,
367
                                                    const ColumnWithTypeAndName& arg_else,
368
912
                                                    uint32_t result, bool& handled) const {
369
912
    bool cond_is_null = arg_cond.column->only_null();
370
912
    handled = false;
371
372
912
    if (cond_is_null) {
373
0
        block.replace_by_position(result, arg_else.column->clone_resized(arg_cond.column->size()));
374
0
        handled = true;
375
0
        return Status::OK();
376
0
    }
377
378
912
    if (const auto* nullable = check_and_get_column<ColumnNullable>(*arg_cond.column)) {
379
176
        DCHECK(remove_nullable(arg_cond.type)->get_primitive_type() == PrimitiveType::TYPE_BOOLEAN);
380
381
        // update nested column by null map
382
176
        const auto* __restrict null_map = nullable->get_null_map_data().data();
383
176
        auto* __restrict nested_bool_data =
384
176
                ((ColumnUInt8&)(nullable->get_nested_column())).get_data().data();
385
176
        auto rows = nullable->size();
386
17.0k
        for (size_t i = 0; i < rows; i++) {
387
16.8k
            nested_bool_data[i] &= !null_map[i];
388
16.8k
        }
389
176
        auto column_size = block.columns();
390
176
        block.insert(
391
176
                {nullable->get_nested_column_ptr(), remove_nullable(arg_cond.type), arg_cond.name});
392
393
176
        handled = true;
394
176
        return _execute_impl_internal(block, {column_size, arguments[1], arguments[2]}, result,
395
176
                                      rows);
396
176
    }
397
736
    return Status::OK();
398
912
}
399
400
Status VectorizedIfExpr::_execute_impl_internal(Block& block, const ColumnNumbers& arguments,
401
912
                                                uint32_t result, size_t input_rows_count) const {
402
912
    const ColumnWithTypeAndName& arg_then = block.get_by_position(arguments[1]);
403
912
    const ColumnWithTypeAndName& arg_else = block.get_by_position(arguments[2]);
404
912
    ColumnWithTypeAndName& cond_column = block.get_by_position(arguments[0]);
405
912
    cond_column.column = materialize_column_if_const(cond_column.column);
406
912
    const ColumnWithTypeAndName& arg_cond = block.get_by_position(arguments[0]);
407
408
912
    Status ret = Status::OK();
409
912
    bool handled = false;
410
912
    RETURN_IF_ERROR(execute_for_null_condition(block, arguments, arg_cond, arg_then, arg_else,
411
912
                                               result, handled));
412
413
912
    if (!handled) {
414
736
        RETURN_IF_ERROR(execute_for_null_then_else(block, arg_cond, arg_then, arg_else, result,
415
736
                                                   input_rows_count, handled));
416
736
    }
417
418
912
    if (!handled) {
419
696
        RETURN_IF_ERROR(execute_for_nullable_then_else(block, arg_cond, arg_then, arg_else, result,
420
696
                                                       input_rows_count, handled));
421
696
    }
422
423
912
    if (handled) {
424
268
        return Status::OK();
425
268
    }
426
427
644
    const auto* cond_col = assert_cast<const ColumnUInt8*>(arg_cond.column.get());
428
644
    const ColumnConst* cond_const_col =
429
644
            check_and_get_column_const<ColumnUInt8>(arg_cond.column.get());
430
431
644
    if (cond_const_col) {
432
0
        block.get_by_position(result).column =
433
0
                cond_const_col->get_value<TYPE_BOOLEAN>() ? arg_then.column : arg_else.column;
434
0
        return Status::OK();
435
0
    }
436
437
644
    Status vec_exec;
438
439
644
    auto call = [&](const auto& type) -> bool {
440
450
        using DataType = std::decay_t<decltype(type)>;
441
450
        vec_exec = execute_basic_type<DataType::PType>(block, cond_col, arg_then, arg_else, result,
442
450
                                                       vec_exec);
443
450
        return true;
444
450
    };
vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE2EEEEEbRKT_
Line
Count
Source
439
109
    auto call = [&](const auto& type) -> bool {
440
109
        using DataType = std::decay_t<decltype(type)>;
441
109
        vec_exec = execute_basic_type<DataType::PType>(block, cond_col, arg_then, arg_else, result,
442
109
                                                       vec_exec);
443
109
        return true;
444
109
    };
vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE3EEEEEbRKT_
Line
Count
Source
439
230
    auto call = [&](const auto& type) -> bool {
440
230
        using DataType = std::decay_t<decltype(type)>;
441
230
        vec_exec = execute_basic_type<DataType::PType>(block, cond_col, arg_then, arg_else, result,
442
230
                                                       vec_exec);
443
230
        return true;
444
230
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE4EEEEEbRKT_
vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE5EEEEEbRKT_
Line
Count
Source
439
38
    auto call = [&](const auto& type) -> bool {
440
38
        using DataType = std::decay_t<decltype(type)>;
441
38
        vec_exec = execute_basic_type<DataType::PType>(block, cond_col, arg_then, arg_else, result,
442
38
                                                       vec_exec);
443
38
        return true;
444
38
    };
vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE6EEEEEbRKT_
Line
Count
Source
439
29
    auto call = [&](const auto& type) -> bool {
440
29
        using DataType = std::decay_t<decltype(type)>;
441
29
        vec_exec = execute_basic_type<DataType::PType>(block, cond_col, arg_then, arg_else, result,
442
29
                                                       vec_exec);
443
29
        return true;
444
29
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE7EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE8EEEEEbRKT_
vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE9EEEEEbRKT_
Line
Count
Source
439
21
    auto call = [&](const auto& type) -> bool {
440
21
        using DataType = std::decay_t<decltype(type)>;
441
21
        vec_exec = execute_basic_type<DataType::PType>(block, cond_col, arg_then, arg_else, result,
442
21
                                                       vec_exec);
443
21
        return true;
444
21
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE28EEEEEbRKT_
vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE29EEEEEbRKT_
Line
Count
Source
439
5
    auto call = [&](const auto& type) -> bool {
440
5
        using DataType = std::decay_t<decltype(type)>;
441
5
        vec_exec = execute_basic_type<DataType::PType>(block, cond_col, arg_then, arg_else, result,
442
5
                                                       vec_exec);
443
5
        return true;
444
5
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE20EEEEEbRKT_
vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE30EEEEEbRKT_
Line
Count
Source
439
13
    auto call = [&](const auto& type) -> bool {
440
13
        using DataType = std::decay_t<decltype(type)>;
441
13
        vec_exec = execute_basic_type<DataType::PType>(block, cond_col, arg_then, arg_else, result,
442
13
                                                       vec_exec);
443
13
        return true;
444
13
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE35EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE11EEEEEbRKT_
vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE25EEEEEbRKT_
Line
Count
Source
439
4
    auto call = [&](const auto& type) -> bool {
440
4
        using DataType = std::decay_t<decltype(type)>;
441
4
        vec_exec = execute_basic_type<DataType::PType>(block, cond_col, arg_then, arg_else, result,
442
4
                                                       vec_exec);
443
4
        return true;
444
4
    };
vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE26EEEEEbRKT_
Line
Count
Source
439
1
    auto call = [&](const auto& type) -> bool {
440
1
        using DataType = std::decay_t<decltype(type)>;
441
1
        vec_exec = execute_basic_type<DataType::PType>(block, cond_col, arg_then, arg_else, result,
442
1
                                                       vec_exec);
443
1
        return true;
444
1
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE12EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE27EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE42EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE36EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZNK5doris16VectorizedIfExpr22_execute_impl_internalERNS_5BlockERKSt6vectorIjSaIjEEjmENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE37EEEEEbRKT_
445
446
644
    auto can_use_vec_exec = dispatch_switch_scalar(arg_then.type->get_primitive_type(), call);
447
644
    if (can_use_vec_exec) {
448
450
        return vec_exec;
449
450
    } else {
450
194
        return execute_generic(block, cond_col, arg_then, arg_else, result, input_rows_count);
451
194
    }
452
644
}
453
454
Status VectorizedIfExpr::execute_column_impl(VExprContext* context, const Block* block,
455
                                             const Selector* selector, size_t count,
456
3.34k
                                             ColumnPtr& result_column) const {
457
18.4E
    DCHECK(_open_finished || block == nullptr) << debug_string();
458
3.34k
    DCHECK_EQ(_children.size(), 3) << "IF expr must have three children";
459
460
3.34k
    ColumnPtr cond_column;
461
3.34k
    RETURN_IF_ERROR(_children[0]->execute_column(context, block, selector, count, cond_column));
462
463
3.34k
    ColumnPtr then_column;
464
3.34k
    ColumnPtr else_column;
465
466
3.34k
    auto true_count = count_true_with_notnull(cond_column);
467
3.34k
    auto item_count = cond_column->size();
468
3.34k
    if (true_count == item_count) {
469
523
        RETURN_IF_ERROR(_children[1]->execute_column(context, block, selector, count, then_column));
470
523
        result_column = _data_type->is_nullable() ? make_nullable(then_column) : then_column;
471
523
        return Status::OK();
472
2.82k
    } else if (true_count == 0) {
473
2.46k
        RETURN_IF_ERROR(_children[2]->execute_column(context, block, selector, count, else_column));
474
2.46k
        result_column = _data_type->is_nullable() ? make_nullable(else_column) : else_column;
475
2.46k
        return Status::OK();
476
2.46k
    }
477
478
358
    RETURN_IF_ERROR(_children[1]->execute_column(context, block, selector, count, then_column));
479
358
    RETURN_IF_ERROR(_children[2]->execute_column(context, block, selector, count, else_column));
480
481
358
    Block temp_block;
482
483
358
    temp_block.insert({cond_column, _children[0]->execute_type(block), _children[0]->expr_name()});
484
358
    temp_block.insert({then_column, _children[1]->execute_type(block), _children[1]->expr_name()});
485
358
    temp_block.insert({else_column, _children[2]->execute_type(block), _children[2]->expr_name()});
486
487
    // prepare a column to save result
488
358
    temp_block.insert({nullptr, _data_type, IF_NAME});
489
358
    RETURN_IF_ERROR(_execute_impl_internal(temp_block, {0, 1, 2}, 3, temp_block.rows()));
490
358
    result_column = temp_block.get_by_position(3).column;
491
358
    DCHECK_EQ(result_column->size(), count);
492
358
    return Status::OK();
493
358
}
494
495
Status VectorizedIfNullExpr::execute_column_impl(VExprContext* context, const Block* block,
496
                                                 const Selector* selector, size_t count,
497
292
                                                 ColumnPtr& result_column) const {
498
292
    DCHECK(_open_finished || block == nullptr) << debug_string();
499
292
    DCHECK_EQ(_children.size(), 2) << "IFNULL expr must have two children";
500
501
292
    ColumnPtr first_column;
502
292
    RETURN_IF_ERROR(_children[0]->execute_column(context, block, selector, count, first_column));
503
292
    first_column = first_column->convert_to_full_column_if_const();
504
505
292
    if (!first_column->is_nullable()) {
506
0
        result_column = first_column;
507
0
        DCHECK(_data_type->is_nullable() == false);
508
0
        return Status::OK();
509
0
    }
510
511
292
    if (first_column->only_null()) {
512
19
        RETURN_IF_ERROR(
513
19
                _children[1]->execute_column(context, block, selector, count, result_column));
514
19
        return Status::OK();
515
19
    }
516
517
273
    ColumnPtr second_column;
518
273
    RETURN_IF_ERROR(_children[1]->execute_column(context, block, selector, count, second_column));
519
520
273
    const auto& nullable_first_column = assert_cast<const ColumnNullable&>(*first_column);
521
522
273
    ColumnPtr cond_column = nullable_first_column.get_null_map_column_ptr();
523
524
273
    ColumnPtr then_column = second_column;
525
526
273
    ColumnPtr else_column;
527
273
    DataTypePtr else_type;
528
529
273
    if (_data_type->is_nullable()) {
530
8
        else_column = first_column;
531
8
        else_type = _children[0]->execute_type(block);
532
265
    } else {
533
265
        else_column = nullable_first_column.get_nested_column_ptr();
534
265
        else_type = remove_nullable(_children[0]->execute_type(block));
535
265
    }
536
537
273
    Block temp_block;
538
273
    temp_block.insert({cond_column, std::make_shared<DataTypeUInt8>(), "cond column"});
539
273
    temp_block.insert({then_column, _children[1]->execute_type(block), _children[1]->expr_name()});
540
273
    temp_block.insert({else_column, else_type, _children[0]->expr_name()});
541
542
    // prepare a column to save result
543
273
    temp_block.insert({nullptr, _data_type, IF_NULL_NAME});
544
273
    RETURN_IF_ERROR(_execute_impl_internal(temp_block, {0, 1, 2}, 3, temp_block.rows()));
545
273
    result_column = temp_block.get_by_position(3).column;
546
273
    DCHECK_EQ(result_column->size(), count);
547
273
    return Status::OK();
548
273
}
549
550
template <typename ColumnType>
551
void insert_result_data(MutableColumnPtr& result_column, ColumnPtr& argument_column,
552
                        const UInt8* __restrict null_map_data, UInt8* __restrict filled_flag,
553
88
                        const size_t input_rows_count) {
554
88
    if (result_column->size() == 0 && input_rows_count) {
555
44
        result_column->resize(input_rows_count);
556
44
        auto* __restrict result_raw_data =
557
44
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
147
        for (int i = 0; i < input_rows_count; i++) {
559
103
            result_raw_data[i] = {};
560
103
        }
561
44
    }
562
88
    auto* __restrict result_raw_data =
563
88
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
88
    auto* __restrict column_raw_data =
565
88
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
316
    for (size_t row = 0; row < input_rows_count; ++row) {
571
228
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
2
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
2
                    result_raw_data[row].to_date_int_val() +
574
2
                    column_raw_data[row].to_date_int_val() *
575
2
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
2
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
2
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
2
                    result_raw_data[row].to_date_int_val() +
579
2
                    column_raw_data[row].to_date_int_val() *
580
2
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
2
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
0
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
0
                    result_raw_data[row].to_date_int_val() +
584
0
                    column_raw_data[row].to_date_int_val() *
585
0
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
0
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
0
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
0
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
0
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
0
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
54
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
54
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
54
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
54
                                            ? column_raw_data[row] * flag
597
54
                                            : (flag ? column_raw_data[row] : 0);
598
170
        } else {
599
170
            result_raw_data[row] +=
600
170
                    column_raw_data[row] *
601
170
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
170
        }
603
604
228
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
228
    }
606
88
}
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE2EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
_ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE3EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Line
Count
Source
553
14
                        const size_t input_rows_count) {
554
14
    if (result_column->size() == 0 && input_rows_count) {
555
8
        result_column->resize(input_rows_count);
556
8
        auto* __restrict result_raw_data =
557
8
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
30
        for (int i = 0; i < input_rows_count; i++) {
559
22
            result_raw_data[i] = {};
560
22
        }
561
8
    }
562
14
    auto* __restrict result_raw_data =
563
14
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
14
    auto* __restrict column_raw_data =
565
14
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
56
    for (size_t row = 0; row < input_rows_count; ++row) {
571
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
                    result_raw_data[row].to_date_int_val() +
574
                    column_raw_data[row].to_date_int_val() *
575
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
                    result_raw_data[row].to_date_int_val() +
579
                    column_raw_data[row].to_date_int_val() *
580
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
                    result_raw_data[row].to_date_int_val() +
584
                    column_raw_data[row].to_date_int_val() *
585
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
                                            ? column_raw_data[row] * flag
597
                                            : (flag ? column_raw_data[row] : 0);
598
42
        } else {
599
42
            result_raw_data[row] +=
600
42
                    column_raw_data[row] *
601
42
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
42
        }
603
604
42
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
42
    }
606
14
}
_ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE4EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Line
Count
Source
553
4
                        const size_t input_rows_count) {
554
4
    if (result_column->size() == 0 && input_rows_count) {
555
2
        result_column->resize(input_rows_count);
556
2
        auto* __restrict result_raw_data =
557
2
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
4
        for (int i = 0; i < input_rows_count; i++) {
559
2
            result_raw_data[i] = {};
560
2
        }
561
2
    }
562
4
    auto* __restrict result_raw_data =
563
4
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
4
    auto* __restrict column_raw_data =
565
4
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
8
    for (size_t row = 0; row < input_rows_count; ++row) {
571
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
                    result_raw_data[row].to_date_int_val() +
574
                    column_raw_data[row].to_date_int_val() *
575
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
                    result_raw_data[row].to_date_int_val() +
579
                    column_raw_data[row].to_date_int_val() *
580
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
                    result_raw_data[row].to_date_int_val() +
584
                    column_raw_data[row].to_date_int_val() *
585
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
                                            ? column_raw_data[row] * flag
597
                                            : (flag ? column_raw_data[row] : 0);
598
4
        } else {
599
4
            result_raw_data[row] +=
600
4
                    column_raw_data[row] *
601
4
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
4
        }
603
604
4
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
4
    }
606
4
}
_ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE5EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Line
Count
Source
553
35
                        const size_t input_rows_count) {
554
35
    if (result_column->size() == 0 && input_rows_count) {
555
15
        result_column->resize(input_rows_count);
556
15
        auto* __restrict result_raw_data =
557
15
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
62
        for (int i = 0; i < input_rows_count; i++) {
559
47
            result_raw_data[i] = {};
560
47
        }
561
15
    }
562
35
    auto* __restrict result_raw_data =
563
35
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
35
    auto* __restrict column_raw_data =
565
35
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
150
    for (size_t row = 0; row < input_rows_count; ++row) {
571
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
                    result_raw_data[row].to_date_int_val() +
574
                    column_raw_data[row].to_date_int_val() *
575
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
                    result_raw_data[row].to_date_int_val() +
579
                    column_raw_data[row].to_date_int_val() *
580
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
                    result_raw_data[row].to_date_int_val() +
584
                    column_raw_data[row].to_date_int_val() *
585
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
                                            ? column_raw_data[row] * flag
597
                                            : (flag ? column_raw_data[row] : 0);
598
115
        } else {
599
115
            result_raw_data[row] +=
600
115
                    column_raw_data[row] *
601
115
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
115
        }
603
604
115
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
115
    }
606
35
}
_ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE6EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Line
Count
Source
553
3
                        const size_t input_rows_count) {
554
3
    if (result_column->size() == 0 && input_rows_count) {
555
2
        result_column->resize(input_rows_count);
556
2
        auto* __restrict result_raw_data =
557
2
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
4
        for (int i = 0; i < input_rows_count; i++) {
559
2
            result_raw_data[i] = {};
560
2
        }
561
2
    }
562
3
    auto* __restrict result_raw_data =
563
3
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
3
    auto* __restrict column_raw_data =
565
3
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
6
    for (size_t row = 0; row < input_rows_count; ++row) {
571
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
                    result_raw_data[row].to_date_int_val() +
574
                    column_raw_data[row].to_date_int_val() *
575
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
                    result_raw_data[row].to_date_int_val() +
579
                    column_raw_data[row].to_date_int_val() *
580
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
                    result_raw_data[row].to_date_int_val() +
584
                    column_raw_data[row].to_date_int_val() *
585
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
                                            ? column_raw_data[row] * flag
597
                                            : (flag ? column_raw_data[row] : 0);
598
3
        } else {
599
3
            result_raw_data[row] +=
600
3
                    column_raw_data[row] *
601
3
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
3
        }
603
604
3
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
3
    }
606
3
}
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE7EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
_ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE8EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Line
Count
Source
553
4
                        const size_t input_rows_count) {
554
4
    if (result_column->size() == 0 && input_rows_count) {
555
2
        result_column->resize(input_rows_count);
556
2
        auto* __restrict result_raw_data =
557
2
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
5
        for (int i = 0; i < input_rows_count; i++) {
559
3
            result_raw_data[i] = {};
560
3
        }
561
2
    }
562
4
    auto* __restrict result_raw_data =
563
4
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
4
    auto* __restrict column_raw_data =
565
4
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
10
    for (size_t row = 0; row < input_rows_count; ++row) {
571
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
                    result_raw_data[row].to_date_int_val() +
574
                    column_raw_data[row].to_date_int_val() *
575
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
                    result_raw_data[row].to_date_int_val() +
579
                    column_raw_data[row].to_date_int_val() *
580
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
                    result_raw_data[row].to_date_int_val() +
584
                    column_raw_data[row].to_date_int_val() *
585
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
6
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
6
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
6
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
6
                                            ? column_raw_data[row] * flag
597
6
                                            : (flag ? column_raw_data[row] : 0);
598
        } else {
599
            result_raw_data[row] +=
600
                    column_raw_data[row] *
601
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
        }
603
604
6
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
6
    }
606
4
}
_ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE9EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Line
Count
Source
553
20
                        const size_t input_rows_count) {
554
20
    if (result_column->size() == 0 && input_rows_count) {
555
11
        result_column->resize(input_rows_count);
556
11
        auto* __restrict result_raw_data =
557
11
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
33
        for (int i = 0; i < input_rows_count; i++) {
559
22
            result_raw_data[i] = {};
560
22
        }
561
11
    }
562
20
    auto* __restrict result_raw_data =
563
20
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
20
    auto* __restrict column_raw_data =
565
20
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
68
    for (size_t row = 0; row < input_rows_count; ++row) {
571
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
                    result_raw_data[row].to_date_int_val() +
574
                    column_raw_data[row].to_date_int_val() *
575
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
                    result_raw_data[row].to_date_int_val() +
579
                    column_raw_data[row].to_date_int_val() *
580
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
                    result_raw_data[row].to_date_int_val() +
584
                    column_raw_data[row].to_date_int_val() *
585
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
48
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
48
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
48
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
48
                                            ? column_raw_data[row] * flag
597
48
                                            : (flag ? column_raw_data[row] : 0);
598
        } else {
599
            result_raw_data[row] +=
600
                    column_raw_data[row] *
601
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
        }
603
604
48
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
48
    }
606
20
}
_ZN5doris18insert_result_dataINS_13ColumnDecimalILNS_13PrimitiveTypeE28EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Line
Count
Source
553
2
                        const size_t input_rows_count) {
554
2
    if (result_column->size() == 0 && input_rows_count) {
555
1
        result_column->resize(input_rows_count);
556
1
        auto* __restrict result_raw_data =
557
1
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
2
        for (int i = 0; i < input_rows_count; i++) {
559
1
            result_raw_data[i] = {};
560
1
        }
561
1
    }
562
2
    auto* __restrict result_raw_data =
563
2
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
2
    auto* __restrict column_raw_data =
565
2
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
4
    for (size_t row = 0; row < input_rows_count; ++row) {
571
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
                    result_raw_data[row].to_date_int_val() +
574
                    column_raw_data[row].to_date_int_val() *
575
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
                    result_raw_data[row].to_date_int_val() +
579
                    column_raw_data[row].to_date_int_val() *
580
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
                    result_raw_data[row].to_date_int_val() +
584
                    column_raw_data[row].to_date_int_val() *
585
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
                                            ? column_raw_data[row] * flag
597
                                            : (flag ? column_raw_data[row] : 0);
598
2
        } else {
599
2
            result_raw_data[row] +=
600
2
                    column_raw_data[row] *
601
2
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
2
        }
603
604
2
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
2
    }
606
2
}
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_13ColumnDecimalILNS_13PrimitiveTypeE29EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_13ColumnDecimalILNS_13PrimitiveTypeE20EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
_ZN5doris18insert_result_dataINS_13ColumnDecimalILNS_13PrimitiveTypeE30EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Line
Count
Source
553
2
                        const size_t input_rows_count) {
554
2
    if (result_column->size() == 0 && input_rows_count) {
555
1
        result_column->resize(input_rows_count);
556
1
        auto* __restrict result_raw_data =
557
1
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
3
        for (int i = 0; i < input_rows_count; i++) {
559
2
            result_raw_data[i] = {};
560
2
        }
561
1
    }
562
2
    auto* __restrict result_raw_data =
563
2
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
2
    auto* __restrict column_raw_data =
565
2
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
6
    for (size_t row = 0; row < input_rows_count; ++row) {
571
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
                    result_raw_data[row].to_date_int_val() +
574
                    column_raw_data[row].to_date_int_val() *
575
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
                    result_raw_data[row].to_date_int_val() +
579
                    column_raw_data[row].to_date_int_val() *
580
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
                    result_raw_data[row].to_date_int_val() +
584
                    column_raw_data[row].to_date_int_val() *
585
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
                                            ? column_raw_data[row] * flag
597
                                            : (flag ? column_raw_data[row] : 0);
598
4
        } else {
599
4
            result_raw_data[row] +=
600
4
                    column_raw_data[row] *
601
4
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
4
        }
603
604
4
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
4
    }
606
2
}
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_13ColumnDecimalILNS_13PrimitiveTypeE35EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE11EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
_ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE25EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Line
Count
Source
553
2
                        const size_t input_rows_count) {
554
2
    if (result_column->size() == 0 && input_rows_count) {
555
1
        result_column->resize(input_rows_count);
556
1
        auto* __restrict result_raw_data =
557
1
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
2
        for (int i = 0; i < input_rows_count; i++) {
559
1
            result_raw_data[i] = {};
560
1
        }
561
1
    }
562
2
    auto* __restrict result_raw_data =
563
2
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
2
    auto* __restrict column_raw_data =
565
2
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
4
    for (size_t row = 0; row < input_rows_count; ++row) {
571
2
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
2
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
2
                    result_raw_data[row].to_date_int_val() +
574
2
                    column_raw_data[row].to_date_int_val() *
575
2
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
                    result_raw_data[row].to_date_int_val() +
579
                    column_raw_data[row].to_date_int_val() *
580
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
                    result_raw_data[row].to_date_int_val() +
584
                    column_raw_data[row].to_date_int_val() *
585
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
                                            ? column_raw_data[row] * flag
597
                                            : (flag ? column_raw_data[row] : 0);
598
        } else {
599
            result_raw_data[row] +=
600
                    column_raw_data[row] *
601
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
        }
603
604
2
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
2
    }
606
2
}
_ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE26EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Line
Count
Source
553
2
                        const size_t input_rows_count) {
554
2
    if (result_column->size() == 0 && input_rows_count) {
555
1
        result_column->resize(input_rows_count);
556
1
        auto* __restrict result_raw_data =
557
1
                assert_cast<ColumnType*>(result_column.get())->get_data().data();
558
2
        for (int i = 0; i < input_rows_count; i++) {
559
1
            result_raw_data[i] = {};
560
1
        }
561
1
    }
562
2
    auto* __restrict result_raw_data =
563
2
            assert_cast<ColumnType*>(result_column.get())->get_data().data();
564
2
    auto* __restrict column_raw_data =
565
2
            assert_cast<const ColumnType*>(argument_column.get())->get_data().data();
566
567
    // Here it's SIMD thought the compiler automatically also
568
    // true: null_map_data[row]==0 && filled_idx[row]==0
569
    // if true, could filled current row data into result column
570
4
    for (size_t row = 0; row < input_rows_count; ++row) {
571
        if constexpr (std::is_same_v<ColumnType, ColumnDateV2>) {
572
            result_raw_data[row] = binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(
573
                    result_raw_data[row].to_date_int_val() +
574
                    column_raw_data[row].to_date_int_val() *
575
                            uint32_t(!(null_map_data[row] | filled_flag[row])));
576
2
        } else if constexpr (std::is_same_v<ColumnType, ColumnDateTimeV2>) {
577
2
            result_raw_data[row] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
578
2
                    result_raw_data[row].to_date_int_val() +
579
2
                    column_raw_data[row].to_date_int_val() *
580
2
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
581
        } else if constexpr (std::is_same_v<ColumnType, ColumnTimeStampTz>) {
582
            result_raw_data[row] = binary_cast<uint64_t, TimestampTzValue>(
583
                    result_raw_data[row].to_date_int_val() +
584
                    column_raw_data[row].to_date_int_val() *
585
                            uint64_t(!(null_map_data[row] | filled_flag[row])));
586
        } else if constexpr (std::is_same_v<ColumnType, ColumnDate> ||
587
                             std::is_same_v<ColumnType, ColumnDateTime>) {
588
            result_raw_data[row] = binary_cast<int64_t, VecDateTimeValue>(
589
                    binary_cast<VecDateTimeValue, int64_t>(result_raw_data[row]) +
590
                    binary_cast<VecDateTimeValue, int64_t>(column_raw_data[row]) *
591
                            int64_t(!(null_map_data[row] | filled_flag[row])));
592
        } else if constexpr (std::is_same_v<ColumnType, ColumnFloat32> ||
593
                             std::is_same_v<ColumnType, ColumnFloat64>) {
594
            auto flag = (!(null_map_data[row] | filled_flag[row]));
595
            result_raw_data[row] += std::isfinite(column_raw_data[row])
596
                                            ? column_raw_data[row] * flag
597
                                            : (flag ? column_raw_data[row] : 0);
598
        } else {
599
            result_raw_data[row] +=
600
                    column_raw_data[row] *
601
                    typename ColumnType::value_type(!(null_map_data[row] | filled_flag[row]));
602
        }
603
604
2
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
605
2
    }
606
2
}
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE12EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE27EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE42EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE36EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
Unexecuted instantiation: _ZN5doris18insert_result_dataINS_12ColumnVectorILNS_13PrimitiveTypeE37EEEEEvRNS_3COWINS_7IColumnEE11mutable_ptrIS5_EERNS6_13immutable_ptrIS5_EEPKhPhm
607
608
Status insert_result_data_bitmap(MutableColumnPtr& result_column, ColumnPtr& argument_column,
609
                                 const UInt8* __restrict null_map_data,
610
3
                                 UInt8* __restrict filled_flag, const size_t input_rows_count) {
611
3
    if (result_column->size() == 0 && input_rows_count) {
612
2
        result_column->resize(input_rows_count);
613
2
    }
614
615
3
    auto* __restrict result_raw_data =
616
3
            reinterpret_cast<ColumnBitmap*>(result_column.get())->get_data().data();
617
3
    auto* __restrict column_raw_data =
618
3
            reinterpret_cast<const ColumnBitmap*>(argument_column.get())->get_data().data();
619
620
    // Here it's SIMD thought the compiler automatically also
621
    // true: null_map_data[row]==0 && filled_idx[row]==0
622
    // if true, could filled current row data into result column
623
8
    for (size_t row = 0; row < input_rows_count; ++row) {
624
5
        if (!(null_map_data[row] | filled_flag[row])) {
625
2
            result_raw_data[row] = column_raw_data[row];
626
2
        }
627
5
        filled_flag[row] += (!(null_map_data[row] | filled_flag[row]));
628
5
    }
629
3
    return Status::OK();
630
3
}
631
632
Status filled_result_column(const DataTypePtr& data_type, MutableColumnPtr& result_column,
633
                            ColumnPtr& argument_column, UInt8* __restrict null_map_data,
634
91
                            UInt8* __restrict filled_flag, const size_t input_rows_count) {
635
91
    if (data_type->get_primitive_type() == TYPE_BITMAP) {
636
3
        return insert_result_data_bitmap(result_column, argument_column, null_map_data, filled_flag,
637
3
                                         input_rows_count);
638
3
    }
639
640
88
    auto call = [&](const auto& type) -> bool {
641
88
        using DispatchType = std::decay_t<decltype(type)>;
642
88
        insert_result_data<typename DispatchType::ColumnType>(
643
88
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
88
        return true;
645
88
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE2EEEEEbRKT_
vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE3EEEEEbRKT_
Line
Count
Source
640
14
    auto call = [&](const auto& type) -> bool {
641
14
        using DispatchType = std::decay_t<decltype(type)>;
642
14
        insert_result_data<typename DispatchType::ColumnType>(
643
14
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
14
        return true;
645
14
    };
vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE4EEEEEbRKT_
Line
Count
Source
640
4
    auto call = [&](const auto& type) -> bool {
641
4
        using DispatchType = std::decay_t<decltype(type)>;
642
4
        insert_result_data<typename DispatchType::ColumnType>(
643
4
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
4
        return true;
645
4
    };
vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE5EEEEEbRKT_
Line
Count
Source
640
35
    auto call = [&](const auto& type) -> bool {
641
35
        using DispatchType = std::decay_t<decltype(type)>;
642
35
        insert_result_data<typename DispatchType::ColumnType>(
643
35
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
35
        return true;
645
35
    };
vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE6EEEEEbRKT_
Line
Count
Source
640
3
    auto call = [&](const auto& type) -> bool {
641
3
        using DispatchType = std::decay_t<decltype(type)>;
642
3
        insert_result_data<typename DispatchType::ColumnType>(
643
3
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
3
        return true;
645
3
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE7EEEEEbRKT_
vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE8EEEEEbRKT_
Line
Count
Source
640
4
    auto call = [&](const auto& type) -> bool {
641
4
        using DispatchType = std::decay_t<decltype(type)>;
642
4
        insert_result_data<typename DispatchType::ColumnType>(
643
4
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
4
        return true;
645
4
    };
vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE9EEEEEbRKT_
Line
Count
Source
640
20
    auto call = [&](const auto& type) -> bool {
641
20
        using DispatchType = std::decay_t<decltype(type)>;
642
20
        insert_result_data<typename DispatchType::ColumnType>(
643
20
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
20
        return true;
645
20
    };
vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE28EEEEEbRKT_
Line
Count
Source
640
2
    auto call = [&](const auto& type) -> bool {
641
2
        using DispatchType = std::decay_t<decltype(type)>;
642
2
        insert_result_data<typename DispatchType::ColumnType>(
643
2
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
2
        return true;
645
2
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE29EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE20EEEEEbRKT_
vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE30EEEEEbRKT_
Line
Count
Source
640
2
    auto call = [&](const auto& type) -> bool {
641
2
        using DispatchType = std::decay_t<decltype(type)>;
642
2
        insert_result_data<typename DispatchType::ColumnType>(
643
2
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
2
        return true;
645
2
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE35EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE11EEEEEbRKT_
vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE25EEEEEbRKT_
Line
Count
Source
640
2
    auto call = [&](const auto& type) -> bool {
641
2
        using DispatchType = std::decay_t<decltype(type)>;
642
2
        insert_result_data<typename DispatchType::ColumnType>(
643
2
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
2
        return true;
645
2
    };
vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE26EEEEEbRKT_
Line
Count
Source
640
2
    auto call = [&](const auto& type) -> bool {
641
2
        using DispatchType = std::decay_t<decltype(type)>;
642
2
        insert_result_data<typename DispatchType::ColumnType>(
643
2
                result_column, argument_column, null_map_data, filled_flag, input_rows_count);
644
2
        return true;
645
2
    };
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE12EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE27EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE42EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE36EEEEEbRKT_
Unexecuted instantiation: vcondition_expr.cpp:_ZZN5doris20filled_result_columnERKSt10shared_ptrIKNS_9IDataTypeEERNS_3COWINS_7IColumnEE11mutable_ptrIS7_EERNS8_13immutable_ptrIS7_EEPhSF_mENK3$_0clINS_16DispatchDataTypeILNS_13PrimitiveTypeE37EEEEEbRKT_
646
647
88
    if (!dispatch_switch_scalar(data_type->get_primitive_type(), call)) {
648
0
        return Status::InternalError("not support type {} in coalesce", data_type->get_name());
649
0
    }
650
88
    return Status::OK();
651
88
}
652
653
Status VectorizedCoalesceExpr::execute_column_impl(VExprContext* context, const Block* block,
654
                                                   const Selector* selector, size_t count,
655
210
                                                   ColumnPtr& return_column) const {
656
210
    DataTypePtr result_type = _data_type;
657
210
    const auto input_rows_count = count;
658
659
210
    size_t remaining_rows = input_rows_count;
660
210
    std::vector<uint32_t> record_idx(
661
210
            input_rows_count,
662
210
            0); //used to save column idx, record the result data of each row from which column
663
210
    std::vector<uint8_t> filled_flags(
664
210
            input_rows_count,
665
210
            0); //used to save filled flag, in order to check current row whether have filled data
666
667
210
    MutableColumnPtr result_column;
668
210
    if (!result_type->is_nullable()) {
669
112
        result_column = result_type->create_column();
670
112
    } else {
671
98
        result_column = remove_nullable(result_type)->create_column();
672
98
    }
673
674
    // because now follow below types does not support random position writing,
675
    // so insert into result data have two methods, one is for these types, one is for others type remaining
676
210
    bool cannot_random_write = result_column->is_column_string() ||
677
210
                               result_type->get_primitive_type() == PrimitiveType::TYPE_MAP ||
678
210
                               result_type->get_primitive_type() == PrimitiveType::TYPE_STRUCT ||
679
210
                               result_type->get_primitive_type() == PrimitiveType::TYPE_ARRAY ||
680
210
                               result_type->get_primitive_type() == PrimitiveType::TYPE_JSONB;
681
210
    if (cannot_random_write) {
682
56
        result_column->reserve(input_rows_count);
683
56
    }
684
685
210
    auto return_type = std::make_shared<DataTypeUInt8>();
686
210
    auto null_map = ColumnUInt8::create(input_rows_count,
687
210
                                        1); //if null_map_data==1, the current row should be null
688
210
    auto* __restrict null_map_data = null_map->get_data().data();
689
690
291
    auto is_not_null = [](const ColumnPtr& column, size_t size) -> ColumnUInt8::MutablePtr {
691
291
        if (const auto* nullable = check_and_get_column<ColumnNullable>(*column)) {
692
            /// Return the negated null map.
693
223
            auto res_column = ColumnUInt8::create(size);
694
223
            const auto* __restrict src_data = nullable->get_null_map_data().data();
695
223
            auto* __restrict res_data = res_column->get_data().data();
696
697
8.78k
            for (size_t i = 0; i < size; ++i) {
698
8.56k
                res_data[i] = !src_data[i];
699
8.56k
            }
700
223
            return res_column;
701
223
        } else {
702
            /// Since no element is nullable, return a constant one.
703
68
            return ColumnUInt8::create(size, 1);
704
68
        }
705
291
    };
706
707
210
    std::vector<ColumnPtr> original_columns(_children.size());
708
210
    std::vector<ColumnPtr> argument_not_null_columns(_children.size());
709
710
350
    for (size_t i = 0; i < _children.size() && remaining_rows; ++i) {
711
        // Execute child expression to get the argument column.
712
291
        RETURN_IF_ERROR(
713
291
                _children[i]->execute_column(context, block, selector, count, original_columns[i]));
714
291
        original_columns[i] = original_columns[i]->convert_to_full_column_if_const();
715
291
        argument_not_null_columns[i] = original_columns[i];
716
291
        if (const auto* nullable =
717
291
                    check_and_get_column<const ColumnNullable>(*argument_not_null_columns[i])) {
718
223
            argument_not_null_columns[i] = nullable->get_nested_column_ptr();
719
223
        }
720
721
291
        auto res_column = is_not_null(original_columns[i], input_rows_count);
722
723
291
        auto& res_map = res_column->get_data();
724
291
        auto* __restrict res = res_map.data();
725
726
        // Here it's SIMD thought the compiler automatically
727
        // true: res[j]==1 && null_map_data[j]==1, false: others
728
        // if true: remaining_rows--; record_idx[j]=column_idx; null_map_data[j]=0, so the current row could fill result
729
9.00k
        for (size_t j = 0; j < input_rows_count; ++j) {
730
8.71k
            remaining_rows -= (res[j] & null_map_data[j]);
731
8.71k
            record_idx[j] += (res[j] & null_map_data[j]) * i;
732
8.71k
            null_map_data[j] -= (res[j] & null_map_data[j]);
733
8.71k
        }
734
735
291
        if (remaining_rows == 0) {
736
            //check whether all result data from the same column
737
196
            size_t is_same_column_count = 0;
738
196
            const auto data = record_idx[0];
739
8.67k
            for (size_t row = 0; row < input_rows_count; ++row) {
740
8.47k
                is_same_column_count += (record_idx[row] == data);
741
8.47k
            }
742
743
196
            if (is_same_column_count == input_rows_count) {
744
151
                if (result_type->is_nullable()) {
745
75
                    return_column = make_nullable(argument_not_null_columns[i]);
746
76
                } else {
747
76
                    return_column = argument_not_null_columns[i];
748
76
                }
749
151
                return Status::OK();
750
151
            }
751
196
        }
752
753
140
        if (!cannot_random_write) {
754
            //if not string type, could check one column firstly,
755
            //and then fill the not null value in result column,
756
            //this method may result in higher CPU cache
757
91
            RETURN_IF_ERROR(filled_result_column(result_type, result_column,
758
91
                                                 argument_not_null_columns[i], null_map_data,
759
91
                                                 filled_flags.data(), input_rows_count));
760
91
        }
761
140
    }
762
763
59
    if (cannot_random_write) {
764
        //if string type,  should according to the record results, fill in result one by one,
765
91
        for (size_t row = 0; row < input_rows_count; ++row) {
766
69
            if (null_map_data[row]) { //should be null
767
3
                result_column->insert_default();
768
66
            } else {
769
66
                result_column->insert_from(*argument_not_null_columns[record_idx[row]].get(), row);
770
66
            }
771
69
        }
772
22
    }
773
774
59
    if (result_type->is_nullable()) {
775
22
        return_column = ColumnNullable::create(std::move(result_column), std::move(null_map));
776
37
    } else {
777
37
        return_column = std::move(result_column);
778
37
    }
779
780
    DCHECK_EQ(return_column->size(), count);
781
59
    return Status::OK();
782
210
}
783
784
} // namespace doris