Coverage Report

Created: 2026-03-28 19:32

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
60.9k
    static void run(LoopType target, TArgs&&... args) {
29
60.9k
        if constexpr (start <= end) {
30
54.6k
            if (start == target) {
31
2.39k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
52.2k
            } else {
33
52.2k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
52.2k
                        target, std::forward<TArgs>(args)...);
35
52.2k
            }
36
54.6k
        }
37
60.9k
    }
_ZN5doris20constexpr_loop_matchIiLi1ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
8.71k
    static void run(LoopType target, TArgs&&... args) {
29
8.71k
        if constexpr (start <= end) {
30
8.71k
            if (start == target) {
31
1.39k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
7.32k
            } else {
33
7.32k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
7.32k
                        target, std::forward<TArgs>(args)...);
35
7.32k
            }
36
8.71k
        }
37
8.71k
    }
_ZN5doris20constexpr_loop_matchIiLi2ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
7.32k
    static void run(LoopType target, TArgs&&... args) {
29
7.32k
        if constexpr (start <= end) {
30
7.32k
            if (start == target) {
31
461
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.86k
            } else {
33
6.86k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.86k
                        target, std::forward<TArgs>(args)...);
35
6.86k
            }
36
7.32k
        }
37
7.32k
    }
_ZN5doris20constexpr_loop_matchIiLi3ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.86k
    static void run(LoopType target, TArgs&&... args) {
29
6.86k
        if constexpr (start <= end) {
30
6.86k
            if (start == target) {
31
501
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.36k
            } else {
33
6.36k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.36k
                        target, std::forward<TArgs>(args)...);
35
6.36k
            }
36
6.86k
        }
37
6.86k
    }
_ZN5doris20constexpr_loop_matchIiLi4ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.36k
    static void run(LoopType target, TArgs&&... args) {
29
6.36k
        if constexpr (start <= end) {
30
6.36k
            if (start == target) {
31
18
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.34k
            } else {
33
6.34k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.34k
                        target, std::forward<TArgs>(args)...);
35
6.34k
            }
36
6.36k
        }
37
6.36k
    }
_ZN5doris20constexpr_loop_matchIiLi5ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.34k
    static void run(LoopType target, TArgs&&... args) {
29
6.34k
        if constexpr (start <= end) {
30
6.34k
            if (start == target) {
31
10
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.33k
            } else {
33
6.33k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.33k
                        target, std::forward<TArgs>(args)...);
35
6.33k
            }
36
6.34k
        }
37
6.34k
    }
_ZN5doris20constexpr_loop_matchIiLi6ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.33k
    static void run(LoopType target, TArgs&&... args) {
29
6.33k
        if constexpr (start <= end) {
30
6.33k
            if (start == target) {
31
8
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.32k
            } else {
33
6.32k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.32k
                        target, std::forward<TArgs>(args)...);
35
6.32k
            }
36
6.33k
        }
37
6.33k
    }
_ZN5doris20constexpr_loop_matchIiLi7ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.32k
    static void run(LoopType target, TArgs&&... args) {
29
6.32k
        if constexpr (start <= end) {
30
6.32k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.32k
            } else {
33
6.32k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.32k
                        target, std::forward<TArgs>(args)...);
35
6.32k
            }
36
6.32k
        }
37
6.32k
    }
_ZN5doris20constexpr_loop_matchIiLi8ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.32k
    static void run(LoopType target, TArgs&&... args) {
29
6.32k
        if constexpr (start <= end) {
30
6.32k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.32k
            } else {
33
6.32k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.32k
                        target, std::forward<TArgs>(args)...);
35
6.32k
            }
36
6.32k
        }
37
6.32k
    }
_ZN5doris20constexpr_loop_matchIiLi9ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.32k
    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
6.32k
    }
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.20M
std::variant<std::false_type, std::true_type> inline make_bool_variant(bool condition) {
44
1.20M
    if (condition) {
45
624k
        return std::true_type {};
46
624k
    } else {
47
583k
        return std::false_type {};
48
583k
    }
49
1.20M
}
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