Coverage Report

Created: 2024-11-20 12:56

/root/doris/be/src/vec/functions/plus.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
// This file is copied from
18
// https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/Plus.cpp
19
// and modified by Doris
20
21
#include <utility>
22
23
#include "runtime/decimalv2_value.h"
24
#include "vec/common/arithmetic_overflow.h"
25
#include "vec/data_types/number_traits.h"
26
#include "vec/functions/function_binary_arithmetic.h"
27
#include "vec/functions/simple_function_factory.h"
28
29
namespace doris::vectorized {
30
31
template <typename A, typename B>
32
struct PlusImpl {
33
    using ResultType = typename NumberTraits::ResultOfAdditionMultiplication<A, B>::Type;
34
    static const constexpr bool allow_decimal = true;
35
36
    template <typename Result = ResultType>
37
0
    static inline Result apply(A a, B b) {
38
        /// Next everywhere, static_cast - so that there is no wrong result in expressions of the form Int64 c = UInt32(a) * Int32(-1).
39
0
        return static_cast<Result>(a) + b;
40
0
    }
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIhhE5applyIiEET_hh
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIhaE5applyIsEET_ha
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIhsE5applyIiEET_hs
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIhiE5applyIlEET_hi
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIhlE5applyIlEET_hl
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIhnE5applyInEET_hn
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIhfE5applyIdEET_hf
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIhdE5applyIdEET_hd
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIiiE5applyIiEET_ii
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIllE5applyIlEET_ll
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplInnE5applyInEET_nn
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIahE5applyIsEET_ah
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIaaE5applyIsEET_aa
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIasE5applyIiEET_as
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIaiE5applyIlEET_ai
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIalE5applyIlEET_al
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIanE5applyInEET_an
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIafE5applyIdEET_af
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIadE5applyIdEET_ad
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIshE5applyIiEET_sh
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIsaE5applyIiEET_sa
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIssE5applyIiEET_ss
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIsiE5applyIlEET_si
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIslE5applyIlEET_sl
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIsnE5applyInEET_sn
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIsfE5applyIdEET_sf
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIsdE5applyIdEET_sd
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIihE5applyIlEET_ih
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIiaE5applyIlEET_ia
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIisE5applyIlEET_is
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIiiE5applyIlEET_ii
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIilE5applyIlEET_il
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIinE5applyInEET_in
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIifE5applyIdEET_if
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIidE5applyIdEET_id
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIlhE5applyIlEET_lh
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIlaE5applyIlEET_la
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIlsE5applyIlEET_ls
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIliE5applyIlEET_li
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIlnE5applyInEET_ln
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIlfE5applyIdEET_lf
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIldE5applyIdEET_ld
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplInhE5applyInEET_nh
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplInaE5applyInEET_na
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplInsE5applyInEET_ns
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIniE5applyInEET_ni
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplInlE5applyInEET_nl
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplInfE5applyIdEET_nf
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIndE5applyIdEET_nd
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIfhE5applyIdEET_fh
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIfaE5applyIdEET_fa
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIfsE5applyIdEET_fs
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIfiE5applyIdEET_fi
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIflE5applyIdEET_fl
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIfnE5applyIdEET_fn
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIffE5applyIdEET_ff
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIfdE5applyIdEET_fd
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIdhE5applyIdEET_dh
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIdaE5applyIdEET_da
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIdsE5applyIdEET_ds
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIdiE5applyIdEET_di
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIdlE5applyIdEET_dl
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIdnE5applyIdEET_dn
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIdfE5applyIdEET_df
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIddE5applyIdEET_dd
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplInnE5applyIN4wide7integerILm256EiEEEET_nn
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIllE5applyIN4wide7integerILm256EiEEEET_ll
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIiiE5applyIN4wide7integerILm256EiEEEET_ii
41
42
    template <typename Result = DecimalV2Value>
43
0
    static inline DecimalV2Value apply(DecimalV2Value a, DecimalV2Value b) {
44
0
        return DecimalV2Value(a.value() + b.value());
45
0
    }
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIiiE5applyINS_14DecimalV2ValueEEES4_S4_S4_
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIllE5applyINS_14DecimalV2ValueEEES4_S4_S4_
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplInnE5applyINS_14DecimalV2ValueEEES4_S4_S4_
46
47
    /// Apply operation and check overflow. It's used for Decimal operations. @returns true if overflowed, false otherwise.
48
    template <typename Result = ResultType>
49
0
    static inline bool apply(A a, B b, Result& c) {
50
0
        return common::add_overflow(static_cast<Result>(a), b, c);
51
0
    }
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIiiE5applyIiEEbiiRT_
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplIllE5applyIlEEbllRT_
Unexecuted instantiation: _ZN5doris10vectorized8PlusImplInnE5applyInEEbnnRT_
52
};
53
54
struct NamePlus {
55
    static constexpr auto name = "add";
56
};
57
using FunctionPlus = FunctionBinaryArithmetic<PlusImpl, NamePlus, false>;
58
59
1
void register_function_plus(SimpleFunctionFactory& factory) {
60
1
    factory.register_function<FunctionPlus>();
61
1
}
62
} // namespace doris::vectorized