Coverage Report

Created: 2026-04-01 12:00

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
56.5k
    static void run(LoopType target, TArgs&&... args) {
29
56.5k
        if constexpr (start <= end) {
30
50.7k
            if (start == target) {
31
2.79k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
47.9k
            } else {
33
47.9k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
47.9k
                        target, std::forward<TArgs>(args)...);
35
47.9k
            }
36
50.7k
        }
37
56.5k
    }
_ZN5doris20constexpr_loop_matchIiLi1ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
8.57k
    static void run(LoopType target, TArgs&&... args) {
29
8.57k
        if constexpr (start <= end) {
30
8.57k
            if (start == target) {
31
1.58k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.99k
            } else {
33
6.99k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.99k
                        target, std::forward<TArgs>(args)...);
35
6.99k
            }
36
8.57k
        }
37
8.57k
    }
_ZN5doris20constexpr_loop_matchIiLi2ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.99k
    static void run(LoopType target, TArgs&&... args) {
29
6.99k
        if constexpr (start <= end) {
30
6.99k
            if (start == target) {
31
720
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.27k
            } else {
33
6.27k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.27k
                        target, std::forward<TArgs>(args)...);
35
6.27k
            }
36
6.99k
        }
37
6.99k
    }
_ZN5doris20constexpr_loop_matchIiLi3ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.27k
    static void run(LoopType target, TArgs&&... args) {
29
6.27k
        if constexpr (start <= end) {
30
6.27k
            if (start == target) {
31
451
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.82k
            } else {
33
5.82k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.82k
                        target, std::forward<TArgs>(args)...);
35
5.82k
            }
36
6.27k
        }
37
6.27k
    }
_ZN5doris20constexpr_loop_matchIiLi4ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.82k
    static void run(LoopType target, TArgs&&... args) {
29
5.82k
        if constexpr (start <= end) {
30
5.82k
            if (start == target) {
31
26
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.79k
            } else {
33
5.79k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.79k
                        target, std::forward<TArgs>(args)...);
35
5.79k
            }
36
5.82k
        }
37
5.82k
    }
_ZN5doris20constexpr_loop_matchIiLi5ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.79k
    static void run(LoopType target, TArgs&&... args) {
29
5.79k
        if constexpr (start <= end) {
30
5.79k
            if (start == target) {
31
10
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.78k
            } else {
33
5.78k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.78k
                        target, std::forward<TArgs>(args)...);
35
5.78k
            }
36
5.79k
        }
37
5.79k
    }
_ZN5doris20constexpr_loop_matchIiLi6ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.78k
    static void run(LoopType target, TArgs&&... args) {
29
5.78k
        if constexpr (start <= end) {
30
5.78k
            if (start == target) {
31
8
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.77k
            } else {
33
5.77k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.77k
                        target, std::forward<TArgs>(args)...);
35
5.77k
            }
36
5.78k
        }
37
5.78k
    }
_ZN5doris20constexpr_loop_matchIiLi7ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.77k
    static void run(LoopType target, TArgs&&... args) {
29
5.77k
        if constexpr (start <= end) {
30
5.77k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.77k
            } else {
33
5.77k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.77k
                        target, std::forward<TArgs>(args)...);
35
5.77k
            }
36
5.77k
        }
37
5.77k
    }
_ZN5doris20constexpr_loop_matchIiLi8ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.77k
    static void run(LoopType target, TArgs&&... args) {
29
5.77k
        if constexpr (start <= end) {
30
5.77k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.77k
            } else {
33
5.77k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.77k
                        target, std::forward<TArgs>(args)...);
35
5.77k
            }
36
5.77k
        }
37
5.77k
    }
_ZN5doris20constexpr_loop_matchIiLi9ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.77k
    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.77k
    }
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.08M
std::variant<std::false_type, std::true_type> inline make_bool_variant(bool condition) {
44
1.08M
    if (condition) {
45
561k
        return std::true_type {};
46
561k
    } else {
47
526k
        return std::false_type {};
48
526k
    }
49
1.08M
}
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