Coverage Report

Created: 2026-03-13 03:47

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
63.4k
    static void run(LoopType target, TArgs&&... args) {
29
63.4k
        if constexpr (start <= end) {
30
56.9k
            if (start == target) {
31
2.98k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
53.9k
            } else {
33
53.9k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
53.9k
                        target, std::forward<TArgs>(args)...);
35
53.9k
            }
36
56.9k
        }
37
63.4k
    }
_ZN5doris20constexpr_loop_matchIiLi1ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
9.47k
    static void run(LoopType target, TArgs&&... args) {
29
9.47k
        if constexpr (start <= end) {
30
9.47k
            if (start == target) {
31
1.65k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
7.82k
            } else {
33
7.82k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
7.82k
                        target, std::forward<TArgs>(args)...);
35
7.82k
            }
36
9.47k
        }
37
9.47k
    }
_ZN5doris20constexpr_loop_matchIiLi2ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
7.82k
    static void run(LoopType target, TArgs&&... args) {
29
7.82k
        if constexpr (start <= end) {
30
7.82k
            if (start == target) {
31
721
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
7.10k
            } else {
33
7.10k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
7.10k
                        target, std::forward<TArgs>(args)...);
35
7.10k
            }
36
7.82k
        }
37
7.82k
    }
_ZN5doris20constexpr_loop_matchIiLi3ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
7.10k
    static void run(LoopType target, TArgs&&... args) {
29
7.10k
        if constexpr (start <= end) {
30
7.10k
            if (start == target) {
31
571
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.52k
            } else {
33
6.52k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.52k
                        target, std::forward<TArgs>(args)...);
35
6.52k
            }
36
7.10k
        }
37
7.10k
    }
_ZN5doris20constexpr_loop_matchIiLi4ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.52k
    static void run(LoopType target, TArgs&&... args) {
29
6.52k
        if constexpr (start <= end) {
30
6.52k
            if (start == target) {
31
18
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.51k
            } else {
33
6.51k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.51k
                        target, std::forward<TArgs>(args)...);
35
6.51k
            }
36
6.52k
        }
37
6.52k
    }
_ZN5doris20constexpr_loop_matchIiLi5ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.51k
    static void run(LoopType target, TArgs&&... args) {
29
6.51k
        if constexpr (start <= end) {
30
6.51k
            if (start == target) {
31
10
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.50k
            } else {
33
6.50k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.50k
                        target, std::forward<TArgs>(args)...);
35
6.50k
            }
36
6.51k
        }
37
6.51k
    }
_ZN5doris20constexpr_loop_matchIiLi6ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.50k
    static void run(LoopType target, TArgs&&... args) {
29
6.50k
        if constexpr (start <= end) {
30
6.50k
            if (start == target) {
31
8
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.49k
            } else {
33
6.49k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.49k
                        target, std::forward<TArgs>(args)...);
35
6.49k
            }
36
6.50k
        }
37
6.50k
    }
_ZN5doris20constexpr_loop_matchIiLi7ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.49k
    static void run(LoopType target, TArgs&&... args) {
29
6.49k
        if constexpr (start <= end) {
30
6.49k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.49k
            } else {
33
6.49k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.49k
                        target, std::forward<TArgs>(args)...);
35
6.49k
            }
36
6.49k
        }
37
6.49k
    }
_ZN5doris20constexpr_loop_matchIiLi8ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.49k
    static void run(LoopType target, TArgs&&... args) {
29
6.49k
        if constexpr (start <= end) {
30
6.49k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.49k
            } else {
33
6.49k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.49k
                        target, std::forward<TArgs>(args)...);
35
6.49k
            }
36
6.49k
        }
37
6.49k
    }
_ZN5doris20constexpr_loop_matchIiLi9ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.49k
    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.49k
    }
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.34M
std::variant<std::false_type, std::true_type> inline make_bool_variant(bool condition) {
44
1.34M
    if (condition) {
45
541k
        return std::true_type {};
46
805k
    } else {
47
805k
        return std::false_type {};
48
805k
    }
49
1.34M
}
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