Coverage Report

Created: 2026-04-10 12:12

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
484
AggregateFunctionPtr create_with_int_data_type(const DataTypes& argument_type) {
29
484
    switch (argument_type[0]->get_primitive_type()) {
30
20
    case PrimitiveType::TYPE_TINYINT:
31
20
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt8>>(argument_type);
32
23
    case PrimitiveType::TYPE_SMALLINT:
33
23
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt16>>(argument_type);
34
439
    case PrimitiveType::TYPE_INT:
35
439
        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
484
    }
43
484
}
_ZN5doris25create_with_int_data_typeILb1ENS_28AggregateFunctionBitmapCountEEESt10shared_ptrINS_18IAggregateFunctionEERKSt6vectorIS2_IKNS_9IDataTypeEESaIS8_EE
Line
Count
Source
28
450
AggregateFunctionPtr create_with_int_data_type(const DataTypes& argument_type) {
29
450
    switch (argument_type[0]->get_primitive_type()) {
30
11
    case PrimitiveType::TYPE_TINYINT:
31
11
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt8>>(argument_type);
32
14
    case PrimitiveType::TYPE_SMALLINT:
33
14
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt16>>(argument_type);
34
424
    case PrimitiveType::TYPE_INT:
35
424
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt32>>(argument_type);
36
0
    case PrimitiveType::TYPE_BIGINT:
37
0
        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
450
    }
43
450
}
_ZN5doris25create_with_int_data_typeILb0ENS_28AggregateFunctionBitmapCountEEESt10shared_ptrINS_18IAggregateFunctionEERKSt6vectorIS2_IKNS_9IDataTypeEESaIS8_EE
Line
Count
Source
28
34
AggregateFunctionPtr create_with_int_data_type(const DataTypes& argument_type) {
29
34
    switch (argument_type[0]->get_primitive_type()) {
30
9
    case PrimitiveType::TYPE_TINYINT:
31
9
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt8>>(argument_type);
32
9
    case PrimitiveType::TYPE_SMALLINT:
33
9
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt16>>(argument_type);
34
15
    case PrimitiveType::TYPE_INT:
35
15
        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
34
    }
43
34
}
44
45
AggregateFunctionPtr create_aggregate_function_bitmap_union_count(
46
        const std::string& name, const DataTypes& argument_types, const DataTypePtr& result_type,
47
580
        const bool result_is_nullable, const AggregateFunctionAttr& attr) {
48
580
    const bool arg_is_nullable = argument_types[0]->is_nullable();
49
580
    if (arg_is_nullable) {
50
3
        return std::make_shared<AggregateFunctionBitmapCount<true, ColumnBitmap>>(argument_types);
51
577
    } else {
52
577
        return std::make_shared<AggregateFunctionBitmapCount<false, ColumnBitmap>>(argument_types);
53
577
    }
54
580
}
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
483
                                                                const AggregateFunctionAttr& attr) {
61
483
    const bool arg_is_nullable = argument_types[0]->is_nullable();
62
483
    if (arg_is_nullable) {
63
449
        return AggregateFunctionPtr(
64
449
                create_with_int_data_type<true, AggregateFunctionBitmapCount>(argument_types));
65
449
    } else {
66
34
        return AggregateFunctionPtr(
67
34
                create_with_int_data_type<false, AggregateFunctionBitmapCount>(argument_types));
68
34
    }
69
483
}
70
71
12
void register_aggregate_function_bitmap(AggregateFunctionSimpleFactory& factory) {
72
12
    factory.register_function_both(
73
12
            "bitmap_union", creator_without_type::creator<
74
12
                                    AggregateFunctionBitmapOp<AggregateFunctionBitmapUnionOp>>);
75
12
    factory.register_function_both(
76
12
            "bitmap_intersect",
77
12
            creator_without_type::creator<
78
12
                    AggregateFunctionBitmapOp<AggregateFunctionBitmapIntersectOp>>);
79
12
    factory.register_function_both(
80
12
            "group_bitmap_xor",
81
12
            creator_without_type::creator<
82
12
                    AggregateFunctionBitmapOp<AggregateFunctionGroupBitmapXorOp>>);
83
12
    factory.register_function_both("bitmap_union_count",
84
12
                                   create_aggregate_function_bitmap_union_count);
85
12
    factory.register_function_both("bitmap_union_int", create_aggregate_function_bitmap_union_int);
86
12
}
87
} // namespace doris