/root/doris/be/src/vec/functions/minus.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/Minus.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 MinusImpl { |
33 | | using ResultType = typename NumberTraits::ResultOfSubtraction<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 | 0 | return static_cast<Result>(a) - b; |
39 | 0 | } Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIhhE5applyIsEET_hh Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIhaE5applyIsEET_ha Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIhsE5applyIiEET_hs Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIhiE5applyIlEET_hi Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIhlE5applyIlEET_hl Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIhnE5applyInEET_hn Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIhfE5applyIdEET_hf Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIhdE5applyIdEET_hd Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIiiE5applyIiEET_ii Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIllE5applyIlEET_ll Unexecuted instantiation: _ZN5doris10vectorized9MinusImplInnE5applyInEET_nn Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIN4wide7integerILm256EiEES4_E5applyIS4_EET_S4_S4_ Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIahE5applyIsEET_ah Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIaaE5applyIsEET_aa Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIasE5applyIiEET_as Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIaiE5applyIlEET_ai Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIalE5applyIlEET_al Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIanE5applyInEET_an Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIafE5applyIdEET_af Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIadE5applyIdEET_ad Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIshE5applyIiEET_sh Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIsaE5applyIiEET_sa Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIssE5applyIiEET_ss Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIsiE5applyIlEET_si Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIslE5applyIlEET_sl Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIsnE5applyInEET_sn Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIsfE5applyIdEET_sf Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIsdE5applyIdEET_sd Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIihE5applyIlEET_ih Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIiaE5applyIlEET_ia Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIisE5applyIlEET_is Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIiiE5applyIlEET_ii Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIilE5applyIlEET_il Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIinE5applyInEET_in Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIifE5applyIdEET_if Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIidE5applyIdEET_id Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIlhE5applyIlEET_lh Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIlaE5applyIlEET_la Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIlsE5applyIlEET_ls Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIliE5applyIlEET_li Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIlnE5applyInEET_ln Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIlfE5applyIdEET_lf Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIldE5applyIdEET_ld Unexecuted instantiation: _ZN5doris10vectorized9MinusImplInhE5applyInEET_nh Unexecuted instantiation: _ZN5doris10vectorized9MinusImplInaE5applyInEET_na Unexecuted instantiation: _ZN5doris10vectorized9MinusImplInsE5applyInEET_ns Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIniE5applyInEET_ni Unexecuted instantiation: _ZN5doris10vectorized9MinusImplInlE5applyInEET_nl Unexecuted instantiation: _ZN5doris10vectorized9MinusImplInfE5applyIdEET_nf Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIndE5applyIdEET_nd Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIfhE5applyIdEET_fh Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIfaE5applyIdEET_fa Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIfsE5applyIdEET_fs Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIfiE5applyIdEET_fi Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIflE5applyIdEET_fl Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIfnE5applyIdEET_fn Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIffE5applyIdEET_ff Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIfdE5applyIdEET_fd Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIdhE5applyIdEET_dh Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIdaE5applyIdEET_da Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIdsE5applyIdEET_ds Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIdiE5applyIdEET_di Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIdlE5applyIdEET_dl Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIdnE5applyIdEET_dn Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIdfE5applyIdEET_df Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIddE5applyIdEET_dd Unexecuted instantiation: _ZN5doris10vectorized9MinusImplInnE5applyIN4wide7integerILm256EiEEEET_nn |
40 | | |
41 | | template <typename Result = DecimalV2Value> |
42 | 0 | static inline DecimalV2Value apply(const DecimalV2Value& a, const DecimalV2Value& b) { |
43 | 0 | return DecimalV2Value(a.value() - b.value()); |
44 | 0 | } Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIiiE5applyINS_14DecimalV2ValueEEES4_RKS4_S6_ Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIllE5applyINS_14DecimalV2ValueEEES4_RKS4_S6_ Unexecuted instantiation: _ZN5doris10vectorized9MinusImplInnE5applyINS_14DecimalV2ValueEEES4_RKS4_S6_ Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIN4wide7integerILm256EiEES4_E5applyINS_14DecimalV2ValueEEES7_RKS7_S9_ |
45 | | |
46 | | /// Apply operation and check overflow. It's used for Decimal operations. @returns true if overflowed, false otherwise. |
47 | | template <typename Result = ResultType> |
48 | 0 | static inline bool apply(A a, B b, Result& c) { |
49 | 0 | return common::sub_overflow(static_cast<Result>(a), b, c); |
50 | 0 | } Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIiiE5applyIiEEbiiRT_ Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIllE5applyIlEEbllRT_ Unexecuted instantiation: _ZN5doris10vectorized9MinusImplInnE5applyInEEbnnRT_ Unexecuted instantiation: _ZN5doris10vectorized9MinusImplIN4wide7integerILm256EiEES4_E5applyIS4_EEbS4_S4_RT_ |
51 | | }; |
52 | | |
53 | | struct NameMinus { |
54 | | static constexpr auto name = "subtract"; |
55 | | }; |
56 | | using FunctionMinus = FunctionBinaryArithmetic<MinusImpl, NameMinus, false>; |
57 | | |
58 | 1 | void register_function_minus(SimpleFunctionFactory& factory) { |
59 | 1 | factory.register_function<FunctionMinus>(); |
60 | 1 | } |
61 | | } // namespace doris::vectorized |