Coverage Report

Created: 2026-07-27 20:46

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.0k
    static void run(LoopType target, TArgs&&... args) {
29
56.0k
        if constexpr (start <= end) {
30
50.3k
            if (start == target) {
31
2.96k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
47.3k
            } else {
33
47.3k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
47.3k
                        target, std::forward<TArgs>(args)...);
35
47.3k
            }
36
50.3k
        }
37
56.0k
    }
_ZN5doris20constexpr_loop_matchIiLi1ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
8.67k
    static void run(LoopType target, TArgs&&... args) {
29
8.67k
        if constexpr (start <= end) {
30
8.67k
            if (start == target) {
31
1.73k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.93k
            } else {
33
6.93k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.93k
                        target, std::forward<TArgs>(args)...);
35
6.93k
            }
36
8.67k
        }
37
8.67k
    }
_ZN5doris20constexpr_loop_matchIiLi2ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.93k
    static void run(LoopType target, TArgs&&... args) {
29
6.93k
        if constexpr (start <= end) {
30
6.93k
            if (start == target) {
31
799
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
6.13k
            } else {
33
6.13k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
6.13k
                        target, std::forward<TArgs>(args)...);
35
6.13k
            }
36
6.93k
        }
37
6.93k
    }
_ZN5doris20constexpr_loop_matchIiLi3ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.14k
    static void run(LoopType target, TArgs&&... args) {
29
6.14k
        if constexpr (start <= end) {
30
6.14k
            if (start == target) {
31
397
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.74k
            } else {
33
5.74k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.74k
                        target, std::forward<TArgs>(args)...);
35
5.74k
            }
36
6.14k
        }
37
6.14k
    }
_ZN5doris20constexpr_loop_matchIiLi4ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.74k
    static void run(LoopType target, TArgs&&... args) {
29
5.74k
        if constexpr (start <= end) {
30
5.74k
            if (start == target) {
31
20
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.72k
            } else {
33
5.72k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.72k
                        target, std::forward<TArgs>(args)...);
35
5.72k
            }
36
5.74k
        }
37
5.74k
    }
_ZN5doris20constexpr_loop_matchIiLi5ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.72k
    static void run(LoopType target, TArgs&&... args) {
29
5.72k
        if constexpr (start <= end) {
30
5.72k
            if (start == target) {
31
10
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.71k
            } else {
33
5.71k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.71k
                        target, std::forward<TArgs>(args)...);
35
5.71k
            }
36
5.72k
        }
37
5.72k
    }
_ZN5doris20constexpr_loop_matchIiLi6ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.71k
    static void run(LoopType target, TArgs&&... args) {
29
5.71k
        if constexpr (start <= end) {
30
5.71k
            if (start == target) {
31
5
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.70k
            } else {
33
5.70k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.70k
                        target, std::forward<TArgs>(args)...);
35
5.70k
            }
36
5.71k
        }
37
5.71k
    }
_ZN5doris20constexpr_loop_matchIiLi7ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.70k
    static void run(LoopType target, TArgs&&... args) {
29
5.70k
        if constexpr (start <= end) {
30
5.70k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.70k
            } else {
33
5.70k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.70k
                        target, std::forward<TArgs>(args)...);
35
5.70k
            }
36
5.70k
        }
37
5.70k
    }
_ZN5doris20constexpr_loop_matchIiLi8ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.70k
    static void run(LoopType target, TArgs&&... args) {
29
5.70k
        if constexpr (start <= end) {
30
5.70k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.70k
            } else {
33
5.70k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.70k
                        target, std::forward<TArgs>(args)...);
35
5.70k
            }
36
5.70k
        }
37
5.70k
    }
_ZN5doris20constexpr_loop_matchIiLi9ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.70k
    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.70k
    }
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
573k
std::variant<std::false_type, std::true_type> inline make_bool_variant(bool condition) {
44
573k
    if (condition) {
45
284k
        return std::true_type {};
46
288k
    } else {
47
288k
        return std::false_type {};
48
288k
    }
49
573k
}
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