Coverage Report

Created: 2026-04-16 17:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/aggregate/aggregate_function_bitmap.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_bitmap.h"
19
20
#include "core/data_type/data_type.h"
21
#include "core/data_type/data_type_nullable.h"
22
#include "exprs/aggregate/aggregate_function_simple_factory.h"
23
#include "exprs/aggregate/helpers.h"
24
25
namespace doris {
26
27
template <bool nullable, template <bool, typename> class AggregateFunctionTemplate>
28
4
AggregateFunctionPtr create_with_int_data_type(const DataTypes& argument_type) {
29
4
    switch (argument_type[0]->get_primitive_type()) {
30
1
    case PrimitiveType::TYPE_TINYINT:
31
1
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt8>>(argument_type);
32
1
    case PrimitiveType::TYPE_SMALLINT:
33
1
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt16>>(argument_type);
34
1
    case PrimitiveType::TYPE_INT:
35
1
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt32>>(argument_type);
36
1
    case PrimitiveType::TYPE_BIGINT:
37
1
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt64>>(argument_type);
38
0
    default:
39
0
        LOG(WARNING) << "with unknowed type, failed in create_with_int_data_type bitmap_union_int"
40
0
                     << " and type is: " << argument_type[0]->get_name();
41
0
        return nullptr;
42
4
    }
43
4
}
Unexecuted instantiation: _ZN5doris25create_with_int_data_typeILb1ENS_28AggregateFunctionBitmapCountEEESt10shared_ptrINS_18IAggregateFunctionEERKSt6vectorIS2_IKNS_9IDataTypeEESaIS8_EE
_ZN5doris25create_with_int_data_typeILb0ENS_28AggregateFunctionBitmapCountEEESt10shared_ptrINS_18IAggregateFunctionEERKSt6vectorIS2_IKNS_9IDataTypeEESaIS8_EE
Line
Count
Source
28
4
AggregateFunctionPtr create_with_int_data_type(const DataTypes& argument_type) {
29
4
    switch (argument_type[0]->get_primitive_type()) {
30
1
    case PrimitiveType::TYPE_TINYINT:
31
1
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt8>>(argument_type);
32
1
    case PrimitiveType::TYPE_SMALLINT:
33
1
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt16>>(argument_type);
34
1
    case PrimitiveType::TYPE_INT:
35
1
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt32>>(argument_type);
36
1
    case PrimitiveType::TYPE_BIGINT:
37
1
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt64>>(argument_type);
38
0
    default:
39
        LOG(WARNING) << "with unknowed type, failed in create_with_int_data_type bitmap_union_int"
40
0
                     << " and type is: " << argument_type[0]->get_name();
41
0
        return nullptr;
42
4
    }
43
4
}
44
45
AggregateFunctionPtr create_aggregate_function_bitmap_union_count(
46
        const std::string& name, const DataTypes& argument_types, const DataTypePtr& result_type,
47
1
        const bool result_is_nullable, const AggregateFunctionAttr& attr) {
48
1
    const bool arg_is_nullable = argument_types[0]->is_nullable();
49
1
    if (arg_is_nullable) {
50
0
        return std::make_shared<AggregateFunctionBitmapCount<true, ColumnBitmap>>(argument_types);
51
1
    } else {
52
1
        return std::make_shared<AggregateFunctionBitmapCount<false, ColumnBitmap>>(argument_types);
53
1
    }
54
1
}
55
56
AggregateFunctionPtr create_aggregate_function_bitmap_union_int(const std::string& name,
57
                                                                const DataTypes& argument_types,
58
                                                                const DataTypePtr& result_type,
59
                                                                const bool result_is_nullable,
60
4
                                                                const AggregateFunctionAttr& attr) {
61
4
    const bool arg_is_nullable = argument_types[0]->is_nullable();
62
4
    if (arg_is_nullable) {
63
0
        return AggregateFunctionPtr(
64
0
                create_with_int_data_type<true, AggregateFunctionBitmapCount>(argument_types));
65
4
    } else {
66
4
        return AggregateFunctionPtr(
67
4
                create_with_int_data_type<false, AggregateFunctionBitmapCount>(argument_types));
68
4
    }
69
4
}
70
71
9
void register_aggregate_function_bitmap(AggregateFunctionSimpleFactory& factory) {
72
9
    factory.register_function_both(
73
9
            "bitmap_union", creator_without_type::creator<
74
9
                                    AggregateFunctionBitmapOp<AggregateFunctionBitmapUnionOp>>);
75
9
    factory.register_function_both(
76
9
            "bitmap_intersect",
77
9
            creator_without_type::creator<
78
9
                    AggregateFunctionBitmapOp<AggregateFunctionBitmapIntersectOp>>);
79
9
    factory.register_function_both(
80
9
            "group_bitmap_xor",
81
9
            creator_without_type::creator<
82
9
                    AggregateFunctionBitmapOp<AggregateFunctionGroupBitmapXorOp>>);
83
9
    factory.register_function_both("bitmap_union_count",
84
9
                                   create_aggregate_function_bitmap_union_count);
85
9
    factory.register_function_both("bitmap_union_int", create_aggregate_function_bitmap_union_int);
86
9
}
87
} // namespace doris