be/src/exprs/aggregate/aggregate_function_state_merge.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 | | |
18 | | #pragma once |
19 | | |
20 | | #include "exprs/aggregate/aggregate_function_state_union.h" |
21 | | |
22 | | namespace doris { |
23 | | #include "common/compile_check_begin.h" |
24 | | const static std::string AGG_MERGE_SUFFIX = "_merge"; |
25 | | |
26 | | class AggregateStateMerge : public AggregateStateUnion { |
27 | | public: |
28 | | using AggregateStateUnion::create; |
29 | | |
30 | | AggregateStateMerge(AggregateFunctionPtr function, const DataTypes& argument_types_, |
31 | | const DataTypePtr& return_type) |
32 | 0 | : AggregateStateUnion(function, argument_types_, return_type) {} |
33 | | |
34 | | static AggregateFunctionPtr create(AggregateFunctionPtr function, |
35 | | const DataTypes& argument_types_, |
36 | 0 | const DataTypePtr& return_type) { |
37 | 0 | CHECK(argument_types_.size() == 1); |
38 | 0 | if (function == nullptr) { |
39 | 0 | return nullptr; |
40 | 0 | } |
41 | 0 | return std::make_shared<AggregateStateMerge>(function, argument_types_, return_type); |
42 | 0 | } |
43 | | |
44 | 0 | void set_version(const int version_) override { |
45 | 0 | IAggregateFunctionHelper::set_version(version_); |
46 | 0 | _function->set_version(version_); |
47 | 0 | } |
48 | | |
49 | 0 | String get_name() const override { return _function->get_name() + AGG_MERGE_SUFFIX; } |
50 | | |
51 | 0 | DataTypePtr get_return_type() const override { return _function->get_return_type(); } |
52 | | |
53 | 0 | void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override { |
54 | 0 | _function->insert_result_into(place, to); |
55 | 0 | } |
56 | | }; |
57 | | |
58 | | } // namespace doris |
59 | | |
60 | | #include "common/compile_check_end.h" |