Coverage Report

Created: 2024-11-21 23:27

/root/doris/be/src/vec/functions/math.cpp
Line
Count
Source (jump to first uncovered line)
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 <cstdint>
19
#include <cstring>
20
21
// IWYU pragma: no_include <bits/std_abs.h>
22
#include <dlfcn.h>
23
24
#include <cmath>
25
#include <string>
26
#include <type_traits>
27
28
#include "common/status.h"
29
#include "vec/columns/column.h"
30
#include "vec/columns/column_string.h"
31
#include "vec/columns/column_vector.h"
32
#include "vec/columns/columns_number.h"
33
#include "vec/core/types.h"
34
#include "vec/data_types/data_type_string.h"
35
#include "vec/data_types/number_traits.h"
36
#include "vec/functions/function_binary_arithmetic.h"
37
#include "vec/functions/function_const.h"
38
#include "vec/functions/function_math_log.h"
39
#include "vec/functions/function_math_unary.h"
40
#include "vec/functions/function_math_unary_alway_nullable.h"
41
#include "vec/functions/function_string.h"
42
#include "vec/functions/function_totype.h"
43
#include "vec/functions/function_unary_arithmetic.h"
44
#include "vec/functions/simple_function_factory.h"
45
46
namespace doris {
47
namespace vectorized {
48
struct LnImpl;
49
struct Log10Impl;
50
struct Log2Impl;
51
} // namespace vectorized
52
} // namespace doris
53
54
namespace doris::vectorized {
55
struct AcosName {
56
    static constexpr auto name = "acos";
57
    // https://dev.mysql.com/doc/refman/8.4/en/mathematical-functions.html#function_acos
58
4
    static constexpr bool is_invalid_input(Float64 x) { return x < -1 || x > 1; }
59
};
60
using FunctionAcos =
61
        FunctionMathUnaryAlwayNullable<UnaryFunctionPlainAlwayNullable<AcosName, std::acos>>;
62
63
struct AsinName {
64
    static constexpr auto name = "asin";
65
    // https://dev.mysql.com/doc/refman/8.4/en/mathematical-functions.html#function_asin
66
4
    static constexpr bool is_invalid_input(Float64 x) { return x < -1 || x > 1; }
67
};
68
using FunctionAsin =
69
        FunctionMathUnaryAlwayNullable<UnaryFunctionPlainAlwayNullable<AsinName, std::asin>>;
70
71
struct AtanName {
72
    static constexpr auto name = "atan";
73
};
74
using FunctionAtan = FunctionMathUnary<UnaryFunctionPlain<AtanName, std::atan>>;
75
76
template <typename A, typename B>
77
struct Atan2Impl {
78
    using ResultType = double;
79
    static const constexpr bool allow_decimal = false;
80
81
    template <typename type>
82
21
    static inline double apply(A a, B b) {
83
21
        return std::atan2((double)a, (double)b);
84
21
    }
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIhhE5applyIdEEdhh
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIhaE5applyIdEEdha
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIhsE5applyIdEEdhs
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIhiE5applyIdEEdhi
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIhlE5applyIdEEdhl
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIhnE5applyIdEEdhn
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIhfE5applyIdEEdhf
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIhdE5applyIdEEdhd
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIahE5applyIdEEdah
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIaaE5applyIdEEdaa
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIasE5applyIdEEdas
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIaiE5applyIdEEdai
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIalE5applyIdEEdal
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIanE5applyIdEEdan
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIafE5applyIdEEdaf
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIadE5applyIdEEdad
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIshE5applyIdEEdsh
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIsaE5applyIdEEdsa
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIssE5applyIdEEdss
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIsiE5applyIdEEdsi
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIslE5applyIdEEdsl
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIsnE5applyIdEEdsn
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIsfE5applyIdEEdsf
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIsdE5applyIdEEdsd
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIihE5applyIdEEdih
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIiaE5applyIdEEdia
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIisE5applyIdEEdis
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIiiE5applyIdEEdii
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIilE5applyIdEEdil
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIinE5applyIdEEdin
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIifE5applyIdEEdif
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIidE5applyIdEEdid
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIlhE5applyIdEEdlh
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIlaE5applyIdEEdla
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIlsE5applyIdEEdls
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIliE5applyIdEEdli
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIllE5applyIdEEdll
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIlnE5applyIdEEdln
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIlfE5applyIdEEdlf
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIldE5applyIdEEdld
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplInhE5applyIdEEdnh
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplInaE5applyIdEEdna
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplInsE5applyIdEEdns
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIniE5applyIdEEdni
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplInlE5applyIdEEdnl
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplInnE5applyIdEEdnn
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplInfE5applyIdEEdnf
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIndE5applyIdEEdnd
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIfhE5applyIdEEdfh
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIfaE5applyIdEEdfa
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIfsE5applyIdEEdfs
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIfiE5applyIdEEdfi
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIflE5applyIdEEdfl
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIfnE5applyIdEEdfn
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIffE5applyIdEEdff
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIfdE5applyIdEEdfd
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIdhE5applyIdEEddh
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIdaE5applyIdEEdda
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIdsE5applyIdEEdds
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIdiE5applyIdEEddi
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIdlE5applyIdEEddl
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIdnE5applyIdEEddn
Unexecuted instantiation: _ZN5doris10vectorized9Atan2ImplIdfE5applyIdEEddf
_ZN5doris10vectorized9Atan2ImplIddE5applyIdEEddd
Line
Count
Source
82
21
    static inline double apply(A a, B b) {
83
21
        return std::atan2((double)a, (double)b);
84
21
    }
85
};
86
struct Atan2Name {
87
    static constexpr auto name = "atan2";
88
};
89
using FunctionAtan2 = FunctionBinaryArithmetic<Atan2Impl, Atan2Name, false>;
90
91
struct CosName {
92
    static constexpr auto name = "cos";
93
};
94
using FunctionCos = FunctionMathUnary<UnaryFunctionPlain<CosName, std::cos>>;
95
96
struct CoshName {
97
    static constexpr auto name = "cosh";
98
};
99
using FunctionCosh = FunctionMathUnary<UnaryFunctionPlain<CoshName, std::cosh>>;
100
101
struct EImpl {
102
    static constexpr auto name = "e";
103
    static constexpr double value = 2.7182818284590452353602874713526624977572470;
104
};
105
using FunctionE = FunctionMathConstFloat64<EImpl>;
106
107
struct PiImpl {
108
    static constexpr auto name = "pi";
109
    static constexpr double value = 3.1415926535897932384626433832795028841971693;
110
};
111
using FunctionPi = FunctionMathConstFloat64<PiImpl>;
112
113
struct ExpName {
114
    static constexpr auto name = "exp";
115
};
116
using FunctionExp = FunctionMathUnary<UnaryFunctionPlain<ExpName, std::exp>>;
117
118
struct LogName {
119
    static constexpr auto name = "log";
120
};
121
122
template <typename A, typename B>
123
struct LogImpl {
124
    using ResultType = Float64;
125
    using Traits = NumberTraits::BinaryOperatorTraits<A, B>;
126
127
    static const constexpr bool allow_decimal = false;
128
    static constexpr double EPSILON = 1e-9;
129
130
    template <typename Result = ResultType>
131
    static void apply(const typename Traits::ArrayA& a, B b,
132
                      typename ColumnVector<Result>::Container& c,
133
0
                      typename Traits::ArrayNull& null_map) {
134
0
        size_t size = c.size();
135
0
        UInt8 is_null = b <= 0;
136
0
        memset(null_map.data(), is_null, size);
137
138
0
        if (!is_null) {
139
0
            for (size_t i = 0; i < size; i++) {
140
0
                if (a[i] <= 0 || std::fabs(a[i] - 1.0) < EPSILON) {
141
0
                    null_map[i] = 1;
142
0
                } else {
143
0
                    c[i] = static_cast<Float64>(std::log(static_cast<Float64>(b)) /
144
0
                                                std::log(static_cast<Float64>(a[i])));
145
0
                }
146
0
            }
147
0
        }
148
0
    }
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhhE5applyIdEEvRKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEhRNS0_12ColumnVectorIT_E9ContainerERS8_
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhaE5applyIdEEvRKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEaRNS0_12ColumnVectorIT_E9ContainerERS8_
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhsE5applyIdEEvRKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEsRNS0_12ColumnVectorIT_E9ContainerERS8_
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhiE5applyIdEEvRKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEiRNS0_12ColumnVectorIT_E9ContainerERS8_
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhlE5applyIdEEvRKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEElRNS0_12ColumnVectorIT_E9ContainerERS8_
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhnE5applyIdEEvRKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEnRNS0_12ColumnVectorIT_E9ContainerERS8_
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhfE5applyIdEEvRKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEfRNS0_12ColumnVectorIT_E9ContainerERS8_
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhdE5applyIdEEvRKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEdRNS0_12ColumnVectorIT_E9ContainerERS8_
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIahE5applyIdEEvRKNS0_8PODArrayIaLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEhRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIaaE5applyIdEEvRKNS0_8PODArrayIaLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEaRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIasE5applyIdEEvRKNS0_8PODArrayIaLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEsRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIaiE5applyIdEEvRKNS0_8PODArrayIaLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEiRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIalE5applyIdEEvRKNS0_8PODArrayIaLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEElRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIanE5applyIdEEvRKNS0_8PODArrayIaLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEnRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIafE5applyIdEEvRKNS0_8PODArrayIaLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEfRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIadE5applyIdEEvRKNS0_8PODArrayIaLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEdRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIshE5applyIdEEvRKNS0_8PODArrayIsLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEhRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIsaE5applyIdEEvRKNS0_8PODArrayIsLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEaRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIssE5applyIdEEvRKNS0_8PODArrayIsLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEsRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIsiE5applyIdEEvRKNS0_8PODArrayIsLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEiRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIslE5applyIdEEvRKNS0_8PODArrayIsLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEElRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIsnE5applyIdEEvRKNS0_8PODArrayIsLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEnRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIsfE5applyIdEEvRKNS0_8PODArrayIsLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEfRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIsdE5applyIdEEvRKNS0_8PODArrayIsLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEdRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIihE5applyIdEEvRKNS0_8PODArrayIiLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEhRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIiaE5applyIdEEvRKNS0_8PODArrayIiLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEaRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIisE5applyIdEEvRKNS0_8PODArrayIiLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEsRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIiiE5applyIdEEvRKNS0_8PODArrayIiLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEiRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIilE5applyIdEEvRKNS0_8PODArrayIiLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEElRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIinE5applyIdEEvRKNS0_8PODArrayIiLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEnRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIifE5applyIdEEvRKNS0_8PODArrayIiLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEfRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIidE5applyIdEEvRKNS0_8PODArrayIiLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEdRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIlhE5applyIdEEvRKNS0_8PODArrayIlLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEhRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIlaE5applyIdEEvRKNS0_8PODArrayIlLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEaRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIlsE5applyIdEEvRKNS0_8PODArrayIlLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEsRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIliE5applyIdEEvRKNS0_8PODArrayIlLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEiRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIllE5applyIdEEvRKNS0_8PODArrayIlLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEElRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIlnE5applyIdEEvRKNS0_8PODArrayIlLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEnRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIlfE5applyIdEEvRKNS0_8PODArrayIlLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEfRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIldE5applyIdEEvRKNS0_8PODArrayIlLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEdRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInhE5applyIdEEvRKNS0_8PODArrayInLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEhRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInaE5applyIdEEvRKNS0_8PODArrayInLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEaRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInsE5applyIdEEvRKNS0_8PODArrayInLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEsRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIniE5applyIdEEvRKNS0_8PODArrayInLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEiRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInlE5applyIdEEvRKNS0_8PODArrayInLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEElRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInnE5applyIdEEvRKNS0_8PODArrayInLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEnRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInfE5applyIdEEvRKNS0_8PODArrayInLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEfRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIndE5applyIdEEvRKNS0_8PODArrayInLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEdRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfhE5applyIdEEvRKNS0_8PODArrayIfLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEhRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfaE5applyIdEEvRKNS0_8PODArrayIfLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEaRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfsE5applyIdEEvRKNS0_8PODArrayIfLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEsRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfiE5applyIdEEvRKNS0_8PODArrayIfLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEiRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIflE5applyIdEEvRKNS0_8PODArrayIfLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEElRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfnE5applyIdEEvRKNS0_8PODArrayIfLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEnRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIffE5applyIdEEvRKNS0_8PODArrayIfLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEfRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfdE5applyIdEEvRKNS0_8PODArrayIfLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEdRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdhE5applyIdEEvRKNS0_8PODArrayIdLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEhRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdaE5applyIdEEvRKNS0_8PODArrayIdLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEaRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdsE5applyIdEEvRKNS0_8PODArrayIdLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEsRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdiE5applyIdEEvRKNS0_8PODArrayIdLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEiRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdlE5applyIdEEvRKNS0_8PODArrayIdLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEElRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdnE5applyIdEEvRKNS0_8PODArrayIdLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEnRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdfE5applyIdEEvRKNS0_8PODArrayIdLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEfRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIddE5applyIdEEvRKNS0_8PODArrayIdLm4096E9AllocatorILb0ELb0ELb0E22DefaultMemoryAllocatorELm16ELm15EEEdRNS0_12ColumnVectorIT_E9ContainerERNS4_IhLm4096ES7_Lm16ELm15EEE
149
150
    template <typename Result>
151
6
    static inline Result apply(A a, B b, UInt8& is_null) {
152
6
        is_null = a <= 0 || b <= 0 || std::fabs(a - 1.0) < EPSILON;
153
6
        return static_cast<Float64>(std::log(static_cast<Float64>(b)) /
154
6
                                    std::log(static_cast<Float64>(a)));
155
6
    }
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhhE5applyIdEET_hhRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhaE5applyIdEET_haRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhsE5applyIdEET_hsRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhiE5applyIdEET_hiRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhlE5applyIdEET_hlRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhnE5applyIdEET_hnRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhfE5applyIdEET_hfRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIhdE5applyIdEET_hdRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIahE5applyIdEET_ahRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIaaE5applyIdEET_aaRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIasE5applyIdEET_asRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIaiE5applyIdEET_aiRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIalE5applyIdEET_alRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIanE5applyIdEET_anRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIafE5applyIdEET_afRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIadE5applyIdEET_adRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIshE5applyIdEET_shRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIsaE5applyIdEET_saRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIssE5applyIdEET_ssRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIsiE5applyIdEET_siRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIslE5applyIdEET_slRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIsnE5applyIdEET_snRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIsfE5applyIdEET_sfRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIsdE5applyIdEET_sdRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIihE5applyIdEET_ihRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIiaE5applyIdEET_iaRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIisE5applyIdEET_isRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIiiE5applyIdEET_iiRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIilE5applyIdEET_ilRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIinE5applyIdEET_inRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIifE5applyIdEET_ifRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIidE5applyIdEET_idRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIlhE5applyIdEET_lhRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIlaE5applyIdEET_laRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIlsE5applyIdEET_lsRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIliE5applyIdEET_liRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIllE5applyIdEET_llRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIlnE5applyIdEET_lnRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIlfE5applyIdEET_lfRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIldE5applyIdEET_ldRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInhE5applyIdEET_nhRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInaE5applyIdEET_naRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInsE5applyIdEET_nsRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIniE5applyIdEET_niRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInlE5applyIdEET_nlRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInnE5applyIdEET_nnRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplInfE5applyIdEET_nfRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIndE5applyIdEET_ndRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfhE5applyIdEET_fhRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfaE5applyIdEET_faRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfsE5applyIdEET_fsRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfiE5applyIdEET_fiRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIflE5applyIdEET_flRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfnE5applyIdEET_fnRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIffE5applyIdEET_ffRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIfdE5applyIdEET_fdRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdhE5applyIdEET_dhRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdaE5applyIdEET_daRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdsE5applyIdEET_dsRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdiE5applyIdEET_diRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdlE5applyIdEET_dlRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdnE5applyIdEET_dnRh
Unexecuted instantiation: _ZN5doris10vectorized7LogImplIdfE5applyIdEET_dfRh
_ZN5doris10vectorized7LogImplIddE5applyIdEET_ddRh
Line
Count
Source
151
6
    static inline Result apply(A a, B b, UInt8& is_null) {
152
6
        is_null = a <= 0 || b <= 0 || std::fabs(a - 1.0) < EPSILON;
153
6
        return static_cast<Float64>(std::log(static_cast<Float64>(b)) /
154
6
                                    std::log(static_cast<Float64>(a)));
155
6
    }
156
};
157
using FunctionLog = FunctionBinaryArithmetic<LogImpl, LogName, true>;
158
159
template <typename A>
160
struct SignImpl {
161
    using ResultType = Int8;
162
6
    static inline ResultType apply(A a) {
163
6
        if constexpr (IsDecimalNumber<A> || std::is_floating_point_v<A>)
164
3
            return static_cast<ResultType>(a < A(0) ? -1 : a == A(0) ? 0 : 1);
165
3
        else if constexpr (std::is_signed_v<A>)
166
3
            return static_cast<ResultType>(a < 0 ? -1 : a == 0 ? 0 : 1);
167
0
        else if constexpr (std::is_unsigned_v<A>)
168
0
            return static_cast<ResultType>(a == 0 ? 0 : 1);
169
6
    }
Unexecuted instantiation: _ZN5doris10vectorized8SignImplIhE5applyEh
Unexecuted instantiation: _ZN5doris10vectorized8SignImplItE5applyEt
Unexecuted instantiation: _ZN5doris10vectorized8SignImplIjE5applyEj
Unexecuted instantiation: _ZN5doris10vectorized8SignImplImE5applyEm
Unexecuted instantiation: _ZN5doris10vectorized8SignImplIaE5applyEa
Unexecuted instantiation: _ZN5doris10vectorized8SignImplIsE5applyEs
_ZN5doris10vectorized8SignImplIiE5applyEi
Line
Count
Source
162
3
    static inline ResultType apply(A a) {
163
3
        if constexpr (IsDecimalNumber<A> || std::is_floating_point_v<A>)
164
0
            return static_cast<ResultType>(a < A(0) ? -1 : a == A(0) ? 0 : 1);
165
3
        else if constexpr (std::is_signed_v<A>)
166
3
            return static_cast<ResultType>(a < 0 ? -1 : a == 0 ? 0 : 1);
167
3
        else if constexpr (std::is_unsigned_v<A>)
168
3
            return static_cast<ResultType>(a == 0 ? 0 : 1);
169
3
    }
Unexecuted instantiation: _ZN5doris10vectorized8SignImplIlE5applyEl
Unexecuted instantiation: _ZN5doris10vectorized8SignImplInE5applyEn
Unexecuted instantiation: _ZN5doris10vectorized8SignImplIfE5applyEf
_ZN5doris10vectorized8SignImplIdE5applyEd
Line
Count
Source
162
3
    static inline ResultType apply(A a) {
163
3
        if constexpr (IsDecimalNumber<A> || std::is_floating_point_v<A>)
164
3
            return static_cast<ResultType>(a < A(0) ? -1 : a == A(0) ? 0 : 1);
165
3
        else if constexpr (std::is_signed_v<A>)
166
3
            return static_cast<ResultType>(a < 0 ? -1 : a == 0 ? 0 : 1);
167
3
        else if constexpr (std::is_unsigned_v<A>)
168
3
            return static_cast<ResultType>(a == 0 ? 0 : 1);
169
3
    }
170
};
171
172
struct NameSign {
173
    static constexpr auto name = "sign";
174
};
175
using FunctionSign = FunctionUnaryArithmetic<SignImpl, NameSign>;
176
177
template <typename A>
178
struct AbsImpl {
179
    using ResultType =
180
            std::conditional_t<IsDecimalNumber<A>, A, typename NumberTraits::ResultOfAbs<A>::Type>;
181
182
12
    static inline ResultType apply(A a) {
183
12
        if constexpr (IsDecimalNumber<A>)
184
0
            return a < A(0) ? A(-a) : a;
185
12
        else if constexpr (std::is_integral_v<A> && std::is_signed_v<A>)
186
7
            return a < A(0) ? static_cast<ResultType>(~a) + 1 : a;
187
5
        else if constexpr (std::is_integral_v<A> && std::is_unsigned_v<A>)
188
0
            return static_cast<ResultType>(a);
189
5
        else if constexpr (std::is_floating_point_v<A>)
190
5
            return static_cast<ResultType>(std::abs(a));
191
12
    }
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplIhE5applyEh
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplItE5applyEt
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplIjE5applyEj
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplImE5applyEm
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplIaE5applyEa
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplIsE5applyEs
_ZN5doris10vectorized7AbsImplIiE5applyEi
Line
Count
Source
182
7
    static inline ResultType apply(A a) {
183
7
        if constexpr (IsDecimalNumber<A>)
184
0
            return a < A(0) ? A(-a) : a;
185
7
        else if constexpr (std::is_integral_v<A> && std::is_signed_v<A>)
186
7
            return a < A(0) ? static_cast<ResultType>(~a) + 1 : a;
187
7
        else if constexpr (std::is_integral_v<A> && std::is_unsigned_v<A>)
188
7
            return static_cast<ResultType>(a);
189
7
        else if constexpr (std::is_floating_point_v<A>)
190
7
            return static_cast<ResultType>(std::abs(a));
191
7
    }
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplIlE5applyEl
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplInE5applyEn
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplIfE5applyEf
_ZN5doris10vectorized7AbsImplIdE5applyEd
Line
Count
Source
182
5
    static inline ResultType apply(A a) {
183
5
        if constexpr (IsDecimalNumber<A>)
184
0
            return a < A(0) ? A(-a) : a;
185
5
        else if constexpr (std::is_integral_v<A> && std::is_signed_v<A>)
186
0
            return a < A(0) ? static_cast<ResultType>(~a) + 1 : a;
187
5
        else if constexpr (std::is_integral_v<A> && std::is_unsigned_v<A>)
188
0
            return static_cast<ResultType>(a);
189
5
        else if constexpr (std::is_floating_point_v<A>)
190
5
            return static_cast<ResultType>(std::abs(a));
191
5
    }
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplINS0_7DecimalIiEEE5applyES3_
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplINS0_7DecimalIlEEE5applyES3_
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplINS0_7DecimalInEEE5applyES3_
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplINS0_12Decimal128V3EE5applyES2_
Unexecuted instantiation: _ZN5doris10vectorized7AbsImplINS0_7DecimalIN4wide7integerILm256EiEEEEE5applyES6_
192
};
193
194
struct NameAbs {
195
    static constexpr auto name = "abs";
196
};
197
198
using FunctionAbs = FunctionUnaryArithmetic<AbsImpl, NameAbs>;
199
200
template <typename A>
201
struct NegativeImpl {
202
    using ResultType = A;
203
204
8
    static inline ResultType apply(A a) { return -a; }
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplIhE5applyEh
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplItE5applyEt
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplIjE5applyEj
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplImE5applyEm
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplIaE5applyEa
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplIsE5applyEs
_ZN5doris10vectorized12NegativeImplIiE5applyEi
Line
Count
Source
204
4
    static inline ResultType apply(A a) { return -a; }
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplIlE5applyEl
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplInE5applyEn
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplIfE5applyEf
_ZN5doris10vectorized12NegativeImplIdE5applyEd
Line
Count
Source
204
4
    static inline ResultType apply(A a) { return -a; }
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplINS0_7DecimalIiEEE5applyES3_
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplINS0_7DecimalIlEEE5applyES3_
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplINS0_7DecimalInEEE5applyES3_
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplINS0_12Decimal128V3EE5applyES2_
Unexecuted instantiation: _ZN5doris10vectorized12NegativeImplINS0_7DecimalIN4wide7integerILm256EiEEEEE5applyES6_
205
};
206
207
struct NameNegative {
208
    static constexpr auto name = "negative";
209
};
210
211
using FunctionNegative = FunctionUnaryArithmetic<NegativeImpl, NameNegative>;
212
213
template <typename A>
214
struct PositiveImpl {
215
    using ResultType = A;
216
217
8
    static inline ResultType apply(A a) { return static_cast<ResultType>(a); }
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplIhE5applyEh
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplItE5applyEt
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplIjE5applyEj
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplImE5applyEm
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplIaE5applyEa
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplIsE5applyEs
_ZN5doris10vectorized12PositiveImplIiE5applyEi
Line
Count
Source
217
4
    static inline ResultType apply(A a) { return static_cast<ResultType>(a); }
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplIlE5applyEl
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplInE5applyEn
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplIfE5applyEf
_ZN5doris10vectorized12PositiveImplIdE5applyEd
Line
Count
Source
217
4
    static inline ResultType apply(A a) { return static_cast<ResultType>(a); }
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplINS0_7DecimalIiEEE5applyES3_
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplINS0_7DecimalIlEEE5applyES3_
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplINS0_7DecimalInEEE5applyES3_
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplINS0_12Decimal128V3EE5applyES2_
Unexecuted instantiation: _ZN5doris10vectorized12PositiveImplINS0_7DecimalIN4wide7integerILm256EiEEEEE5applyES6_
218
};
219
220
struct NamePositive {
221
    static constexpr auto name = "positive";
222
};
223
224
using FunctionPositive = FunctionUnaryArithmetic<PositiveImpl, NamePositive>;
225
226
struct UnaryFunctionPlainSin {
227
    using Type = DataTypeFloat64;
228
    static constexpr auto name = "sin";
229
    using FuncType = double (*)(double);
230
231
1
    static FuncType get_sin_func() {
232
1
        void* handle = dlopen("libm.so.6", RTLD_LAZY);
233
1
        if (handle) {
234
1
            if (auto sin_func = (double (*)(double))dlsym(handle, "sin"); sin_func) {
235
1
                return sin_func;
236
1
            }
237
0
            dlclose(handle);
238
0
        }
239
0
        return std::sin;
240
1
    }
241
242
5
    static void execute(const double* src, double* dst) {
243
5
        static auto sin_func = get_sin_func();
244
5
        *dst = sin_func(*src);
245
5
    }
246
};
247
248
using FunctionSin = FunctionMathUnary<UnaryFunctionPlainSin>;
249
250
struct SqrtName {
251
    static constexpr auto name = "sqrt";
252
    // https://dev.mysql.com/doc/refman/8.4/en/mathematical-functions.html#function_sqrt
253
4
    static constexpr bool is_invalid_input(Float64 x) { return x < 0; }
254
};
255
using FunctionSqrt =
256
        FunctionMathUnaryAlwayNullable<UnaryFunctionPlainAlwayNullable<SqrtName, std::sqrt>>;
257
258
struct CbrtName {
259
    static constexpr auto name = "cbrt";
260
};
261
using FunctionCbrt = FunctionMathUnary<UnaryFunctionPlain<CbrtName, std::cbrt>>;
262
263
struct TanName {
264
    static constexpr auto name = "tan";
265
};
266
using FunctionTan = FunctionMathUnary<UnaryFunctionPlain<TanName, std::tan>>;
267
268
struct TanhName {
269
    static constexpr auto name = "tanh";
270
};
271
using FunctionTanh = FunctionMathUnary<UnaryFunctionPlain<TanhName, std::tanh>>;
272
273
template <typename A>
274
struct RadiansImpl {
275
    using ResultType = A;
276
277
4
    static inline ResultType apply(A a) {
278
4
        return static_cast<ResultType>(a * PiImpl::value / 180.0);
279
4
    }
Unexecuted instantiation: _ZN5doris10vectorized11RadiansImplIhE5applyEh
Unexecuted instantiation: _ZN5doris10vectorized11RadiansImplItE5applyEt
Unexecuted instantiation: _ZN5doris10vectorized11RadiansImplIjE5applyEj
Unexecuted instantiation: _ZN5doris10vectorized11RadiansImplImE5applyEm
Unexecuted instantiation: _ZN5doris10vectorized11RadiansImplIaE5applyEa
Unexecuted instantiation: _ZN5doris10vectorized11RadiansImplIsE5applyEs
Unexecuted instantiation: _ZN5doris10vectorized11RadiansImplIiE5applyEi
Unexecuted instantiation: _ZN5doris10vectorized11RadiansImplIlE5applyEl
Unexecuted instantiation: _ZN5doris10vectorized11RadiansImplInE5applyEn
Unexecuted instantiation: _ZN5doris10vectorized11RadiansImplIfE5applyEf
_ZN5doris10vectorized11RadiansImplIdE5applyEd
Line
Count
Source
277
4
    static inline ResultType apply(A a) {
278
4
        return static_cast<ResultType>(a * PiImpl::value / 180.0);
279
4
    }
280
};
281
282
struct NameRadians {
283
    static constexpr auto name = "radians";
284
};
285
286
using FunctionRadians = FunctionUnaryArithmetic<RadiansImpl, NameRadians>;
287
288
template <typename A>
289
struct DegreesImpl {
290
    using ResultType = A;
291
292
4
    static inline ResultType apply(A a) {
293
4
        return static_cast<ResultType>(a * 180.0 / PiImpl::value);
294
4
    }
Unexecuted instantiation: _ZN5doris10vectorized11DegreesImplIhE5applyEh
Unexecuted instantiation: _ZN5doris10vectorized11DegreesImplItE5applyEt
Unexecuted instantiation: _ZN5doris10vectorized11DegreesImplIjE5applyEj
Unexecuted instantiation: _ZN5doris10vectorized11DegreesImplImE5applyEm
Unexecuted instantiation: _ZN5doris10vectorized11DegreesImplIaE5applyEa
Unexecuted instantiation: _ZN5doris10vectorized11DegreesImplIsE5applyEs
Unexecuted instantiation: _ZN5doris10vectorized11DegreesImplIiE5applyEi
Unexecuted instantiation: _ZN5doris10vectorized11DegreesImplIlE5applyEl
Unexecuted instantiation: _ZN5doris10vectorized11DegreesImplInE5applyEn
Unexecuted instantiation: _ZN5doris10vectorized11DegreesImplIfE5applyEf
_ZN5doris10vectorized11DegreesImplIdE5applyEd
Line
Count
Source
292
4
    static inline ResultType apply(A a) {
293
4
        return static_cast<ResultType>(a * 180.0 / PiImpl::value);
294
4
    }
295
};
296
297
struct NameDegrees {
298
    static constexpr auto name = "degrees";
299
};
300
301
using FunctionDegrees = FunctionUnaryArithmetic<DegreesImpl, NameDegrees>;
302
303
struct NameBin {
304
    static constexpr auto name = "bin";
305
};
306
struct BinImpl {
307
    using ReturnType = DataTypeString;
308
    static constexpr auto TYPE_INDEX = TypeIndex::Int64;
309
    using Type = Int64;
310
    using ReturnColumnType = ColumnString;
311
312
4
    static std::string bin_impl(Int64 value) {
313
4
        uint64_t n = static_cast<uint64_t>(value);
314
4
        const size_t max_bits = sizeof(uint64_t) * 8;
315
4
        char result[max_bits];
316
4
        uint32_t index = max_bits;
317
7
        do {
318
7
            result[--index] = '0' + (n & 1);
319
7
        } while (n >>= 1);
320
4
        return std::string(result + index, max_bits - index);
321
4
    }
322
323
    static Status vector(const ColumnInt64::Container& data, ColumnString::Chars& res_data,
324
1
                         ColumnString::Offsets& res_offsets) {
325
1
        res_offsets.resize(data.size());
326
1
        size_t input_size = res_offsets.size();
327
328
5
        for (size_t i = 0; i < input_size; ++i) {
329
4
            StringOP::push_value_string(bin_impl(data[i]), i, res_data, res_offsets);
330
4
        }
331
1
        return Status::OK();
332
1
    }
333
};
334
335
using FunctionBin = FunctionUnaryToType<BinImpl, NameBin>;
336
337
template <typename A, typename B>
338
struct PowImpl {
339
    using ResultType = double;
340
    static const constexpr bool allow_decimal = false;
341
342
    template <typename type>
343
4
    static inline double apply(A a, B b) {
344
        /// Next everywhere, static_cast - so that there is no wrong result in expressions of the form Int64 c = UInt32(a) * Int32(-1).
345
4
        return std::pow((double)a, (double)b);
346
4
    }
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIhhE5applyIdEEdhh
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIhaE5applyIdEEdha
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIhsE5applyIdEEdhs
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIhiE5applyIdEEdhi
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIhlE5applyIdEEdhl
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIhnE5applyIdEEdhn
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIhfE5applyIdEEdhf
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIhdE5applyIdEEdhd
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIahE5applyIdEEdah
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIaaE5applyIdEEdaa
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIasE5applyIdEEdas
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIaiE5applyIdEEdai
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIalE5applyIdEEdal
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIanE5applyIdEEdan
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIafE5applyIdEEdaf
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIadE5applyIdEEdad
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIshE5applyIdEEdsh
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIsaE5applyIdEEdsa
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIssE5applyIdEEdss
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIsiE5applyIdEEdsi
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIslE5applyIdEEdsl
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIsnE5applyIdEEdsn
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIsfE5applyIdEEdsf
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIsdE5applyIdEEdsd
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIihE5applyIdEEdih
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIiaE5applyIdEEdia
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIisE5applyIdEEdis
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIiiE5applyIdEEdii
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIilE5applyIdEEdil
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIinE5applyIdEEdin
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIifE5applyIdEEdif
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIidE5applyIdEEdid
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIlhE5applyIdEEdlh
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIlaE5applyIdEEdla
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIlsE5applyIdEEdls
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIliE5applyIdEEdli
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIllE5applyIdEEdll
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIlnE5applyIdEEdln
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIlfE5applyIdEEdlf
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIldE5applyIdEEdld
Unexecuted instantiation: _ZN5doris10vectorized7PowImplInhE5applyIdEEdnh
Unexecuted instantiation: _ZN5doris10vectorized7PowImplInaE5applyIdEEdna
Unexecuted instantiation: _ZN5doris10vectorized7PowImplInsE5applyIdEEdns
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIniE5applyIdEEdni
Unexecuted instantiation: _ZN5doris10vectorized7PowImplInlE5applyIdEEdnl
Unexecuted instantiation: _ZN5doris10vectorized7PowImplInnE5applyIdEEdnn
Unexecuted instantiation: _ZN5doris10vectorized7PowImplInfE5applyIdEEdnf
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIndE5applyIdEEdnd
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIfhE5applyIdEEdfh
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIfaE5applyIdEEdfa
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIfsE5applyIdEEdfs
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIfiE5applyIdEEdfi
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIflE5applyIdEEdfl
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIfnE5applyIdEEdfn
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIffE5applyIdEEdff
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIfdE5applyIdEEdfd
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIdhE5applyIdEEddh
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIdaE5applyIdEEdda
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIdsE5applyIdEEdds
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIdiE5applyIdEEddi
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIdlE5applyIdEEddl
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIdnE5applyIdEEddn
Unexecuted instantiation: _ZN5doris10vectorized7PowImplIdfE5applyIdEEddf
_ZN5doris10vectorized7PowImplIddE5applyIdEEddd
Line
Count
Source
343
4
    static inline double apply(A a, B b) {
344
        /// Next everywhere, static_cast - so that there is no wrong result in expressions of the form Int64 c = UInt32(a) * Int32(-1).
345
4
        return std::pow((double)a, (double)b);
346
4
    }
347
};
348
struct PowName {
349
    static constexpr auto name = "pow";
350
};
351
using FunctionPow = FunctionBinaryArithmetic<PowImpl, PowName, false>;
352
353
class FunctionNormalCdf : public IFunction {
354
public:
355
    static constexpr auto name = "normal_cdf";
356
357
0
    String get_name() const override { return name; }
358
359
1
    static FunctionPtr create() { return std::make_shared<FunctionNormalCdf>(); }
360
361
0
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
362
0
        return make_nullable(std::make_shared<DataTypeFloat64>());
363
0
    }
364
365
1
    DataTypes get_variadic_argument_types_impl() const override {
366
1
        return {std::make_shared<DataTypeFloat64>(), std::make_shared<DataTypeFloat64>(),
367
1
                std::make_shared<DataTypeFloat64>()};
368
1
    }
369
0
    size_t get_number_of_arguments() const override { return 3; }
370
371
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
372
0
                        uint32_t result, size_t input_rows_count) const override {
373
0
        auto result_column = ColumnFloat64::create(input_rows_count);
374
0
        auto result_null_map_column = ColumnUInt8::create(input_rows_count, 0);
375
376
0
        auto& result_data = result_column->get_data();
377
0
        NullMap& result_null_map =
378
0
                assert_cast<ColumnUInt8*>(result_null_map_column.get())->get_data();
379
380
0
        ColumnPtr argument_columns[3];
381
0
        bool col_const[3];
382
0
        size_t argument_size = arguments.size();
383
0
        for (int i = 0; i < argument_size; ++i) {
384
0
            argument_columns[i] = block.get_by_position(arguments[i]).column;
385
0
            col_const[i] = is_column_const(*argument_columns[i]);
386
0
            if (col_const[i]) {
387
0
                argument_columns[i] =
388
0
                        static_cast<const ColumnConst&>(*argument_columns[i]).get_data_column_ptr();
389
0
            }
390
0
        }
391
392
0
        auto* mean_col = assert_cast<const ColumnFloat64*>(argument_columns[0].get());
393
0
        auto* sd_col = assert_cast<const ColumnFloat64*>(argument_columns[1].get());
394
0
        auto* value_col = assert_cast<const ColumnFloat64*>(argument_columns[2].get());
395
396
0
        result_column->reserve(input_rows_count);
397
0
        for (size_t i = 0; i < input_rows_count; ++i) {
398
0
            double mean = mean_col->get_element(index_check_const(i, col_const[0]));
399
0
            double sd = sd_col->get_element(index_check_const(i, col_const[1]));
400
0
            double v = value_col->get_element(index_check_const(i, col_const[2]));
401
402
0
            if (!check_argument(sd)) [[unlikely]] {
403
0
                result_null_map[i] = true;
404
0
                continue;
405
0
            }
406
0
            result_data[i] = calculate_cell(mean, sd, v);
407
0
        }
408
409
0
        block.get_by_position(result).column =
410
0
                ColumnNullable::create(std::move(result_column), std::move(result_null_map_column));
411
0
        return Status::OK();
412
0
    }
