Coverage Report

Created: 2026-07-06 12:17

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