/root/doris/be/src/vec/functions/round.cpp
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #include "round.h" |
19 | | |
20 | | #include "vec/functions/simple_function_factory.h" |
21 | | |
22 | | namespace doris::vectorized { |
23 | | |
24 | | // We split round funcs from register_function_math() in math.cpp to here, |
25 | | // so that to speed up compile time and make code more readable. |
26 | 1 | void register_function_round(SimpleFunctionFactory& factory) { |
27 | 1 | #define REGISTER_ROUND_FUNCTIONS(IMPL) \ |
28 | 2 | factory.register_function< \ |
29 | 2 | FunctionRounding<IMPL<TruncateName>, RoundingMode::Trunc, TieBreakingMode::Auto>>(); \ |
30 | 2 | factory.register_function< \ |
31 | 2 | FunctionRounding<IMPL<FloorName>, RoundingMode::Floor, TieBreakingMode::Auto>>(); \ |
32 | 2 | factory.register_function< \ |
33 | 2 | FunctionRounding<IMPL<RoundName>, RoundingMode::Round, TieBreakingMode::Auto>>(); \ |
34 | 2 | factory.register_function< \ |
35 | 2 | FunctionRounding<IMPL<CeilName>, RoundingMode::Ceil, TieBreakingMode::Auto>>(); \ |
36 | 2 | factory.register_function<FunctionRounding<IMPL<RoundBankersName>, RoundingMode::Round, \ |
37 | 2 | TieBreakingMode::Bankers>>(); |
38 | 1 | REGISTER_ROUND_FUNCTIONS(DoubleRoundOneImpl) |
39 | 1 | REGISTER_ROUND_FUNCTIONS(DoubleRoundTwoImpl) |
40 | 1 | #undef REGISTER_ROUND_FUNCTIONS |
41 | | |
42 | 1 | #define REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE) \ |
43 | 10 | factory.register_function<FunctionRounding<IMPL<TruncateName, TYPE>, RoundingMode::Trunc, \ |
44 | 10 | TieBreakingMode::Auto>>(); \ |
45 | 10 | factory.register_function<FunctionRounding<IMPL<FloorName, TYPE>, RoundingMode::Floor, \ |
46 | 10 | TieBreakingMode::Auto>>(); \ |
47 | 10 | factory.register_function<FunctionRounding<IMPL<RoundName, TYPE>, RoundingMode::Round, \ |
48 | 10 | TieBreakingMode::Auto>>(); \ |
49 | 10 | factory.register_function< \ |
50 | 10 | FunctionRounding<IMPL<CeilName, TYPE>, RoundingMode::Ceil, TieBreakingMode::Auto>>(); \ |
51 | 10 | factory.register_function<FunctionRounding<IMPL<RoundBankersName, TYPE>, RoundingMode::Round, \ |
52 | 10 | TieBreakingMode::Bankers>>(); |
53 | | |
54 | 1 | #define REGISTER_ROUND_FUNCTIONS(IMPL) \ |
55 | 2 | REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE_DECIMAL32) \ |
56 | 2 | REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE_DECIMAL64) \ |
57 | 2 | REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE_DECIMAL128I) \ |
58 | 2 | REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE_DECIMALV2) \ |
59 | 2 | REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE_DECIMAL256) |
60 | 1 | REGISTER_ROUND_FUNCTIONS(DecimalRoundOneImpl) |
61 | 1 | REGISTER_ROUND_FUNCTIONS(DecimalRoundTwoImpl) |
62 | 1 | #undef REGISTER_ROUND_FUNCTIONS |
63 | 1 | #undef REGISTER_ROUND_FUNCTIONS_IMPL |
64 | | |
65 | 1 | factory.register_alias("ceil", "dceil"); |
66 | 1 | factory.register_alias("ceil", "ceiling"); |
67 | 1 | factory.register_alias("floor", "dfloor"); |
68 | 1 | factory.register_alias("round", "dround"); |
69 | 1 | } |
70 | | |
71 | | } // namespace doris::vectorized |