Coverage Report

Created: 2026-05-20 18:18

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
44.6k
    static void run(LoopType target, TArgs&&... args) {
29
44.6k
        if constexpr (start <= end) {
30
40.0k
            if (start == target) {
31
2.12k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
37.9k
            } else {
33
37.9k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
37.9k
                        target, std::forward<TArgs>(args)...);
35
37.9k
            }
36
40.0k
        }
37
44.6k
    }
_ZN5doris20constexpr_loop_matchIiLi1ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
6.71k
    static void run(LoopType target, TArgs&&... args) {
29
6.71k
        if constexpr (start <= end) {
30
6.71k
            if (start == target) {
31
1.26k
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
5.44k
            } else {
33
5.44k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
5.44k
                        target, std::forward<TArgs>(args)...);
35
5.44k
            }
36
6.71k
        }
37
6.71k
    }
_ZN5doris20constexpr_loop_matchIiLi2ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
5.44k
    static void run(LoopType target, TArgs&&... args) {
29
5.44k
        if constexpr (start <= end) {
30
5.44k
            if (start == target) {
31
502
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.94k
            } else {
33
4.94k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.94k
                        target, std::forward<TArgs>(args)...);
35
4.94k
            }
36
5.44k
        }
37
5.44k
    }
_ZN5doris20constexpr_loop_matchIiLi3ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.94k
    static void run(LoopType target, TArgs&&... args) {
29
4.94k
        if constexpr (start <= end) {
30
4.94k
            if (start == target) {
31
326
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.61k
            } else {
33
4.61k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.61k
                        target, std::forward<TArgs>(args)...);
35
4.61k
            }
36
4.94k
        }
37
4.94k
    }
_ZN5doris20constexpr_loop_matchIiLi4ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.61k
    static void run(LoopType target, TArgs&&... args) {
29
4.61k
        if constexpr (start <= end) {
30
4.61k
            if (start == target) {
31
16
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.60k
            } else {
33
4.60k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.60k
                        target, std::forward<TArgs>(args)...);
35
4.60k
            }
36
4.61k
        }
37
4.61k
    }
_ZN5doris20constexpr_loop_matchIiLi5ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.60k
    static void run(LoopType target, TArgs&&... args) {
29
4.60k
        if constexpr (start <= end) {
30
4.60k
            if (start == target) {
31
9
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.59k
            } else {
33
4.59k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.59k
                        target, std::forward<TArgs>(args)...);
35
4.59k
            }
36
4.60k
        }
37
4.60k
    }
_ZN5doris20constexpr_loop_matchIiLi6ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.59k
    static void run(LoopType target, TArgs&&... args) {
29
4.59k
        if constexpr (start <= end) {
30
4.59k
            if (start == target) {
31
5
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.58k
            } else {
33
4.58k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.58k
                        target, std::forward<TArgs>(args)...);
35
4.58k
            }
36
4.59k
        }
37
4.59k
    }
_ZN5doris20constexpr_loop_matchIiLi7ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.58k
    static void run(LoopType target, TArgs&&... args) {
29
4.58k
        if constexpr (start <= end) {
30
4.58k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.58k
            } else {
33
4.58k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.58k
                        target, std::forward<TArgs>(args)...);
35
4.58k
            }
36
4.58k
        }
37
4.58k
    }
_ZN5doris20constexpr_loop_matchIiLi8ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.58k
    static void run(LoopType target, TArgs&&... args) {
29
4.58k
        if constexpr (start <= end) {
30
4.58k
            if (start == target) {
31
0
                Reducer<start>::run(std::forward<TArgs>(args)...);
32
4.58k
            } else {
33
4.58k
                constexpr_loop_match<LoopType, start + 1, end, Reducer>::run(
34
4.58k
                        target, std::forward<TArgs>(args)...);
35
4.58k
            }
36
4.58k
        }
37
4.58k
    }
_ZN5doris20constexpr_loop_matchIiLi9ELi8ENS_19PackNullmapsReducerEE3runIJPPKhPhRmmS7_EEEviDpOT_
Line
Count
Source
28
4.58k
    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.58k
    }
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
449k
std::variant<std::false_type, std::true_type> inline make_bool_variant(bool condition) {
44
449k
    if (condition) {
45
212k
        return std::true_type {};
46
237k
    } else {
47
237k
        return std::false_type {};
48
237k
    }
49
449k
}
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