Coverage Report

Created: 2026-03-27 21:20

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