Coverage Report

Created: 2026-03-19 11:39

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
489
AggregateFunctionPtr create_with_int_data_type(const DataTypes& argument_type) {
30
489
    switch (argument_type[0]->get_primitive_type()) {
31
21
    case PrimitiveType::TYPE_TINYINT:
32
21
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt8>>(argument_type);
33
24
    case PrimitiveType::TYPE_SMALLINT:
34
24
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt16>>(argument_type);
35
442
    case PrimitiveType::TYPE_INT:
36
442
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt32>>(argument_type);
37
2
    case PrimitiveType::TYPE_BIGINT:
38
2
        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
489
    }
44
489
}
_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
426
    case PrimitiveType::TYPE_INT:
36
426
        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
38
AggregateFunctionPtr create_with_int_data_type(const DataTypes& argument_type) {
30
38
    switch (argument_type[0]->get_primitive_type()) {
31
10
    case PrimitiveType::TYPE_TINYINT:
32
10
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt8>>(argument_type);
33
10
    case PrimitiveType::TYPE_SMALLINT:
34
10
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt16>>(argument_type);
35
16
    case PrimitiveType::TYPE_INT:
36
16
        return std::make_shared<AggregateFunctionTemplate<nullable, ColumnInt32>>(argument_type);
37
2
    case PrimitiveType::TYPE_BIGINT:
38
2
        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
38
    }
44
38
}
45
46
AggregateFunctionPtr create_aggregate_function_bitmap_union_count(
47
        const std::string& name, const DataTypes& argument_types, const DataTypePtr& result_type,
48
623
        const bool result_is_nullable, const AggregateFunctionAttr& attr) {
49
623
    const bool arg_is_nullable = argument_types[0]->is_nullable();
50
623
    if (arg_is_nullable) {
51
3
        return std::make_shared<AggregateFunctionBitmapCount<true, ColumnBitmap>>(argument_types);
52
620
    } else {
53
620
        return std::make_shared<AggregateFunctionBitmapCount<false, ColumnBitmap>>(argument_types);
54
620
    }
55
623
}
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
490
                                                                const AggregateFunctionAttr& attr) {
62
490
    const bool arg_is_nullable = argument_types[0]->is_nullable();
63
490
    if (arg_is_nullable) {
64
452
        return AggregateFunctionPtr(
65
452
                create_with_int_data_type<true, AggregateFunctionBitmapCount>(argument_types));
66
452
    } else {
67
38
        return AggregateFunctionPtr(
68
38
                create_with_int_data_type<false, AggregateFunctionBitmapCount>(argument_types));
69
38
    }
70
490
}
71
72
23
void register_aggregate_function_bitmap(AggregateFunctionSimpleFactory& factory) {
73
23
    factory.register_function_both(
74
23
            "bitmap_union", creator_without_type::creator<
75
23
                                    AggregateFunctionBitmapOp<AggregateFunctionBitmapUnionOp>>);
76
23
    factory.register_function_both(
77
23
            "bitmap_intersect",
78
23
            creator_without_type::creator<
79
23
                    AggregateFunctionBitmapOp<AggregateFunctionBitmapIntersectOp>>);
80
23
    factory.register_function_both(
81
23
            "group_bitmap_xor",
82
23
            creator_without_type::creator<
83
23
                    AggregateFunctionBitmapOp<AggregateFunctionGroupBitmapXorOp>>);
84
23
    factory.register_function_both("bitmap_union_count",
85
23
                                   create_aggregate_function_bitmap_union_count);
86
23
    factory.register_function_both("bitmap_union_int", create_aggregate_function_bitmap_union_int);
87
23
}
88
} // namespace doris