Coverage Report

Created: 2026-06-18 05:36

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
46.3k
    static void run(LoopType target, TArgs&&... args) {
29
46.3k
        if constexpr (start <= end) {
30
41.6k
            if (start == target) {
31
2.27k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
39.3k
            } else {
33
39.3k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
39.3k
                        target, std::forward<TArgs>(args)...);
35
39.3k
            }
36
41.6k
        }
37
46.3k
    }
_ZN5doris20constexpr_loop_matchIiLi1ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
7.02k
    static void run(LoopType target, TArgs&&... args) {
29
7.02k
        if constexpr (start <= end) {
30
7.02k
            if (start == target) {
31
1.35k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.67k
            } else {
33
5.67k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.67k
                        target, std::forward<TArgs>(args)...);
35
5.67k
            }
36
7.02k
        }
37
7.02k
    }
_ZN5doris20constexpr_loop_matchIiLi2ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.67k
    static void run(LoopType target, TArgs&&... args) {
29
5.67k
        if constexpr (start <= end) {
30
5.67k
            if (start == target) {
31
547
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.12k
            } else {
33
5.12k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.12k
                        target, std::forward<TArgs>(args)...);
35
5.12k
            }
36
5.67k
        }
37
5.67k
    }
_ZN5doris20constexpr_loop_matchIiLi3ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.12k
    static void run(LoopType target, TArgs&&... args) {
29
5.12k
        if constexpr (start <= end) {
30
5.12k
            if (start == target) {
31
342
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.78k
            } else {
33
4.78k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.78k
                        target, std::forward<TArgs>(args)...);
35
4.78k
            }
36
5.12k
        }
37
5.12k
    }
_ZN5doris20constexpr_loop_matchIiLi4ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.78k
    static void run(LoopType target, TArgs&&... args) {
29
4.78k
        if constexpr (start <= end) {
30
4.78k
            if (start == target) {
31
20
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.76k
            } else {
33
4.76k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.76k
                        target, std::forward<TArgs>(args)...);
35
4.76k
            }
36
4.78k
        }
37
4.78k
    }
_ZN5doris20constexpr_loop_matchIiLi5ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.76k
    static void run(LoopType target, TArgs&&... args) {
29
4.76k
        if constexpr (start <= end) {
30
4.76k
            if (start == target) {
31
10
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.75k
            } else {
33
4.75k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.75k
                        target, std::forward<TArgs>(args)...);
35
4.75k
            }
36
4.76k
        }
37
4.76k
    }
_ZN5doris20constexpr_loop_matchIiLi6ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.75k
    static void run(LoopType target, TArgs&&... args) {
29
4.75k
        if constexpr (start <= end) {
30
4.75k
            if (start == target) {
31
5
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.75k
            } else {
33
4.75k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.75k
                        target, std::forward<TArgs>(args)...);
35
4.75k
            }
36
4.75k
        }
37
4.75k
    }
_ZN5doris20constexpr_loop_matchIiLi7ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.75k
    static void run(LoopType target, TArgs&&... args) {
29
4.75k
        if constexpr (start <= end) {
30
4.75k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.75k
            } else {
33
4.75k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.75k
                        target, std::forward<TArgs>(args)...);
35
4.75k
            }
36
4.75k
        }
37
4.75k
    }
_ZN5doris20constexpr_loop_matchIiLi8ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.75k
    static void run(LoopType target, TArgs&&... args) {
29
4.75k
        if constexpr (start <= end) {
30
4.75k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.75k
            } else {
33
4.75k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.75k
                        target, std::forward<TArgs>(args)...);
35
4.75k
            }
36
4.75k
        }
37
4.75k
    }
_ZN5doris20constexpr_loop_matchIiLi9ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.75k
    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
4.75k
    }
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
491k
std::variant<std::false_type, std::true_type> inline make_bool_variant(bool condition) {
44
491k
    if (condition) {
45
259k
        return std::true_type {};
46
259k
    } else {
47
232k
        return std::false_type {};
48
232k
    }
49
491k
}
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