Coverage Report

Created: 2026-04-10 04:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/aggregate/aggregate_function_linear_histogram.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 "exprs/aggregate/aggregate_function_linear_histogram.h"
19
20
#include "exprs/aggregate/helpers.h"
21
22
namespace doris {
23
24
const std::string AggregateFunctionLinearHistogramConsts::NAME = "linear_histogram";
25
26
template <PrimitiveType T, typename Data>
27
using HistogramWithInputParam = AggregateFunctionLinearHistogram<T, Data, true>;
28
29
template <PrimitiveType T, typename Data>
30
using HistogramNormal = AggregateFunctionLinearHistogram<T, Data, false>;
31
32
AggregateFunctionPtr create_aggregate_function_linear_histogram(const std::string& name,
33
                                                                const DataTypes& argument_types,
34
                                                                const DataTypePtr& result_type,
35
                                                                const bool result_is_nullable,
36
33
                                                                const AggregateFunctionAttr& attr) {
37
33
    using creator = creator_with_type_list<TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT,
38
33
                                           TYPE_LARGEINT, TYPE_FLOAT, TYPE_DOUBLE, TYPE_DECIMAL32,
39
33
                                           TYPE_DECIMAL64, TYPE_DECIMAL128I, TYPE_DECIMAL256>;
40
33
    bool has_offset = (argument_types.size() == 3);
41
33
    if (has_offset) {
42
11
        return creator::create<HistogramWithInputParam, AggregateFunctionLinearHistogramData>(
43
11
                argument_types, result_is_nullable, attr);
44
22
    } else {
45
22
        return creator::create<HistogramNormal, AggregateFunctionLinearHistogramData>(
46
22
                argument_types, result_is_nullable, attr);
47
22
    }
48
33
}
49
50
3
void register_aggregate_function_linear_histogram(AggregateFunctionSimpleFactory& factory) {
51
3
    factory.register_function_both(AggregateFunctionLinearHistogramConsts::NAME,
52
3
                                   create_aggregate_function_linear_histogram);
53
3
}
54
55
} // namespace doris