be/src/exprs/function/int_div.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 | | // This file is copied from |
18 | | // https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/IntDiv.cpp |
19 | | // and modified by Doris |
20 | | |
21 | | #include <libdivide.h> |
22 | | |
23 | | #include <limits> |
24 | | #include <utility> |
25 | | |
26 | | #include "core/data_type/data_type_number.h" |
27 | | #include "exprs/function/simple_function_factory.h" |
28 | | |
29 | | namespace doris { |
30 | | |
31 | | template <typename Impl> |
32 | | class FunctionIntDiv : public IFunction { |
33 | | public: |
34 | | static constexpr auto name = "int_divide"; |
35 | | |
36 | 682 | static FunctionPtr create() { return std::make_shared<FunctionIntDiv>(); }_ZN5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE6createEv Line | Count | Source | 36 | 26 | static FunctionPtr create() { return std::make_shared<FunctionIntDiv>(); } |
_ZN5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE6createEv Line | Count | Source | 36 | 18 | static FunctionPtr create() { return std::make_shared<FunctionIntDiv>(); } |
_ZN5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE6createEv Line | Count | Source | 36 | 33 | static FunctionPtr create() { return std::make_shared<FunctionIntDiv>(); } |
_ZN5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE6createEv Line | Count | Source | 36 | 572 | static FunctionPtr create() { return std::make_shared<FunctionIntDiv>(); } |
_ZN5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE6createEv Line | Count | Source | 36 | 33 | static FunctionPtr create() { return std::make_shared<FunctionIntDiv>(); } |
|
37 | | |
38 | 682 | FunctionIntDiv() = default; _ZN5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEEC2Ev Line | Count | Source | 38 | 26 | FunctionIntDiv() = default; |
_ZN5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEEC2Ev Line | Count | Source | 38 | 18 | FunctionIntDiv() = default; |
_ZN5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEEC2Ev Line | Count | Source | 38 | 33 | FunctionIntDiv() = default; |
_ZN5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEEC2Ev Line | Count | Source | 38 | 572 | FunctionIntDiv() = default; |
_ZN5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEEC2Ev Line | Count | Source | 38 | 33 | FunctionIntDiv() = default; |
|
39 | | |
40 | 5 | String get_name() const override { return name; }_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE8get_nameB5cxx11Ev Line | Count | Source | 40 | 1 | String get_name() const override { return name; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE8get_nameB5cxx11Ev Line | Count | Source | 40 | 1 | String get_name() const override { return name; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE8get_nameB5cxx11Ev Line | Count | Source | 40 | 1 | String get_name() const override { return name; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE8get_nameB5cxx11Ev Line | Count | Source | 40 | 1 | String get_name() const override { return name; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE8get_nameB5cxx11Ev Line | Count | Source | 40 | 1 | String get_name() const override { return name; } |
|
41 | | |
42 | 637 | size_t get_number_of_arguments() const override { return 2; }_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE23get_number_of_argumentsEv Line | Count | Source | 42 | 17 | size_t get_number_of_arguments() const override { return 2; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE23get_number_of_argumentsEv Line | Count | Source | 42 | 9 | size_t get_number_of_arguments() const override { return 2; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE23get_number_of_argumentsEv Line | Count | Source | 42 | 24 | size_t get_number_of_arguments() const override { return 2; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE23get_number_of_argumentsEv Line | Count | Source | 42 | 563 | size_t get_number_of_arguments() const override { return 2; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE23get_number_of_argumentsEv Line | Count | Source | 42 | 24 | size_t get_number_of_arguments() const override { return 2; } |
|
43 | | |
44 | 40 | DataTypes get_variadic_argument_types_impl() const override { |
45 | 40 | return Impl::get_variadic_argument_types(); |
46 | 40 | } _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE32get_variadic_argument_types_implEv Line | Count | Source | 44 | 8 | DataTypes get_variadic_argument_types_impl() const override { | 45 | 8 | return Impl::get_variadic_argument_types(); | 46 | 8 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE32get_variadic_argument_types_implEv Line | Count | Source | 44 | 8 | DataTypes get_variadic_argument_types_impl() const override { | 45 | 8 | return Impl::get_variadic_argument_types(); | 46 | 8 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE32get_variadic_argument_types_implEv Line | Count | Source | 44 | 8 | DataTypes get_variadic_argument_types_impl() const override { | 45 | 8 | return Impl::get_variadic_argument_types(); | 46 | 8 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE32get_variadic_argument_types_implEv Line | Count | Source | 44 | 8 | DataTypes get_variadic_argument_types_impl() const override { | 45 | 8 | return Impl::get_variadic_argument_types(); | 46 | 8 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE32get_variadic_argument_types_implEv Line | Count | Source | 44 | 8 | DataTypes get_variadic_argument_types_impl() const override { | 45 | 8 | return Impl::get_variadic_argument_types(); | 46 | 8 | } |
|
47 | | |
48 | 637 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
49 | 637 | DataTypePtr type_res = |
50 | 637 | std::make_shared<typename PrimitiveTypeTraits<Impl::ResultType>::DataType>(); |
51 | 637 | return make_nullable(type_res); |
52 | 637 | } _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Line | Count | Source | 48 | 17 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 49 | 17 | DataTypePtr type_res = | 50 | 17 | std::make_shared<typename PrimitiveTypeTraits<Impl::ResultType>::DataType>(); | 51 | 17 | return make_nullable(type_res); | 52 | 17 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Line | Count | Source | 48 | 9 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 49 | 9 | DataTypePtr type_res = | 50 | 9 | std::make_shared<typename PrimitiveTypeTraits<Impl::ResultType>::DataType>(); | 51 | 9 | return make_nullable(type_res); | 52 | 9 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Line | Count | Source | 48 | 24 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 49 | 24 | DataTypePtr type_res = | 50 | 24 | std::make_shared<typename PrimitiveTypeTraits<Impl::ResultType>::DataType>(); | 51 | 24 | return make_nullable(type_res); | 52 | 24 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Line | Count | Source | 48 | 563 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 49 | 563 | DataTypePtr type_res = | 50 | 563 | std::make_shared<typename PrimitiveTypeTraits<Impl::ResultType>::DataType>(); | 51 | 563 | return make_nullable(type_res); | 52 | 563 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Line | Count | Source | 48 | 24 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 49 | 24 | DataTypePtr type_res = | 50 | 24 | std::make_shared<typename PrimitiveTypeTraits<Impl::ResultType>::DataType>(); | 51 | 24 | return make_nullable(type_res); | 52 | 24 | } |
|
53 | | |
54 | 7.25k | bool use_default_implementation_for_constants() const final { return false; }_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE40use_default_implementation_for_constantsEv Line | Count | Source | 54 | 126 | bool use_default_implementation_for_constants() const final { return false; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE40use_default_implementation_for_constantsEv Line | Count | Source | 54 | 75 | bool use_default_implementation_for_constants() const final { return false; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE40use_default_implementation_for_constantsEv Line | Count | Source | 54 | 144 | bool use_default_implementation_for_constants() const final { return false; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE40use_default_implementation_for_constantsEv Line | Count | Source | 54 | 6.67k | bool use_default_implementation_for_constants() const final { return false; } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE40use_default_implementation_for_constantsEv Line | Count | Source | 54 | 228 | bool use_default_implementation_for_constants() const final { return false; } |
|
55 | | |
56 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
57 | 2.40k | uint32_t result, size_t input_rows_count) const override { |
58 | 2.40k | auto& column_left = block.get_by_position(arguments[0]).column; |
59 | 2.40k | auto& column_right = block.get_by_position(arguments[1]).column; |
60 | 2.40k | bool is_const_left = is_column_const(*column_left); |
61 | 2.40k | bool is_const_right = is_column_const(*column_right); |
62 | | |
63 | 2.40k | ColumnPtr column_result = nullptr; |
64 | 2.40k | if (is_const_left && is_const_right) { |
65 | 25 | column_result = constant_constant(column_left, column_right); |
66 | 2.38k | } else if (is_const_left) { |
67 | 2 | column_result = constant_vector(column_left, column_right); |
68 | 2.38k | } else if (is_const_right) { |
69 | 7 | column_result = vector_constant(column_left, column_right); |
70 | 2.37k | } else { |
71 | 2.37k | column_result = vector_vector(column_left, column_right); |
72 | 2.37k | } |
73 | 2.40k | block.replace_by_position(result, std::move(column_result)); |
74 | 2.40k | return Status::OK(); |
75 | 2.40k | } _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 57 | 35 | uint32_t result, size_t input_rows_count) const override { | 58 | 35 | auto& column_left = block.get_by_position(arguments[0]).column; | 59 | 35 | auto& column_right = block.get_by_position(arguments[1]).column; | 60 | 35 | bool is_const_left = is_column_const(*column_left); | 61 | 35 | bool is_const_right = is_column_const(*column_right); | 62 | | | 63 | 35 | ColumnPtr column_result = nullptr; | 64 | 35 | if (is_const_left && is_const_right) { | 65 | 10 | column_result = constant_constant(column_left, column_right); | 66 | 25 | } else if (is_const_left) { | 67 | 0 | column_result = constant_vector(column_left, column_right); | 68 | 25 | } else if (is_const_right) { | 69 | 0 | column_result = vector_constant(column_left, column_right); | 70 | 25 | } else { | 71 | 25 | column_result = vector_vector(column_left, column_right); | 72 | 25 | } | 73 | 35 | block.replace_by_position(result, std::move(column_result)); | 74 | 35 | return Status::OK(); | 75 | 35 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 57 | 27 | uint32_t result, size_t input_rows_count) const override { | 58 | 27 | auto& column_left = block.get_by_position(arguments[0]).column; | 59 | 27 | auto& column_right = block.get_by_position(arguments[1]).column; | 60 | 27 | bool is_const_left = is_column_const(*column_left); | 61 | 27 | bool is_const_right = is_column_const(*column_right); | 62 | | | 63 | 27 | ColumnPtr column_result = nullptr; | 64 | 27 | if (is_const_left && is_const_right) { | 65 | 2 | column_result = constant_constant(column_left, column_right); | 66 | 25 | } else if (is_const_left) { | 67 | 0 | column_result = constant_vector(column_left, column_right); | 68 | 25 | } else if (is_const_right) { | 69 | 0 | column_result = vector_constant(column_left, column_right); | 70 | 25 | } else { | 71 | 25 | column_result = vector_vector(column_left, column_right); | 72 | 25 | } | 73 | 27 | block.replace_by_position(result, std::move(column_result)); | 74 | 27 | return Status::OK(); | 75 | 27 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 57 | 48 | uint32_t result, size_t input_rows_count) const override { | 58 | 48 | auto& column_left = block.get_by_position(arguments[0]).column; | 59 | 48 | auto& column_right = block.get_by_position(arguments[1]).column; | 60 | 48 | bool is_const_left = is_column_const(*column_left); | 61 | 48 | bool is_const_right = is_column_const(*column_right); | 62 | | | 63 | 48 | ColumnPtr column_result = nullptr; | 64 | 48 | if (is_const_left && is_const_right) { | 65 | 10 | column_result = constant_constant(column_left, column_right); | 66 | 38 | } else if (is_const_left) { | 67 | 0 | column_result = constant_vector(column_left, column_right); | 68 | 38 | } else if (is_const_right) { | 69 | 5 | column_result = vector_constant(column_left, column_right); | 70 | 33 | } else { | 71 | 33 | column_result = vector_vector(column_left, column_right); | 72 | 33 | } | 73 | 48 | block.replace_by_position(result, std::move(column_result)); | 74 | 48 | return Status::OK(); | 75 | 48 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 57 | 2.21k | uint32_t result, size_t input_rows_count) const override { | 58 | 2.21k | auto& column_left = block.get_by_position(arguments[0]).column; | 59 | 2.21k | auto& column_right = block.get_by_position(arguments[1]).column; | 60 | 2.21k | bool is_const_left = is_column_const(*column_left); | 61 | 2.21k | bool is_const_right = is_column_const(*column_right); | 62 | | | 63 | 2.21k | ColumnPtr column_result = nullptr; | 64 | 2.21k | if (is_const_left && is_const_right) { | 65 | 2 | column_result = constant_constant(column_left, column_right); | 66 | 2.21k | } else if (is_const_left) { | 67 | 1 | column_result = constant_vector(column_left, column_right); | 68 | 2.21k | } else if (is_const_right) { | 69 | 1 | column_result = vector_constant(column_left, column_right); | 70 | 2.21k | } else { | 71 | 2.21k | column_result = vector_vector(column_left, column_right); | 72 | 2.21k | } | 73 | 2.21k | block.replace_by_position(result, std::move(column_result)); | 74 | 2.21k | return Status::OK(); | 75 | 2.21k | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 57 | 84 | uint32_t result, size_t input_rows_count) const override { | 58 | 84 | auto& column_left = block.get_by_position(arguments[0]).column; | 59 | 84 | auto& column_right = block.get_by_position(arguments[1]).column; | 60 | 84 | bool is_const_left = is_column_const(*column_left); | 61 | 84 | bool is_const_right = is_column_const(*column_right); | 62 | | | 63 | 84 | ColumnPtr column_result = nullptr; | 64 | 84 | if (is_const_left && is_const_right) { | 65 | 1 | column_result = constant_constant(column_left, column_right); | 66 | 83 | } else if (is_const_left) { | 67 | 1 | column_result = constant_vector(column_left, column_right); | 68 | 82 | } else if (is_const_right) { | 69 | 1 | column_result = vector_constant(column_left, column_right); | 70 | 81 | } else { | 71 | 81 | column_result = vector_vector(column_left, column_right); | 72 | 81 | } | 73 | 84 | block.replace_by_position(result, std::move(column_result)); | 74 | 84 | return Status::OK(); | 75 | 84 | } |
|
76 | | |
77 | | private: |
78 | 25 | ColumnPtr constant_constant(ColumnPtr column_left, ColumnPtr column_right) const { |
79 | 25 | const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get()); |
80 | 25 | const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get()); |
81 | 25 | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); |
82 | | |
83 | 25 | ColumnPtr column_result = nullptr; |
84 | | |
85 | 25 | column_result = |
86 | 25 | Impl::constant_constant(column_left_ptr->template get_value<Impl::ResultType>(), |
87 | 25 | column_right_ptr->template get_value<Impl::ResultType>()); |
88 | | |
89 | 25 | return ColumnConst::create(std::move(column_result), column_left->size()); |
90 | 25 | } _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE17constant_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 78 | 10 | ColumnPtr constant_constant(ColumnPtr column_left, ColumnPtr column_right) const { | 79 | 10 | const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get()); | 80 | 10 | const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get()); | 81 | 10 | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); | 82 | | | 83 | 10 | ColumnPtr column_result = nullptr; | 84 | | | 85 | 10 | column_result = | 86 | 10 | Impl::constant_constant(column_left_ptr->template get_value<Impl::ResultType>(), | 87 | 10 | column_right_ptr->template get_value<Impl::ResultType>()); | 88 | | | 89 | 10 | return ColumnConst::create(std::move(column_result), column_left->size()); | 90 | 10 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE17constant_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 78 | 2 | ColumnPtr constant_constant(ColumnPtr column_left, ColumnPtr column_right) const { | 79 | 2 | const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get()); | 80 | 2 | const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get()); | 81 | 2 | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); | 82 | | | 83 | 2 | ColumnPtr column_result = nullptr; | 84 | | | 85 | 2 | column_result = | 86 | 2 | Impl::constant_constant(column_left_ptr->template get_value<Impl::ResultType>(), | 87 | 2 | column_right_ptr->template get_value<Impl::ResultType>()); | 88 | | | 89 | 2 | return ColumnConst::create(std::move(column_result), column_left->size()); | 90 | 2 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE17constant_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 78 | 10 | ColumnPtr constant_constant(ColumnPtr column_left, ColumnPtr column_right) const { | 79 | 10 | const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get()); | 80 | 10 | const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get()); | 81 | 10 | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); | 82 | | | 83 | 10 | ColumnPtr column_result = nullptr; | 84 | | | 85 | 10 | column_result = | 86 | 10 | Impl::constant_constant(column_left_ptr->template get_value<Impl::ResultType>(), | 87 | 10 | column_right_ptr->template get_value<Impl::ResultType>()); | 88 | | | 89 | 10 | return ColumnConst::create(std::move(column_result), column_left->size()); | 90 | 10 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE17constant_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 78 | 2 | ColumnPtr constant_constant(ColumnPtr column_left, ColumnPtr column_right) const { | 79 | 2 | const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get()); | 80 | 2 | const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get()); | 81 | 2 | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); | 82 | | | 83 | 2 | ColumnPtr column_result = nullptr; | 84 | | | 85 | 2 | column_result = | 86 | 2 | Impl::constant_constant(column_left_ptr->template get_value<Impl::ResultType>(), | 87 | 2 | column_right_ptr->template get_value<Impl::ResultType>()); | 88 | | | 89 | 2 | return ColumnConst::create(std::move(column_result), column_left->size()); | 90 | 2 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE17constant_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 78 | 1 | ColumnPtr constant_constant(ColumnPtr column_left, ColumnPtr column_right) const { | 79 | 1 | const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get()); | 80 | 1 | const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get()); | 81 | 1 | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); | 82 | | | 83 | 1 | ColumnPtr column_result = nullptr; | 84 | | | 85 | 1 | column_result = | 86 | 1 | Impl::constant_constant(column_left_ptr->template get_value<Impl::ResultType>(), | 87 | 1 | column_right_ptr->template get_value<Impl::ResultType>()); | 88 | | | 89 | 1 | return ColumnConst::create(std::move(column_result), column_left->size()); | 90 | 1 | } |
|
91 | | |
92 | 7 | ColumnPtr vector_constant(ColumnPtr column_left, ColumnPtr column_right) const { |
93 | 7 | const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get()); |
94 | 7 | DCHECK(column_right_ptr != nullptr); |
95 | | |
96 | 7 | return Impl::vector_constant(column_left->get_ptr(), |
97 | 7 | column_right_ptr->template get_value<Impl::ResultType>()); |
98 | 7 | } Unexecuted instantiation: _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Unexecuted instantiation: _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 92 | 5 | ColumnPtr vector_constant(ColumnPtr column_left, ColumnPtr column_right) const { | 93 | 5 | const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get()); | 94 | 5 | DCHECK(column_right_ptr != nullptr); | 95 | | | 96 | 5 | return Impl::vector_constant(column_left->get_ptr(), | 97 | 5 | column_right_ptr->template get_value<Impl::ResultType>()); | 98 | 5 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 92 | 1 | ColumnPtr vector_constant(ColumnPtr column_left, ColumnPtr column_right) const { | 93 | 1 | const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get()); | 94 | 1 | DCHECK(column_right_ptr != nullptr); | 95 | | | 96 | 1 | return Impl::vector_constant(column_left->get_ptr(), | 97 | 1 | column_right_ptr->template get_value<Impl::ResultType>()); | 98 | 1 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 92 | 1 | ColumnPtr vector_constant(ColumnPtr column_left, ColumnPtr column_right) const { | 93 | 1 | const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get()); | 94 | 1 | DCHECK(column_right_ptr != nullptr); | 95 | | | 96 | 1 | return Impl::vector_constant(column_left->get_ptr(), | 97 | 1 | column_right_ptr->template get_value<Impl::ResultType>()); | 98 | 1 | } |
|
99 | | |
100 | 2 | ColumnPtr constant_vector(ColumnPtr column_left, ColumnPtr column_right) const { |
101 | 2 | const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get()); |
102 | 2 | DCHECK(column_left_ptr != nullptr); |
103 | | |
104 | 2 | return Impl::constant_vector(column_left_ptr->template get_value<Impl::ResultType>(), |
105 | 2 | column_right->get_ptr()); |
106 | 2 | } Unexecuted instantiation: _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Unexecuted instantiation: _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Unexecuted instantiation: _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 100 | 1 | ColumnPtr constant_vector(ColumnPtr column_left, ColumnPtr column_right) const { | 101 | 1 | const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get()); | 102 | 1 | DCHECK(column_left_ptr != nullptr); | 103 | | | 104 | 1 | return Impl::constant_vector(column_left_ptr->template get_value<Impl::ResultType>(), | 105 | 1 | column_right->get_ptr()); | 106 | 1 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 100 | 1 | ColumnPtr constant_vector(ColumnPtr column_left, ColumnPtr column_right) const { | 101 | 1 | const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get()); | 102 | 1 | DCHECK(column_left_ptr != nullptr); | 103 | | | 104 | 1 | return Impl::constant_vector(column_left_ptr->template get_value<Impl::ResultType>(), | 105 | 1 | column_right->get_ptr()); | 106 | 1 | } |
|
107 | | |
108 | 2.37k | ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const { |
109 | 2.37k | return Impl::vector_vector(column_left->get_ptr(), column_right->get_ptr()); |
110 | 2.37k | } _ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE3EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 108 | 25 | ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const { | 109 | 25 | return Impl::vector_vector(column_left->get_ptr(), column_right->get_ptr()); | 110 | 25 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE4EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 108 | 25 | ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const { | 109 | 25 | return Impl::vector_vector(column_left->get_ptr(), column_right->get_ptr()); | 110 | 25 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE5EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 108 | 33 | ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const { | 109 | 33 | return Impl::vector_vector(column_left->get_ptr(), column_right->get_ptr()); | 110 | 33 | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE6EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 108 | 2.20k | ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const { | 109 | 2.20k | return Impl::vector_vector(column_left->get_ptr(), column_right->get_ptr()); | 110 | 2.20k | } |
_ZNK5doris14FunctionIntDivINS_18DivideIntegralImplILNS_13PrimitiveTypeE7EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_ Line | Count | Source | 108 | 81 | ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const { | 109 | 81 | return Impl::vector_vector(column_left->get_ptr(), column_right->get_ptr()); | 110 | 81 | } |
|
111 | | }; |
112 | | |
113 | | template <PrimitiveType Type> |
114 | | struct DivideIntegralImpl { |
115 | | using Arg = typename PrimitiveTypeTraits<Type>::CppType; |
116 | | using ColumnType = typename PrimitiveTypeTraits<Type>::ColumnType; |
117 | | static constexpr PrimitiveType ResultType = Type; |
118 | | static constexpr bool is_signed_integer = std::is_signed_v<Arg> || std::is_same_v<Arg, Int128>; |
119 | | |
120 | 40 | static DataTypes get_variadic_argument_types() { |
121 | 40 | return {std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>(), |
122 | 40 | std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>()}; |
123 | 40 | } _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE3EE27get_variadic_argument_typesEv Line | Count | Source | 120 | 8 | static DataTypes get_variadic_argument_types() { | 121 | 8 | return {std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>(), | 122 | 8 | std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>()}; | 123 | 8 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE4EE27get_variadic_argument_typesEv Line | Count | Source | 120 | 8 | static DataTypes get_variadic_argument_types() { | 121 | 8 | return {std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>(), | 122 | 8 | std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>()}; | 123 | 8 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE5EE27get_variadic_argument_typesEv Line | Count | Source | 120 | 8 | static DataTypes get_variadic_argument_types() { | 121 | 8 | return {std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>(), | 122 | 8 | std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>()}; | 123 | 8 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE6EE27get_variadic_argument_typesEv Line | Count | Source | 120 | 8 | static DataTypes get_variadic_argument_types() { | 121 | 8 | return {std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>(), | 122 | 8 | std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>()}; | 123 | 8 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE7EE27get_variadic_argument_typesEv Line | Count | Source | 120 | 8 | static DataTypes get_variadic_argument_types() { | 121 | 8 | return {std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>(), | 122 | 8 | std::make_shared<typename PrimitiveTypeTraits<Type>::DataType>()}; | 123 | 8 | } |
|
124 | | |
125 | 12.3k | static bool division_leads_to_fpe(Arg a, Arg b) { |
126 | 12.3k | if constexpr (is_signed_integer) { |
127 | 12.3k | return b == -1 && a == std::numeric_limits<Arg>::min(); |
128 | | } else { |
129 | | return false; |
130 | | } |
131 | 12.3k | } _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE3EE21division_leads_to_fpeEaa Line | Count | Source | 125 | 127 | static bool division_leads_to_fpe(Arg a, Arg b) { | 126 | 127 | if constexpr (is_signed_integer) { | 127 | 127 | return b == -1 && a == std::numeric_limits<Arg>::min(); | 128 | | } else { | 129 | | return false; | 130 | | } | 131 | 127 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE4EE21division_leads_to_fpeEss Line | Count | Source | 125 | 148 | static bool division_leads_to_fpe(Arg a, Arg b) { | 126 | 148 | if constexpr (is_signed_integer) { | 127 | 148 | return b == -1 && a == std::numeric_limits<Arg>::min(); | 128 | | } else { | 129 | | return false; | 130 | | } | 131 | 148 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE5EE21division_leads_to_fpeEii Line | Count | Source | 125 | 204 | static bool division_leads_to_fpe(Arg a, Arg b) { | 126 | 204 | if constexpr (is_signed_integer) { | 127 | 204 | return b == -1 && a == std::numeric_limits<Arg>::min(); | 128 | | } else { | 129 | | return false; | 130 | | } | 131 | 204 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE6EE21division_leads_to_fpeEll Line | Count | Source | 125 | 11.3k | static bool division_leads_to_fpe(Arg a, Arg b) { | 126 | 11.3k | if constexpr (is_signed_integer) { | 127 | 11.3k | return b == -1 && a == std::numeric_limits<Arg>::min(); | 128 | | } else { | 129 | | return false; | 130 | | } | 131 | 11.3k | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE7EE21division_leads_to_fpeEnn Line | Count | Source | 125 | 461 | static bool division_leads_to_fpe(Arg a, Arg b) { | 126 | 461 | if constexpr (is_signed_integer) { | 127 | 461 | return b == -1 && a == std::numeric_limits<Arg>::min(); | 128 | | } else { | 129 | | return false; | 130 | | } | 131 | 461 | } |
|
132 | | |
133 | | static void apply(const typename ColumnType::Container& a, Arg b, |
134 | | typename PrimitiveTypeTraits<ResultType>::ColumnType::Container& c, |
135 | 7 | PaddedPODArray<UInt8>& null_map) { |
136 | 7 | size_t size = c.size(); |
137 | 7 | UInt8 is_null = b == 0; |
138 | 7 | memset(null_map.data(), is_null, size); |
139 | | |
140 | 7 | if (!is_null) { |
141 | 7 | if constexpr (is_signed_integer) { |
142 | 7 | if (b == -1) { |
143 | 4 | for (size_t i = 0; i < size; i++) { |
144 | 2 | null_map[i] = division_leads_to_fpe(a[i], b); |
145 | 2 | if (!null_map[i]) { |
146 | 0 | c[i] = typename PrimitiveTypeTraits<ResultType>::CppType(a[i] / b); |
147 | 2 | } else { |
148 | 2 | c[i] = {}; |
149 | 2 | } |
150 | 2 | } |
151 | 2 | return; |
152 | 2 | } |
153 | 7 | } |
154 | | if constexpr (!std::is_floating_point_v<Arg> && !std::is_same_v<Arg, Int128> && |
155 | 6 | !std::is_same_v<Arg, Int8> && !std::is_same_v<Arg, UInt8>) { |
156 | 6 | const auto divider = libdivide::divider<Arg>(Arg(b)); |
157 | 65 | for (size_t i = 0; i < size; i++) { |
158 | 59 | c[i] = a[i] / divider; |
159 | 59 | } |
160 | 6 | } else { |
161 | 1 | for (size_t i = 0; i < size; i++) { |
162 | 0 | c[i] = typename PrimitiveTypeTraits<ResultType>::CppType(a[i] / b); |
163 | 0 | } |
164 | 1 | } |
165 | 7 | } |
166 | 7 | } Unexecuted instantiation: _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE3EE5applyERKNS_8PODArrayIaLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEaRS7_RNS3_IhLm4096ES6_Lm16ELm15EEE Unexecuted instantiation: _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE4EE5applyERKNS_8PODArrayIsLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEsRS7_RNS3_IhLm4096ES6_Lm16ELm15EEE _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE5EE5applyERKNS_8PODArrayIiLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEiRS7_RNS3_IhLm4096ES6_Lm16ELm15EEE Line | Count | Source | 135 | 5 | PaddedPODArray<UInt8>& null_map) { | 136 | 5 | size_t size = c.size(); | 137 | 5 | UInt8 is_null = b == 0; | 138 | 5 | memset(null_map.data(), is_null, size); | 139 | | | 140 | 5 | if (!is_null) { | 141 | 5 | if constexpr (is_signed_integer) { | 142 | 5 | if (b == -1) { | 143 | 0 | for (size_t i = 0; i < size; i++) { | 144 | 0 | null_map[i] = division_leads_to_fpe(a[i], b); | 145 | 0 | if (!null_map[i]) { | 146 | 0 | c[i] = typename PrimitiveTypeTraits<ResultType>::CppType(a[i] / b); | 147 | 0 | } else { | 148 | 0 | c[i] = {}; | 149 | 0 | } | 150 | 0 | } | 151 | 0 | return; | 152 | 0 | } | 153 | 5 | } | 154 | | if constexpr (!std::is_floating_point_v<Arg> && !std::is_same_v<Arg, Int128> && | 155 | 5 | !std::is_same_v<Arg, Int8> && !std::is_same_v<Arg, UInt8>) { | 156 | 5 | const auto divider = libdivide::divider<Arg>(Arg(b)); | 157 | 64 | for (size_t i = 0; i < size; i++) { | 158 | 59 | c[i] = a[i] / divider; | 159 | 59 | } | 160 | | } else { | 161 | | for (size_t i = 0; i < size; i++) { | 162 | | c[i] = typename PrimitiveTypeTraits<ResultType>::CppType(a[i] / b); | 163 | | } | 164 | | } | 165 | 5 | } | 166 | 5 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE6EE5applyERKNS_8PODArrayIlLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEElRS7_RNS3_IhLm4096ES6_Lm16ELm15EEE Line | Count | Source | 135 | 1 | PaddedPODArray<UInt8>& null_map) { | 136 | 1 | size_t size = c.size(); | 137 | 1 | UInt8 is_null = b == 0; | 138 | 1 | memset(null_map.data(), is_null, size); | 139 | | | 140 | 1 | if (!is_null) { | 141 | 1 | if constexpr (is_signed_integer) { | 142 | 1 | if (b == -1) { | 143 | 2 | for (size_t i = 0; i < size; i++) { | 144 | 1 | null_map[i] = division_leads_to_fpe(a[i], b); | 145 | 1 | if (!null_map[i]) { | 146 | 0 | c[i] = typename PrimitiveTypeTraits<ResultType>::CppType(a[i] / b); | 147 | 1 | } else { | 148 | 1 | c[i] = {}; | 149 | 1 | } | 150 | 1 | } | 151 | 1 | return; | 152 | 1 | } | 153 | 1 | } | 154 | | if constexpr (!std::is_floating_point_v<Arg> && !std::is_same_v<Arg, Int128> && | 155 | 1 | !std::is_same_v<Arg, Int8> && !std::is_same_v<Arg, UInt8>) { | 156 | 1 | const auto divider = libdivide::divider<Arg>(Arg(b)); | 157 | 1 | for (size_t i = 0; i < size; i++) { | 158 | 0 | c[i] = a[i] / divider; | 159 | 0 | } | 160 | | } else { | 161 | | for (size_t i = 0; i < size; i++) { | 162 | | c[i] = typename PrimitiveTypeTraits<ResultType>::CppType(a[i] / b); | 163 | | } | 164 | | } | 165 | 1 | } | 166 | 1 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE7EE5applyERKNS_8PODArrayInLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEnRS7_RNS3_IhLm4096ES6_Lm16ELm15EEE Line | Count | Source | 135 | 1 | PaddedPODArray<UInt8>& null_map) { | 136 | 1 | size_t size = c.size(); | 137 | 1 | UInt8 is_null = b == 0; | 138 | 1 | memset(null_map.data(), is_null, size); | 139 | | | 140 | 1 | if (!is_null) { | 141 | 1 | if constexpr (is_signed_integer) { | 142 | 1 | if (b == -1) { | 143 | 2 | for (size_t i = 0; i < size; i++) { | 144 | 1 | null_map[i] = division_leads_to_fpe(a[i], b); | 145 | 1 | if (!null_map[i]) { | 146 | 0 | c[i] = typename PrimitiveTypeTraits<ResultType>::CppType(a[i] / b); | 147 | 1 | } else { | 148 | 1 | c[i] = {}; | 149 | 1 | } | 150 | 1 | } | 151 | 1 | return; | 152 | 1 | } | 153 | 1 | } | 154 | | if constexpr (!std::is_floating_point_v<Arg> && !std::is_same_v<Arg, Int128> && | 155 | | !std::is_same_v<Arg, Int8> && !std::is_same_v<Arg, UInt8>) { | 156 | | const auto divider = libdivide::divider<Arg>(Arg(b)); | 157 | | for (size_t i = 0; i < size; i++) { | 158 | | c[i] = a[i] / divider; | 159 | | } | 160 | 1 | } else { | 161 | 1 | for (size_t i = 0; i < size; i++) { | 162 | 0 | c[i] = typename PrimitiveTypeTraits<ResultType>::CppType(a[i] / b); | 163 | 0 | } | 164 | 1 | } | 165 | 1 | } | 166 | 1 | } |
|
167 | | |
168 | | static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(Arg a, Arg b, |
169 | 14.5k | UInt8& is_null) { |
170 | 14.5k | is_null = b == 0 || division_leads_to_fpe(a, b); |
171 | 14.5k | if (is_null) { |
172 | 2.19k | return {}; |
173 | 2.19k | } |
174 | 12.3k | return typename PrimitiveTypeTraits<ResultType>::CppType(a / b); |
175 | 14.5k | } _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE3EE5applyEaaRh Line | Count | Source | 169 | 159 | UInt8& is_null) { | 170 | 159 | is_null = b == 0 || division_leads_to_fpe(a, b); | 171 | 159 | if (is_null) { | 172 | 33 | return {}; | 173 | 33 | } | 174 | 126 | return typename PrimitiveTypeTraits<ResultType>::CppType(a / b); | 175 | 159 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE4EE5applyEssRh Line | Count | Source | 169 | 151 | UInt8& is_null) { | 170 | 151 | is_null = b == 0 || division_leads_to_fpe(a, b); | 171 | 151 | if (is_null) { | 172 | 4 | return {}; | 173 | 4 | } | 174 | 147 | return typename PrimitiveTypeTraits<ResultType>::CppType(a / b); | 175 | 151 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE5EE5applyEiiRh Line | Count | Source | 169 | 208 | UInt8& is_null) { | 170 | 208 | is_null = b == 0 || division_leads_to_fpe(a, b); | 171 | 208 | if (is_null) { | 172 | 5 | return {}; | 173 | 5 | } | 174 | 203 | return typename PrimitiveTypeTraits<ResultType>::CppType(a / b); | 175 | 208 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE6EE5applyEllRh Line | Count | Source | 169 | 13.5k | UInt8& is_null) { | 170 | 13.5k | is_null = b == 0 || division_leads_to_fpe(a, b); | 171 | 13.5k | if (is_null) { | 172 | 2.11k | return {}; | 173 | 2.11k | } | 174 | 11.3k | return typename PrimitiveTypeTraits<ResultType>::CppType(a / b); | 175 | 13.5k | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE7EE5applyEnnRh Line | Count | Source | 169 | 494 | UInt8& is_null) { | 170 | 494 | is_null = b == 0 || division_leads_to_fpe(a, b); | 171 | 494 | if (is_null) { | 172 | 37 | return {}; | 173 | 37 | } | 174 | 457 | return typename PrimitiveTypeTraits<ResultType>::CppType(a / b); | 175 | 494 | } |
|
176 | | |
177 | 25 | static ColumnPtr constant_constant(Arg a, Arg b) { |
178 | 25 | auto column_result = ColumnType ::create(1); |
179 | | |
180 | 25 | auto null_map = ColumnUInt8::create(1, 0); |
181 | 25 | column_result->get_element(0) = apply(a, b, null_map->get_element(0)); |
182 | 25 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); |
183 | 25 | } _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE3EE17constant_constantEaa Line | Count | Source | 177 | 10 | static ColumnPtr constant_constant(Arg a, Arg b) { | 178 | 10 | auto column_result = ColumnType ::create(1); | 179 | | | 180 | 10 | auto null_map = ColumnUInt8::create(1, 0); | 181 | 10 | column_result->get_element(0) = apply(a, b, null_map->get_element(0)); | 182 | 10 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 183 | 10 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE4EE17constant_constantEss Line | Count | Source | 177 | 2 | static ColumnPtr constant_constant(Arg a, Arg b) { | 178 | 2 | auto column_result = ColumnType ::create(1); | 179 | | | 180 | 2 | auto null_map = ColumnUInt8::create(1, 0); | 181 | 2 | column_result->get_element(0) = apply(a, b, null_map->get_element(0)); | 182 | 2 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 183 | 2 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE5EE17constant_constantEii Line | Count | Source | 177 | 10 | static ColumnPtr constant_constant(Arg a, Arg b) { | 178 | 10 | auto column_result = ColumnType ::create(1); | 179 | | | 180 | 10 | auto null_map = ColumnUInt8::create(1, 0); | 181 | 10 | column_result->get_element(0) = apply(a, b, null_map->get_element(0)); | 182 | 10 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 183 | 10 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE6EE17constant_constantEll Line | Count | Source | 177 | 2 | static ColumnPtr constant_constant(Arg a, Arg b) { | 178 | 2 | auto column_result = ColumnType ::create(1); | 179 | | | 180 | 2 | auto null_map = ColumnUInt8::create(1, 0); | 181 | 2 | column_result->get_element(0) = apply(a, b, null_map->get_element(0)); | 182 | 2 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 183 | 2 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE7EE17constant_constantEnn Line | Count | Source | 177 | 1 | static ColumnPtr constant_constant(Arg a, Arg b) { | 178 | 1 | auto column_result = ColumnType ::create(1); | 179 | | | 180 | 1 | auto null_map = ColumnUInt8::create(1, 0); | 181 | 1 | column_result->get_element(0) = apply(a, b, null_map->get_element(0)); | 182 | 1 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 183 | 1 | } |
|
184 | | |
185 | 7 | static ColumnPtr vector_constant(ColumnPtr column_left, Arg b) { |
186 | 7 | const auto* column_left_ptr = assert_cast<const ColumnType*>(column_left.get()); |
187 | 7 | auto column_result = ColumnType::create(column_left->size()); |
188 | 7 | DCHECK(column_left_ptr != nullptr); |
189 | | |
190 | 7 | auto null_map = ColumnUInt8::create(column_left->size(), 0); |
191 | 7 | apply(column_left_ptr->get_data(), b, column_result->get_data(), null_map->get_data()); |
192 | 7 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); |
193 | 7 | } Unexecuted instantiation: _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE3EE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS4_EEa Unexecuted instantiation: _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE4EE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS4_EEs _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE5EE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS4_EEi Line | Count | Source | 185 | 5 | static ColumnPtr vector_constant(ColumnPtr column_left, Arg b) { | 186 | 5 | const auto* column_left_ptr = assert_cast<const ColumnType*>(column_left.get()); | 187 | 5 | auto column_result = ColumnType::create(column_left->size()); | 188 | 5 | DCHECK(column_left_ptr != nullptr); | 189 | | | 190 | 5 | auto null_map = ColumnUInt8::create(column_left->size(), 0); | 191 | 5 | apply(column_left_ptr->get_data(), b, column_result->get_data(), null_map->get_data()); | 192 | 5 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 193 | 5 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE6EE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS4_EEl Line | Count | Source | 185 | 1 | static ColumnPtr vector_constant(ColumnPtr column_left, Arg b) { | 186 | 1 | const auto* column_left_ptr = assert_cast<const ColumnType*>(column_left.get()); | 187 | 1 | auto column_result = ColumnType::create(column_left->size()); | 188 | 1 | DCHECK(column_left_ptr != nullptr); | 189 | | | 190 | 1 | auto null_map = ColumnUInt8::create(column_left->size(), 0); | 191 | 1 | apply(column_left_ptr->get_data(), b, column_result->get_data(), null_map->get_data()); | 192 | 1 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 193 | 1 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE7EE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS4_EEn Line | Count | Source | 185 | 1 | static ColumnPtr vector_constant(ColumnPtr column_left, Arg b) { | 186 | 1 | const auto* column_left_ptr = assert_cast<const ColumnType*>(column_left.get()); | 187 | 1 | auto column_result = ColumnType::create(column_left->size()); | 188 | 1 | DCHECK(column_left_ptr != nullptr); | 189 | | | 190 | 1 | auto null_map = ColumnUInt8::create(column_left->size(), 0); | 191 | 1 | apply(column_left_ptr->get_data(), b, column_result->get_data(), null_map->get_data()); | 192 | 1 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 193 | 1 | } |
|
194 | | |
195 | 2 | static ColumnPtr constant_vector(Arg a, ColumnPtr column_right) { |
196 | 2 | const auto* column_right_ptr = assert_cast<const ColumnType*>(column_right.get()); |
197 | 2 | auto column_result = ColumnType::create(column_right->size()); |
198 | 2 | DCHECK(column_right_ptr != nullptr); |
199 | | |
200 | 2 | auto null_map = ColumnUInt8::create(column_right->size(), 0); |
201 | 2 | auto& b = column_right_ptr->get_data(); |
202 | 2 | auto& c = column_result->get_data(); |
203 | 2 | auto& n = null_map->get_data(); |
204 | 2 | size_t size = b.size(); |
205 | 4 | for (size_t i = 0; i < size; ++i) { |
206 | 2 | c[i] = apply(a, b[i], n[i]); |
207 | 2 | } |
208 | 2 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); |
209 | 2 | } Unexecuted instantiation: _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE3EE15constant_vectorEaNS_3COWINS_7IColumnEE13immutable_ptrIS4_EE Unexecuted instantiation: _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE4EE15constant_vectorEsNS_3COWINS_7IColumnEE13immutable_ptrIS4_EE Unexecuted instantiation: _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE5EE15constant_vectorEiNS_3COWINS_7IColumnEE13immutable_ptrIS4_EE _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE6EE15constant_vectorElNS_3COWINS_7IColumnEE13immutable_ptrIS4_EE Line | Count | Source | 195 | 1 | static ColumnPtr constant_vector(Arg a, ColumnPtr column_right) { | 196 | 1 | const auto* column_right_ptr = assert_cast<const ColumnType*>(column_right.get()); | 197 | 1 | auto column_result = ColumnType::create(column_right->size()); | 198 | 1 | DCHECK(column_right_ptr != nullptr); | 199 | | | 200 | 1 | auto null_map = ColumnUInt8::create(column_right->size(), 0); | 201 | 1 | auto& b = column_right_ptr->get_data(); | 202 | 1 | auto& c = column_result->get_data(); | 203 | 1 | auto& n = null_map->get_data(); | 204 | 1 | size_t size = b.size(); | 205 | 2 | for (size_t i = 0; i < size; ++i) { | 206 | 1 | c[i] = apply(a, b[i], n[i]); | 207 | 1 | } | 208 | 1 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 209 | 1 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE7EE15constant_vectorEnNS_3COWINS_7IColumnEE13immutable_ptrIS4_EE Line | Count | Source | 195 | 1 | static ColumnPtr constant_vector(Arg a, ColumnPtr column_right) { | 196 | 1 | const auto* column_right_ptr = assert_cast<const ColumnType*>(column_right.get()); | 197 | 1 | auto column_result = ColumnType::create(column_right->size()); | 198 | 1 | DCHECK(column_right_ptr != nullptr); | 199 | | | 200 | 1 | auto null_map = ColumnUInt8::create(column_right->size(), 0); | 201 | 1 | auto& b = column_right_ptr->get_data(); | 202 | 1 | auto& c = column_result->get_data(); | 203 | 1 | auto& n = null_map->get_data(); | 204 | 1 | size_t size = b.size(); | 205 | 2 | for (size_t i = 0; i < size; ++i) { | 206 | 1 | c[i] = apply(a, b[i], n[i]); | 207 | 1 | } | 208 | 1 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 209 | 1 | } |
|
210 | | |
211 | 2.37k | static ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) { |
212 | 2.37k | const auto* column_left_ptr = assert_cast<const ColumnType*>(column_left.get()); |
213 | 2.37k | const auto* column_right_ptr = assert_cast<const ColumnType*>(column_right.get()); |
214 | | |
215 | 2.37k | auto column_result = ColumnType::create(column_left->size()); |
216 | 2.37k | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); |
217 | | |
218 | 2.37k | auto null_map = ColumnUInt8::create(column_result->size(), 0); |
219 | 2.37k | auto& a = column_left_ptr->get_data(); |
220 | 2.37k | auto& b = column_right_ptr->get_data(); |
221 | 2.37k | auto& c = column_result->get_data(); |
222 | 2.37k | auto& n = null_map->get_data(); |
223 | 2.37k | size_t size = a.size(); |
224 | 16.8k | for (size_t i = 0; i < size; ++i) { |
225 | 14.4k | c[i] = apply(a[i], b[i], n[i]); |
226 | 14.4k | } |
227 | 2.37k | return ColumnNullable::create(std::move(column_result), std::move(null_map)); |
228 | 2.37k | } _ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE3EE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_ Line | Count | Source | 211 | 25 | static ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) { | 212 | 25 | const auto* column_left_ptr = assert_cast<const ColumnType*>(column_left.get()); | 213 | 25 | const auto* column_right_ptr = assert_cast<const ColumnType*>(column_right.get()); | 214 | | | 215 | 25 | auto column_result = ColumnType::create(column_left->size()); | 216 | 25 | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); | 217 | | | 218 | 25 | auto null_map = ColumnUInt8::create(column_result->size(), 0); | 219 | 25 | auto& a = column_left_ptr->get_data(); | 220 | 25 | auto& b = column_right_ptr->get_data(); | 221 | 25 | auto& c = column_result->get_data(); | 222 | 25 | auto& n = null_map->get_data(); | 223 | 25 | size_t size = a.size(); | 224 | 174 | for (size_t i = 0; i < size; ++i) { | 225 | 149 | c[i] = apply(a[i], b[i], n[i]); | 226 | 149 | } | 227 | 25 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 228 | 25 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE4EE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_ Line | Count | Source | 211 | 25 | static ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) { | 212 | 25 | const auto* column_left_ptr = assert_cast<const ColumnType*>(column_left.get()); | 213 | 25 | const auto* column_right_ptr = assert_cast<const ColumnType*>(column_right.get()); | 214 | | | 215 | 25 | auto column_result = ColumnType::create(column_left->size()); | 216 | 25 | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); | 217 | | | 218 | 25 | auto null_map = ColumnUInt8::create(column_result->size(), 0); | 219 | 25 | auto& a = column_left_ptr->get_data(); | 220 | 25 | auto& b = column_right_ptr->get_data(); | 221 | 25 | auto& c = column_result->get_data(); | 222 | 25 | auto& n = null_map->get_data(); | 223 | 25 | size_t size = a.size(); | 224 | 174 | for (size_t i = 0; i < size; ++i) { | 225 | 149 | c[i] = apply(a[i], b[i], n[i]); | 226 | 149 | } | 227 | 25 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 228 | 25 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE5EE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_ Line | Count | Source | 211 | 33 | static ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) { | 212 | 33 | const auto* column_left_ptr = assert_cast<const ColumnType*>(column_left.get()); | 213 | 33 | const auto* column_right_ptr = assert_cast<const ColumnType*>(column_right.get()); | 214 | | | 215 | 33 | auto column_result = ColumnType::create(column_left->size()); | 216 | 33 | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); | 217 | | | 218 | 33 | auto null_map = ColumnUInt8::create(column_result->size(), 0); | 219 | 33 | auto& a = column_left_ptr->get_data(); | 220 | 33 | auto& b = column_right_ptr->get_data(); | 221 | 33 | auto& c = column_result->get_data(); | 222 | 33 | auto& n = null_map->get_data(); | 223 | 33 | size_t size = a.size(); | 224 | 231 | for (size_t i = 0; i < size; ++i) { | 225 | 198 | c[i] = apply(a[i], b[i], n[i]); | 226 | 198 | } | 227 | 33 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 228 | 33 | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE6EE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_ Line | Count | Source | 211 | 2.21k | static ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) { | 212 | 2.21k | const auto* column_left_ptr = assert_cast<const ColumnType*>(column_left.get()); | 213 | 2.21k | const auto* column_right_ptr = assert_cast<const ColumnType*>(column_right.get()); | 214 | | | 215 | 2.21k | auto column_result = ColumnType::create(column_left->size()); | 216 | 2.21k | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); | 217 | | | 218 | 2.21k | auto null_map = ColumnUInt8::create(column_result->size(), 0); | 219 | 2.21k | auto& a = column_left_ptr->get_data(); | 220 | 2.21k | auto& b = column_right_ptr->get_data(); | 221 | 2.21k | auto& c = column_result->get_data(); | 222 | 2.21k | auto& n = null_map->get_data(); | 223 | 2.21k | size_t size = a.size(); | 224 | 15.7k | for (size_t i = 0; i < size; ++i) { | 225 | 13.5k | c[i] = apply(a[i], b[i], n[i]); | 226 | 13.5k | } | 227 | 2.21k | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 228 | 2.21k | } |
_ZN5doris18DivideIntegralImplILNS_13PrimitiveTypeE7EE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_ Line | Count | Source | 211 | 81 | static ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) { | 212 | 81 | const auto* column_left_ptr = assert_cast<const ColumnType*>(column_left.get()); | 213 | 81 | const auto* column_right_ptr = assert_cast<const ColumnType*>(column_right.get()); | 214 | | | 215 | 81 | auto column_result = ColumnType::create(column_left->size()); | 216 | 81 | DCHECK(column_left_ptr != nullptr && column_right_ptr != nullptr); | 217 | | | 218 | 81 | auto null_map = ColumnUInt8::create(column_result->size(), 0); | 219 | 81 | auto& a = column_left_ptr->get_data(); | 220 | 81 | auto& b = column_right_ptr->get_data(); | 221 | 81 | auto& c = column_result->get_data(); | 222 | 81 | auto& n = null_map->get_data(); | 223 | 81 | size_t size = a.size(); | 224 | 573 | for (size_t i = 0; i < size; ++i) { | 225 | 492 | c[i] = apply(a[i], b[i], n[i]); | 226 | 492 | } | 227 | 81 | return ColumnNullable::create(std::move(column_result), std::move(null_map)); | 228 | 81 | } |
|
229 | | }; |
230 | | |
231 | 8 | void register_function_int_div(SimpleFunctionFactory& factory) { |
232 | 8 | factory.register_function<FunctionIntDiv<DivideIntegralImpl<TYPE_TINYINT>>>(); |
233 | 8 | factory.register_function<FunctionIntDiv<DivideIntegralImpl<TYPE_SMALLINT>>>(); |
234 | 8 | factory.register_function<FunctionIntDiv<DivideIntegralImpl<TYPE_INT>>>(); |
235 | 8 | factory.register_function<FunctionIntDiv<DivideIntegralImpl<TYPE_BIGINT>>>(); |
236 | 8 | factory.register_function<FunctionIntDiv<DivideIntegralImpl<TYPE_LARGEINT>>>(); |
237 | 8 | } |
238 | | |
239 | | } // namespace doris |