413
414
0
    static bool check_argument(double sd) { return sd > 0; }
415
0
    static double calculate_cell(double mean, double sd, double v) {
416
#ifdef __APPLE__
417
        const double sqrt2 = std::sqrt(2);
418
#else
419
0
        constexpr double sqrt2 = std::numbers::sqrt2;
420
0
#endif
421
422
0
        return 0.5 * (std::erf((v - mean) / (sd * sqrt2)) + 1);
423
0
    }
424
};
425
426
// TODO: Now math may cause one thread compile time too long, because the function in math
427
// so mush. Split it to speed up compile time in the future
428
1
void register_function_math(SimpleFunctionFactory& factory) {
429
1
    factory.register_function<FunctionAcos>();
430
1
    factory.register_function<FunctionAsin>();
431
1
    factory.register_function<FunctionAtan>();
432
1
    factory.register_function<FunctionAtan2>();
433
1
    factory.register_function<FunctionCos>();
434
1
    factory.register_function<FunctionCosh>();
435
1
    factory.register_function<FunctionE>();
436
1
    factory.register_alias("ln", "dlog1");
437
1
    factory.register_function<FunctionLog>();
438
1
    factory.register_function<FunctionMathLog<ImplLn>>();
439
1
    factory.register_function<FunctionMathLog<ImplLog2>>();
440
1
    factory.register_function<FunctionMathLog<ImplLog10>>();
441
1
    factory.register_alias("log10", "dlog10");
442
1
    factory.register_function<FunctionPi>();
443
1
    factory.register_function<FunctionSign>();
444
1
    factory.register_function<FunctionAbs>();
445
1
    factory.register_function<FunctionNegative>();
446
1
    factory.register_function<FunctionPositive>();
447
1
    factory.register_function<FunctionSin>();
448
1
    factory.register_function<FunctionSqrt>();
449
1
    factory.register_alias("sqrt", "dsqrt");
450
1
    factory.register_function<FunctionCbrt>();
451
1
    factory.register_function<FunctionTan>();
452
1
    factory.register_function<FunctionTanh>();
453
1
    factory.register_function<FunctionPow>();
454
1
    factory.register_alias("pow", "power");
455
1
    factory.register_alias("pow", "dpow");
456
1
    factory.register_alias("pow", "fpow");
457
1
    factory.register_function<FunctionExp>();
458
1
    factory.register_alias("exp", "dexp");
459
1
    factory.register_function<FunctionRadians>();
460
1
    factory.register_function<FunctionDegrees>();
461
1
    factory.register_function<FunctionBin>();
462
1
    factory.register_function<FunctionNormalCdf>();
463
1
}
464
} // namespace doris::vectorized