Coverage Report

Created: 2026-03-13 03:47

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
#include "common/compile_check_begin.h"
27
28
template <bool nullable, template <bool, typename> class AggregateFunctionTemplate>
29
485
AggregateFunctionPtr create_with_int_data_type(const DataTypes& argument_type) {
30
485
    switch (argument_type[0]->get_primitive_type()) {
31
20
    case PrimitiveType::TYPE_TINYINT:
32
20
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt8>>(argument_type);
33
23
    case PrimitiveType::TYPE_SMALLINT:
34
23
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt16>>(argument_type);
35
443
    case PrimitiveType::TYPE_INT:
36
443
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt32>>(argument_type);
37
1
    case PrimitiveType::TYPE_BIGINT:
38
1
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt64>>(argument_type);
39
0
    default:
40
0
        LOG(WARNING) << "with unknowed type, failed in create_with_int_data_type bitmap_union_int"
41
0
                     << " and type is: " << argument_type[0]->get_name();
42
0
        return nullptr;
43
485
    }
44
485
}
_ZN5doris25create_with_int_data_typeILb1ENS_28AggregateFunctionBitmapCountEEESt10shared_ptrINS_18IAggregateFunctionEERKSt6vectorIS2_IKNS_9IDataTypeEESaIS8_EE
Line
Count
Source
29
451
AggregateFunctionPtr create_with_int_data_type(const DataTypes& argument_type) {
30
451
    switch (argument_type[0]->get_primitive_type()) {
31
11
    case PrimitiveType::TYPE_TINYINT:
32
11
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt8>>(argument_type);
33
14
    case PrimitiveType::TYPE_SMALLINT:
34
14
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt16>>(argument_type);
35
428
    case PrimitiveType::TYPE_INT:
36
428
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt32>>(argument_type);
37
0
    case PrimitiveType::TYPE_BIGINT:
38
0
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt64>>(argument_type);
39
0
    default:
40
        LOG(WARNING) << "with unknowed type, failed in create_with_int_data_type bitmap_union_int"
41
0
                     << " and type is: " << argument_type[0]->get_name();
42
0
        return nullptr;
43
451
    }
44
451
}
_ZN5doris25create_with_int_data_typeILb0ENS_28AggregateFunctionBitmapCountEEESt10shared_ptrINS_18IAggregateFunctionEERKSt6vectorIS2_IKNS_9IDataTypeEESaIS8_EE
Line
Count
Source
29
34
AggregateFunctionPtr create_with_int_data_type(const DataTypes& argument_type) {
30
34
    switch (argument_type[0]->get_primitive_type()) {
31
9
    case PrimitiveType::TYPE_TINYINT:
32
9
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt8>>(argument_type);
33
9
    case PrimitiveType::TYPE_SMALLINT:
34
9
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt16>>(argument_type);
35
15
    case PrimitiveType::TYPE_INT:
36
15
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt32>>(argument_type);
37
1
    case PrimitiveType::TYPE_BIGINT:
38
1
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt64>>(argument_type);
39
0
    default:
40
        LOG(WARNING) << "with unknowed type, failed in create_with_int_data_type bitmap_union_int"
41
0
                     << " and type is: " << argument_type[0]->get_name();
42
0
        return nullptr;
43
34
    }
44
34
}
45
46
AggregateFunctionPtr create_aggregate_function_bitmap_union_count(
47
        const std::string& name, const DataTypes& argument_types, const DataTypePtr& result_type,
48
529
        const bool result_is_nullable, const AggregateFunctionAttr& attr) {
49
529
    const bool arg_is_nullable = argument_types[0]->is_nullable();
50
529
    if (arg_is_nullable) {
51
3
        return std::make_shared<AggregateFunctionBitmapCount<true, ColumnBitmap>>(argument_types);
52
526
    } else {
53
526
        return std::make_shared<AggregateFunctionBitmapCount<false, ColumnBitmap>>(argument_types);
54
526
    }
55
529
}
56
57
AggregateFunctionPtr create_aggregate_function_bitmap_union_int(const std::string& name,
58
                                                                const DataTypes& argument_types,
59
                                                                const DataTypePtr& result_type,
60
                                                                const bool result_is_nullable,
61
487
                                                                const AggregateFunctionAttr& attr) {
62
487
    const bool arg_is_nullable = argument_types[0]->is_nullable();
63
487
    if (arg_is_nullable) {
64
452
        return AggregateFunctionPtr(
65
452
                create_with_int_data_type<true, AggregateFunctionBitmapCount>(argument_types));
66
452
    } else {
67
35
        return AggregateFunctionPtr(
68
35
                create_with_int_data_type<false, AggregateFunctionBitmapCount>(argument_types));
69
35
    }
70
487
}
71
72
16
void register_aggregate_function_bitmap(AggregateFunctionSimpleFactory& factory) {
73
16
    factory.register_function_both(
74
16
            "bitmap_union", creator_without_type::creator<
75
16
                                    AggregateFunctionBitmapOp<AggregateFunctionBitmapUnionOp>>);
76
16
    factory.register_function_both(
77
16
            "bitmap_intersect",
78
16
            creator_without_type::creator<
79
16
                    AggregateFunctionBitmapOp<AggregateFunctionBitmapIntersectOp>>);
80
16
    factory.register_function_both(
81
16
            "group_bitmap_xor",
82
16
            creator_without_type::creator<
83
16
                    AggregateFunctionBitmapOp<AggregateFunctionGroupBitmapXorOp>>);
84
16
    factory.register_function_both("bitmap_union_count",
85
16
                                   create_aggregate_function_bitmap_union_count);
86
16
    factory.register_function_both("bitmap_union_int", create_aggregate_function_bitmap_union_int);
87
16
}
88
} // namespace doris