be/src/exprs/function/function_const.h
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/FunctionConst.h |
19 | | // and modified by Doris |
20 | | |
21 | | #pragma once |
22 | | |
23 | | #include "core/column/column_const.h" |
24 | | #include "core/data_type/data_type_number.h" |
25 | | #include "exprs/function/function.h" |
26 | | |
27 | | namespace doris { |
28 | | |
29 | | template <typename Impl, bool use_field = true> |
30 | | class FunctionConst : public IFunction { |
31 | | public: |
32 | | static constexpr auto name = Impl::name; |
33 | | |
34 | | static FunctionPtr create() { return std::make_shared<FunctionConst>(); } |
35 | | |
36 | | public: |
37 | | String get_name() const override { return name; } |
38 | | |
39 | | size_t get_number_of_arguments() const override { return 0; } |
40 | | |
41 | | DataTypePtr get_return_type_impl(const DataTypes& /*arguments*/) const override { |
42 | | return Impl::get_return_type(); |
43 | | } |
44 | | |
45 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
46 | | uint32_t result, size_t input_rows_count) const override { |
47 | | block.get_by_position(result).column = |
48 | | block.get_by_position(result).type->create_column_const(input_rows_count, |
49 | | Impl::init_value()); |
50 | | return Status::OK(); |
51 | | } |
52 | | }; |
53 | | |
54 | | template <typename Impl> |
55 | | class FunctionConst<Impl, false> : public IFunction { |
56 | | public: |
57 | | static constexpr auto name = Impl::name; |
58 | 6 | static FunctionPtr create() { return std::make_shared<FunctionConst>(); }_ZN5doris13FunctionConstINS_11BitmapEmptyELb0EE6createEv Line | Count | Source | 58 | 2 | static FunctionPtr create() { return std::make_shared<FunctionConst>(); } |
_ZN5doris13FunctionConstINS_12HLLEmptyImplELb0EE6createEv Line | Count | Source | 58 | 2 | static FunctionPtr create() { return std::make_shared<FunctionConst>(); } |
_ZN5doris13FunctionConstINS_18QuantileStateEmptyELb0EE6createEv Line | Count | Source | 58 | 2 | static FunctionPtr create() { return std::make_shared<FunctionConst>(); } |
|
59 | 3 | String get_name() const override { return name; }_ZNK5doris13FunctionConstINS_11BitmapEmptyELb0EE8get_nameB5cxx11Ev Line | Count | Source | 59 | 1 | String get_name() const override { return name; } |
_ZNK5doris13FunctionConstINS_12HLLEmptyImplELb0EE8get_nameB5cxx11Ev Line | Count | Source | 59 | 1 | String get_name() const override { return name; } |
_ZNK5doris13FunctionConstINS_18QuantileStateEmptyELb0EE8get_nameB5cxx11Ev Line | Count | Source | 59 | 1 | String get_name() const override { return name; } |
|
60 | | |
61 | 0 | size_t get_number_of_arguments() const override { return 0; }Unexecuted instantiation: _ZNK5doris13FunctionConstINS_11BitmapEmptyELb0EE23get_number_of_argumentsEv Unexecuted instantiation: _ZNK5doris13FunctionConstINS_12HLLEmptyImplELb0EE23get_number_of_argumentsEv Unexecuted instantiation: _ZNK5doris13FunctionConstINS_18QuantileStateEmptyELb0EE23get_number_of_argumentsEv |
62 | | |
63 | 0 | DataTypePtr get_return_type_impl(const DataTypes& /*arguments*/) const override { |
64 | 0 | return Impl::get_return_type(); |
65 | 0 | } Unexecuted instantiation: _ZNK5doris13FunctionConstINS_11BitmapEmptyELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Unexecuted instantiation: _ZNK5doris13FunctionConstINS_12HLLEmptyImplELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Unexecuted instantiation: _ZNK5doris13FunctionConstINS_18QuantileStateEmptyELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE |
66 | | |
67 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
68 | 0 | uint32_t result, size_t input_rows_count) const override { |
69 | 0 | auto column = Impl::ReturnColVec::create(); |
70 | 0 | column->get_data().emplace_back(Impl::init_value()); |
71 | 0 | block.replace_by_position(result, ColumnConst::create(std::move(column), input_rows_count)); |
72 | 0 | return Status::OK(); |
73 | 0 | } Unexecuted instantiation: _ZNK5doris13FunctionConstINS_11BitmapEmptyELb0EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Unexecuted instantiation: _ZNK5doris13FunctionConstINS_12HLLEmptyImplELb0EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Unexecuted instantiation: _ZNK5doris13FunctionConstINS_18QuantileStateEmptyELb0EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm |
74 | | }; |
75 | | |
76 | | template <typename Impl> |
77 | | class FunctionMathConstFloat64 : public IFunction { |
78 | | public: |
79 | | static constexpr auto name = Impl::name; |
80 | 4 | static FunctionPtr create() { return std::make_shared<FunctionMathConstFloat64>(); }_ZN5doris24FunctionMathConstFloat64INS_5EImplEE6createEv Line | Count | Source | 80 | 2 | static FunctionPtr create() { return std::make_shared<FunctionMathConstFloat64>(); } |
_ZN5doris24FunctionMathConstFloat64INS_6PiImplEE6createEv Line | Count | Source | 80 | 2 | static FunctionPtr create() { return std::make_shared<FunctionMathConstFloat64>(); } |
|
81 | | |
82 | | private: |
83 | 2 | String get_name() const override { return name; }_ZNK5doris24FunctionMathConstFloat64INS_5EImplEE8get_nameB5cxx11Ev Line | Count | Source | 83 | 1 | String get_name() const override { return name; } |
_ZNK5doris24FunctionMathConstFloat64INS_6PiImplEE8get_nameB5cxx11Ev Line | Count | Source | 83 | 1 | String get_name() const override { return name; } |
|
84 | | |
85 | 0 | size_t get_number_of_arguments() const override { return 0; }Unexecuted instantiation: _ZNK5doris24FunctionMathConstFloat64INS_5EImplEE23get_number_of_argumentsEv Unexecuted instantiation: _ZNK5doris24FunctionMathConstFloat64INS_6PiImplEE23get_number_of_argumentsEv |
86 | | |
87 | 0 | DataTypePtr get_return_type_impl(const DataTypes& /*arguments*/) const override { |
88 | 0 | return std::make_shared<DataTypeFloat64>(); |
89 | 0 | } Unexecuted instantiation: _ZNK5doris24FunctionMathConstFloat64INS_5EImplEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Unexecuted instantiation: _ZNK5doris24FunctionMathConstFloat64INS_6PiImplEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE |
90 | | |
91 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
92 | 0 | uint32_t result, size_t input_rows_count) const override { |
93 | 0 | block.get_by_position(result).column = |
94 | 0 | block.get_by_position(result).type->create_column_const( |
95 | 0 | input_rows_count, Field::create_field<TYPE_DOUBLE>(Impl::value)); |
96 | 0 | return Status::OK(); |
97 | 0 | } Unexecuted instantiation: _ZNK5doris24FunctionMathConstFloat64INS_5EImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Unexecuted instantiation: _ZNK5doris24FunctionMathConstFloat64INS_6PiImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm |
98 | | }; |
99 | | |
100 | | } // namespace doris |