Coverage Report

Created: 2026-03-25 16:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/common/template_helpers.hpp
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
#pragma once
19
20
#include <limits>
21
#include <variant>
22
23
namespace doris {
24
25
template <typename LoopType, LoopType start, LoopType end, template <LoopType> typename Reducer>
26
struct constexpr_loop_match {
27
    template <typename... TArgs>
28
54.1k
    static void run(LoopType target, TArgs&&... args) {
29
54.1k
        if constexpr (start <= end) {
30
48.5k
            if (start == target) {
31
2.73k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
45.8k
            } else {
33
45.8k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
45.8k
                        target, std::forward<TArgs>(args)...);
35
45.8k
            }
36
48.5k
        }
37
54.1k
    }
_ZN5doris20constexpr_loop_matchIiLi1ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
8.25k
    static void run(LoopType target, TArgs&&... args) {
29
8.25k
        if constexpr (start <= end) {
30
8.25k
            if (start == target) {
31
1.64k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.61k
            } else {
33
6.61k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.61k
                        target, std::forward<TArgs>(args)...);
35
6.61k
            }
36
8.25k
        }
37
8.25k
    }
_ZN5doris20constexpr_loop_matchIiLi2ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.61k
    static void run(LoopType target, TArgs&&... args) {
29
6.61k
        if constexpr (start <= end) {
30
6.61k
            if (start == target) {
31
554
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.05k
            } else {
33
6.05k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.05k
                        target, std::forward<TArgs>(args)...);
35
6.05k
            }
36
6.61k
        }
37
6.61k
    }
_ZN5doris20constexpr_loop_matchIiLi3ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.05k
    static void run(LoopType target, TArgs&&... args) {
29
6.05k
        if constexpr (start <= end) {
30
6.05k
            if (start == target) {
31
506
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.55k
            } else {
33
5.55k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.55k
                        target, std::forward<TArgs>(args)...);
35
5.55k
            }
36
6.05k
        }
37
6.05k
    }
_ZN5doris20constexpr_loop_matchIiLi4ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.55k
    static void run(LoopType target, TArgs&&... args) {
29
5.55k
        if constexpr (start <= end) {
30
5.55k
            if (start == target) {
31
16
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.53k
            } else {
33
5.53k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.53k
                        target, std::forward<TArgs>(args)...);
35
5.53k
            }
36
5.55k
        }
37
5.55k
    }
_ZN5doris20constexpr_loop_matchIiLi5ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.53k
    static void run(LoopType target, TArgs&&... args) {
29
5.53k
        if constexpr (start <= end) {
30
5.53k
            if (start == target) {
31
10
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.52k
            } else {
33
5.52k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.52k
                        target, std::forward<TArgs>(args)...);
35
5.52k
            }
36
5.53k
        }
37
5.53k
    }
_ZN5doris20constexpr_loop_matchIiLi6ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.52k
    static void run(LoopType target, TArgs&&... args) {
29
5.52k
        if constexpr (start <= end) {
30
5.52k
            if (start == target) {
31
4
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.52k
            } else {
33
5.52k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.52k
                        target, std::forward<TArgs>(args)...);
35
5.52k
            }
36
5.52k
        }
37
5.52k
    }
_ZN5doris20constexpr_loop_matchIiLi7ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.52k
    static void run(LoopType target, TArgs&&... args) {
29
5.52k
        if constexpr (start <= end) {
30
5.52k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.52k
            } else {
33
5.52k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.52k
                        target, std::forward<TArgs>(args)...);
35
5.52k
            }
36
5.52k
        }
37
5.52k
    }
_ZN5doris20constexpr_loop_matchIiLi8ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.52k
    static void run(LoopType target, TArgs&&... args) {
29
5.52k
        if constexpr (start <= end) {
30
5.52k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.52k
            } else {
33
5.52k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.52k
                        target, std::forward<TArgs>(args)...);
35
5.52k
            }
36
5.52k
        }
37
5.52k
    }
_ZN5doris20constexpr_loop_matchIiLi9ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.52k
    static void run(LoopType target, TArgs&&... args) {
29
        if constexpr (start <= end) {
30
            if (start == target) {
31
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
            } else {
33
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
                        target, std::forward<TArgs>(args)...);
35
            }
36
        }
37
5.52k
    }
38
};
39
40
template <int start, int end, template <int> typename Reducer>
41
using constexpr_int_match = constexpr_loop_match<int, start, end, Reducer>;
42
43
1.11M
std::variant<std::false_type, std::true_type> inline make_bool_variant(bool condition) {
44
1.11M
    if (condition) {
45
572k
        return std::true_type {};
46
572k
    } else {
47
544k
        return std::false_type {};
48
544k
    }
49
1.11M
}
50
51
template <typename... Callables>
52
struct Overload : Callables... {
53
    using Callables::operator()...;
54
};
55
56
template <typename... Callables>
57
Overload(Callables&&... callables) -> Overload<Callables...>;
58
59
} // namespace  doris