Coverage Report

Created: 2025-09-12 17:50

/root/doris/be/src/util/binary_cast.hpp
Line
Count
Source (jump to first uncovered line)
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 <cstddef>
21
#include <cstdint>
22
#include <type_traits>
23
24
#include "runtime/decimalv2_value.h"
25
#include "util/types.h"
26
#include "vec/core/wide_integer.h"
27
#include "vec/runtime/vdatetime_value.h"
28
namespace doris {
29
union TypeConverter {
30
    uint64_t u64;
31
    int64_t i64;
32
    uint32_t u32[2];
33
    int32_t i32[2];
34
    uint8_t u8[8];
35
    float flt[2];
36
    double dbl;
37
};
38
39
template <typename C0, typename C1, typename T0, typename T1>
40
constexpr bool match_v = std::is_same_v<C0, C1> && std::is_same_v<T0, T1>;
41
42
union DecimalInt128Union {
43
    DecimalV2Value decimal;
44
    PackedInt128 packed128;
45
    __int128_t i128;
46
};
47
48
static_assert(sizeof(DecimalV2Value) == sizeof(PackedInt128));
49
static_assert(sizeof(DecimalV2Value) == sizeof(__int128_t));
50
51
union VecDateTimeInt64Union {
52
    doris::VecDateTimeValue dt;
53
    __int64_t i64;
54
20.8k
    ~VecDateTimeInt64Union() {}
55
};
56
57
union DateV2UInt32Union {
58
    DateV2Value<DateV2ValueType> dt;
59
    uint32_t ui32;
60
1.32k
    ~DateV2UInt32Union() {}
61
};
62
63
union DateTimeV2UInt64Union {
64
    DateV2Value<DateTimeV2ValueType> dt;
65
    uint64_t ui64;
66
2.25k
    ~DateTimeV2UInt64Union() {}
67
};
68
69
// similar to reinterpret_cast but won't break strict-aliasing rules
70
template <typename From, typename To>
71
24.5k
To binary_cast(From from) {
72
24.5k
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
24.5k
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
24.5k
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
24.5k
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
24.5k
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
24.5k
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
24.5k
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
24.5k
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
24.5k
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
24.5k
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
24.5k
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
24.5k
    constexpr bool from_ui64_to_datetime_v2 =
87
24.5k
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
24.5k
    constexpr bool from_datetime_v2_to_ui64 =
90
24.5k
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
24.5k
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
24.5k
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
24.5k
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
24.5k
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
24.5k
    if constexpr (from_u64_to_db) {
  Branch (97:19): [Folded - Ignored]
  Branch (97:19): [Folded - Ignored]
  Branch (97:19): [Folded - Ignored]
  Branch (97:19): [Folded - Ignored]
  Branch (97:19): [Folded - Ignored]
  Branch (97:19): [Folded - Ignored]
  Branch (97:19): [Folded - Ignored]
  Branch (97:19): [Folded - Ignored]
  Branch (97:19): [Folded - Ignored]
  Branch (97:19): [Folded - Ignored]
  Branch (97:19): [Folded - Ignored]
98
24.5k
        TypeConverter conv;
99
24.5k
        conv.u64 = from;
100
24.5k
        return conv.dbl;
101
24.5k
    } else if constexpr (from_i64_to_db) {
  Branch (101:26): [Folded - Ignored]
  Branch (101:26): [Folded - Ignored]
  Branch (101:26): [Folded - Ignored]
  Branch (101:26): [Folded - Ignored]
  Branch (101:26): [Folded - Ignored]
  Branch (101:26): [Folded - Ignored]
  Branch (101:26): [Folded - Ignored]
  Branch (101:26): [Folded - Ignored]
  Branch (101:26): [Folded - Ignored]
  Branch (101:26): [Folded - Ignored]
102
24.5k
        TypeConverter conv;
103
24.5k
        conv.i64 = from;
104
24.5k
        return conv.dbl;
105
24.5k
    } else if constexpr (from_db_to_i64) {
  Branch (105:26): [Folded - Ignored]
  Branch (105:26): [Folded - Ignored]
  Branch (105:26): [Folded - Ignored]
  Branch (105:26): [Folded - Ignored]
  Branch (105:26): [Folded - Ignored]
  Branch (105:26): [Folded - Ignored]
  Branch (105:26): [Folded - Ignored]
  Branch (105:26): [Folded - Ignored]
  Branch (105:26): [Folded - Ignored]
106
24.5k
        TypeConverter conv;
107
24.5k
        conv.dbl = from;
108
24.5k
        return conv.i64;
109
24.5k
    } else if constexpr (from_db_to_u64) {
  Branch (109:26): [Folded - Ignored]
  Branch (109:26): [Folded - Ignored]
  Branch (109:26): [Folded - Ignored]
  Branch (109:26): [Folded - Ignored]
  Branch (109:26): [Folded - Ignored]
  Branch (109:26): [Folded - Ignored]
  Branch (109:26): [Folded - Ignored]
  Branch (109:26): [Folded - Ignored]
110
24.5k
        TypeConverter conv;
111
24.5k
        conv.dbl = from;
112
24.5k
        return conv.u64;
113
24.5k
    } else if constexpr (from_i64_to_vec_dt) {
  Branch (113:26): [Folded - Ignored]
  Branch (113:26): [Folded - Ignored]
  Branch (113:26): [Folded - Ignored]
  Branch (113:26): [Folded - Ignored]
  Branch (113:26): [Folded - Ignored]
  Branch (113:26): [Folded - Ignored]
  Branch (113:26): [Folded - Ignored]
  Branch (113:26): [Folded - Ignored]
114
23.7k
        VecDateTimeInt64Union conv = {.i64 = from};
115
23.7k
        return conv.dt;
116
23.7k
    } else if constexpr (from_ui32_to_date_v2) {
  Branch (116:26): [Folded - Ignored]
  Branch (116:26): [Folded - Ignored]
  Branch (116:26): [Folded - Ignored]
  Branch (116:26): [Folded - Ignored]
  Branch (116:26): [Folded - Ignored]
  Branch (116:26): [Folded - Ignored]
  Branch (116:26): [Folded - Ignored]
117
22.6k
        DateV2UInt32Union conv = {.ui32 = from};
118
22.6k
        return conv.dt;
119
22.6k
    } else if constexpr (from_date_v2_to_ui32) {
  Branch (119:26): [Folded - Ignored]
  Branch (119:26): [Folded - Ignored]
  Branch (119:26): [Folded - Ignored]
  Branch (119:26): [Folded - Ignored]
  Branch (119:26): [Folded - Ignored]
  Branch (119:26): [Folded - Ignored]
120
22.4k
        DateV2UInt32Union conv = {.dt = from};
121
22.4k
        return conv.ui32;
122
22.4k
    } else if constexpr (from_ui64_to_datetime_v2) {
  Branch (122:26): [Folded - Ignored]
  Branch (122:26): [Folded - Ignored]
  Branch (122:26): [Folded - Ignored]
  Branch (122:26): [Folded - Ignored]
  Branch (122:26): [Folded - Ignored]
123
20.8k
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
20.8k
        return conv.dt;
125
20.8k
    } else if constexpr (from_datetime_v2_to_ui64) {
  Branch (125:26): [Folded - Ignored]
  Branch (125:26): [Folded - Ignored]
  Branch (125:26): [Folded - Ignored]
  Branch (125:26): [Folded - Ignored]
126
20.1k
        DateTimeV2UInt64Union conv = {.dt = from};
127
20.1k
        return conv.ui64;
128
20.1k
    } else if constexpr (from_vec_dt_to_i64) {
  Branch (128:26): [Folded - Ignored]
  Branch (128:26): [Folded - Ignored]
  Branch (128:26): [Folded - Ignored]
129
48
        VecDateTimeInt64Union conv = {.dt = from};
130
48
        return conv.i64;
131
48
    } else if constexpr (from_i128_to_decv2) {
  Branch (131:26): [Folded - Ignored]
  Branch (131:26): [Folded - Ignored]
132
48
        DecimalInt128Union conv;
133
48
        conv.i128 = from;
134
48
        return conv.decimal;
135
48
    } else if constexpr (from_decv2_to_i128) {
  Branch (135:26): [Folded - Ignored]
136
48
        DecimalInt128Union conv;
137
48
        conv.decimal = from;
138
48
        return conv.i128;
139
48
    } else {
140
24.5k
        LOG(FATAL) << "__builtin_unreachable";
141
24.5k
        __builtin_unreachable();
142
24.5k
    }
143
24.5k
}
Unexecuted instantiation: _ZN5doris11binary_castIdlEET0_T_
Unexecuted instantiation: _ZN5doris11binary_castIldEET0_T_
Unexecuted instantiation: _ZN5doris11binary_castImdEET0_T_
_ZN5doris11binary_castIjNS_11DateV2ValueINS_15DateV2ValueTypeEEEEET0_T_
Line
Count
Source
71
1.05k
To binary_cast(From from) {
72
1.05k
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
1.05k
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
1.05k
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
1.05k
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
1.05k
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
1.05k
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
1.05k
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
1.05k
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
1.05k
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
1.05k
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
1.05k
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
1.05k
    constexpr bool from_ui64_to_datetime_v2 =
87
1.05k
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
1.05k
    constexpr bool from_datetime_v2_to_ui64 =
90
1.05k
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
1.05k
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
1.05k
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
1.05k
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
1.05k
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
1.05k
    if constexpr (from_u64_to_db) {
  Branch (97:19): [Folded - Ignored]
98
1.05k
        TypeConverter conv;
99
1.05k
        conv.u64 = from;
100
1.05k
        return conv.dbl;
101
1.05k
    } else if constexpr (from_i64_to_db) {
  Branch (101:26): [Folded - Ignored]
102
1.05k
        TypeConverter conv;
103
1.05k
        conv.i64 = from;
104
1.05k
        return conv.dbl;
105
1.05k
    } else if constexpr (from_db_to_i64) {
  Branch (105:26): [Folded - Ignored]
106
1.05k
        TypeConverter conv;
107
1.05k
        conv.dbl = from;
108
1.05k
        return conv.i64;
109
1.05k
    } else if constexpr (from_db_to_u64) {
  Branch (109:26): [Folded - Ignored]
110
1.05k
        TypeConverter conv;
111
1.05k
        conv.dbl = from;
112
1.05k
        return conv.u64;
113
1.05k
    } else if constexpr (from_i64_to_vec_dt) {
  Branch (113:26): [Folded - Ignored]
114
1.05k
        VecDateTimeInt64Union conv = {.i64 = from};
115
1.05k
        return conv.dt;
116
1.05k
    } else if constexpr (from_ui32_to_date_v2) {
  Branch (116:26): [Folded - Ignored]
117
1.05k
        DateV2UInt32Union conv = {.ui32 = from};
118
1.05k
        return conv.dt;
119
1.05k
    } else if constexpr (from_date_v2_to_ui32) {
120
1.05k
        DateV2UInt32Union conv = {.dt = from};
121
1.05k
        return conv.ui32;
122
1.05k
    } else if constexpr (from_ui64_to_datetime_v2) {
123
1.05k
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
1.05k
        return conv.dt;
125
1.05k
    } else if constexpr (from_datetime_v2_to_ui64) {
126
1.05k
        DateTimeV2UInt64Union conv = {.dt = from};
127
1.05k
        return conv.ui64;
128
1.05k
    } else if constexpr (from_vec_dt_to_i64) {
129
1.05k
        VecDateTimeInt64Union conv = {.dt = from};
130
1.05k
        return conv.i64;
131
1.05k
    } else if constexpr (from_i128_to_decv2) {
132
1.05k
        DecimalInt128Union conv;
133
1.05k
        conv.i128 = from;
134
1.05k
        return conv.decimal;
135
1.05k
    } else if constexpr (from_decv2_to_i128) {
136
1.05k
        DecimalInt128Union conv;
137
1.05k
        conv.decimal = from;
138
1.05k
        return conv.i128;
139
1.05k
    } else {
140
1.05k
        LOG(FATAL) << "__builtin_unreachable";
141
1.05k
        __builtin_unreachable();
142
1.05k
    }
143
1.05k
}
_ZN5doris11binary_castImNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEEEET0_T_
Line
Count
Source
71
1.53k
To binary_cast(From from) {
72
1.53k
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
1.53k
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
1.53k
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
1.53k
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
1.53k
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
1.53k
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
1.53k
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
1.53k
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
1.53k
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
1.53k
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
1.53k
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
1.53k
    constexpr bool from_ui64_to_datetime_v2 =
87
1.53k
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
1.53k
    constexpr bool from_datetime_v2_to_ui64 =
90
1.53k
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
1.53k
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
1.53k
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
1.53k
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
1.53k
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
1.53k
    if constexpr (from_u64_to_db) {
  Branch (97:19): [Folded - Ignored]
98
1.53k
        TypeConverter conv;
99
1.53k
        conv.u64 = from;
100
1.53k
        return conv.dbl;
101
1.53k
    } else if constexpr (from_i64_to_db) {
  Branch (101:26): [Folded - Ignored]
102
1.53k
        TypeConverter conv;
103
1.53k
        conv.i64 = from;
104
1.53k
        return conv.dbl;
105
1.53k
    } else if constexpr (from_db_to_i64) {
  Branch (105:26): [Folded - Ignored]
106
1.53k
        TypeConverter conv;
107
1.53k
        conv.dbl = from;
108
1.53k
        return conv.i64;
109
1.53k
    } else if constexpr (from_db_to_u64) {
  Branch (109:26): [Folded - Ignored]
110
1.53k
        TypeConverter conv;
111
1.53k
        conv.dbl = from;
112
1.53k
        return conv.u64;
113
1.53k
    } else if constexpr (from_i64_to_vec_dt) {
  Branch (113:26): [Folded - Ignored]
114
1.53k
        VecDateTimeInt64Union conv = {.i64 = from};
115
1.53k
        return conv.dt;
116
1.53k
    } else if constexpr (from_ui32_to_date_v2) {
  Branch (116:26): [Folded - Ignored]
117
1.53k
        DateV2UInt32Union conv = {.ui32 = from};
118
1.53k
        return conv.dt;
119
1.53k
    } else if constexpr (from_date_v2_to_ui32) {
  Branch (119:26): [Folded - Ignored]
120
1.53k
        DateV2UInt32Union conv = {.dt = from};
121
1.53k
        return conv.ui32;
122
1.53k
    } else if constexpr (from_ui64_to_datetime_v2) {
  Branch (122:26): [Folded - Ignored]
123
1.53k
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
1.53k
        return conv.dt;
125
1.53k
    } else if constexpr (from_datetime_v2_to_ui64) {
126
1.53k
        DateTimeV2UInt64Union conv = {.dt = from};
127
1.53k
        return conv.ui64;
128
1.53k
    } else if constexpr (from_vec_dt_to_i64) {
129
1.53k
        VecDateTimeInt64Union conv = {.dt = from};
130
1.53k
        return conv.i64;
131
1.53k
    } else if constexpr (from_i128_to_decv2) {
132
1.53k
        DecimalInt128Union conv;
133
1.53k
        conv.i128 = from;
134
1.53k
        return conv.decimal;
135
1.53k
    } else if constexpr (from_decv2_to_i128) {
136
1.53k
        DecimalInt128Union conv;
137
1.53k
        conv.decimal = from;
138
1.53k
        return conv.i128;
139
1.53k
    } else {
140
1.53k
        LOG(FATAL) << "__builtin_unreachable";
141
1.53k
        __builtin_unreachable();
142
1.53k
    }
143
1.53k
}
_ZN5doris11binary_castIlNS_16VecDateTimeValueEEET0_T_
Line
Count
Source
71
754
To binary_cast(From from) {
72
754
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
754
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
754
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
754
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
754
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
754
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
754
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
754
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
754
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
754
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
754
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
754
    constexpr bool from_ui64_to_datetime_v2 =
87
754
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
754
    constexpr bool from_datetime_v2_to_ui64 =
90
754
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
754
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
754
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
754
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
754
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
754
    if constexpr (from_u64_to_db) {
  Branch (97:19): [Folded - Ignored]
98
754
        TypeConverter conv;
99
754
        conv.u64 = from;
100
754
        return conv.dbl;
101
754
    } else if constexpr (from_i64_to_db) {
  Branch (101:26): [Folded - Ignored]
102
754
        TypeConverter conv;
103
754
        conv.i64 = from;
104
754
        return conv.dbl;
105
754
    } else if constexpr (from_db_to_i64) {
  Branch (105:26): [Folded - Ignored]
106
754
        TypeConverter conv;
107
754
        conv.dbl = from;
108
754
        return conv.i64;
109
754
    } else if constexpr (from_db_to_u64) {
  Branch (109:26): [Folded - Ignored]
110
754
        TypeConverter conv;
111
754
        conv.dbl = from;
112
754
        return conv.u64;
113
754
    } else if constexpr (from_i64_to_vec_dt) {
  Branch (113:26): [Folded - Ignored]
114
754
        VecDateTimeInt64Union conv = {.i64 = from};
115
754
        return conv.dt;
116
754
    } else if constexpr (from_ui32_to_date_v2) {
117
754
        DateV2UInt32Union conv = {.ui32 = from};
118
754
        return conv.dt;
119
754
    } else if constexpr (from_date_v2_to_ui32) {
120
754
        DateV2UInt32Union conv = {.dt = from};
121
754
        return conv.ui32;
122
754
    } else if constexpr (from_ui64_to_datetime_v2) {
123
754
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
754
        return conv.dt;
125
754
    } else if constexpr (from_datetime_v2_to_ui64) {
126
754
        DateTimeV2UInt64Union conv = {.dt = from};
127
754
        return conv.ui64;
128
754
    } else if constexpr (from_vec_dt_to_i64) {
129
754
        VecDateTimeInt64Union conv = {.dt = from};
130
754
        return conv.i64;
131
754
    } else if constexpr (from_i128_to_decv2) {
132
754
        DecimalInt128Union conv;
133
754
        conv.i128 = from;
134
754
        return conv.decimal;
135
754
    } else if constexpr (from_decv2_to_i128) {
136
754
        DecimalInt128Union conv;
137
754
        conv.decimal = from;
138
754
        return conv.i128;
139
754
    } else {
140
754
        LOG(FATAL) << "__builtin_unreachable";
141
754
        __builtin_unreachable();
142
754
    }
143
754
}
Unexecuted instantiation: _ZN5doris11binary_castInNS_14DecimalV2ValueEEET0_T_
_ZN5doris11binary_castINS_14DecimalV2ValueEnEET0_T_
Line
Count
Source
71
48
To binary_cast(From from) {
72
48
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
48
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
48
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
48
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
48
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
48
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
48
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
48
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
48
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
48
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
48
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
48
    constexpr bool from_ui64_to_datetime_v2 =
87
48
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
48
    constexpr bool from_datetime_v2_to_ui64 =
90
48
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
48
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
48
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
48
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
48
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
48
    if constexpr (from_u64_to_db) {
  Branch (97:19): [Folded - Ignored]
98
48
        TypeConverter conv;
99
48
        conv.u64 = from;
100
48
        return conv.dbl;
101
48
    } else if constexpr (from_i64_to_db) {
  Branch (101:26): [Folded - Ignored]
102
48
        TypeConverter conv;
103
48
        conv.i64 = from;
104
48
        return conv.dbl;
105
48
    } else if constexpr (from_db_to_i64) {
  Branch (105:26): [Folded - Ignored]
106
48
        TypeConverter conv;
107
48
        conv.dbl = from;
108
48
        return conv.i64;
109
48
    } else if constexpr (from_db_to_u64) {
  Branch (109:26): [Folded - Ignored]
110
48
        TypeConverter conv;
111
48
        conv.dbl = from;
112
48
        return conv.u64;
113
48
    } else if constexpr (from_i64_to_vec_dt) {
  Branch (113:26): [Folded - Ignored]
114
48
        VecDateTimeInt64Union conv = {.i64 = from};
115
48
        return conv.dt;
116
48
    } else if constexpr (from_ui32_to_date_v2) {
  Branch (116:26): [Folded - Ignored]
117
48
        DateV2UInt32Union conv = {.ui32 = from};
118
48
        return conv.dt;
119
48
    } else if constexpr (from_date_v2_to_ui32) {
  Branch (119:26): [Folded - Ignored]
120
48
        DateV2UInt32Union conv = {.dt = from};
121
48
        return conv.ui32;
122
48
    } else if constexpr (from_ui64_to_datetime_v2) {
  Branch (122:26): [Folded - Ignored]
123
48
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
48
        return conv.dt;
125
48
    } else if constexpr (from_datetime_v2_to_ui64) {
  Branch (125:26): [Folded - Ignored]
126
48
        DateTimeV2UInt64Union conv = {.dt = from};
127
48
        return conv.ui64;
128
48
    } else if constexpr (from_vec_dt_to_i64) {
  Branch (128:26): [Folded - Ignored]
129
48
        VecDateTimeInt64Union conv = {.dt = from};
130
48
        return conv.i64;
131
48
    } else if constexpr (from_i128_to_decv2) {
  Branch (131:26): [Folded - Ignored]
132
48
        DecimalInt128Union conv;
133
48
        conv.i128 = from;
134
48
        return conv.decimal;
135
48
    } else if constexpr (from_decv2_to_i128) {
  Branch (135:26): [Folded - Ignored]
136
48
        DecimalInt128Union conv;
137
48
        conv.decimal = from;
138
48
        return conv.i128;
139
48
    } else {
140
48
        LOG(FATAL) << "__builtin_unreachable";
141
48
        __builtin_unreachable();
142
48
    }
143
48
}
_ZN5doris11binary_castINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEEmEET0_T_
Line
Count
Source
71
723
To binary_cast(From from) {
72
723
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
723
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
723
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
723
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
723
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
723
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
723
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
723
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
723
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
723
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
723
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
723
    constexpr bool from_ui64_to_datetime_v2 =
87
723
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
723
    constexpr bool from_datetime_v2_to_ui64 =
90
723
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
723
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
723
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
723
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
723
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
723
    if constexpr (from_u64_to_db) {
  Branch (97:19): [Folded - Ignored]
98
723
        TypeConverter conv;
99
723
        conv.u64 = from;
100
723
        return conv.dbl;
101
723
    } else if constexpr (from_i64_to_db) {
  Branch (101:26): [Folded - Ignored]
102
723
        TypeConverter conv;
103
723
        conv.i64 = from;
104
723
        return conv.dbl;
105
723
    } else if constexpr (from_db_to_i64) {
  Branch (105:26): [Folded - Ignored]
106
723
        TypeConverter conv;
107
723
        conv.dbl = from;
108
723
        return conv.i64;
109
723
    } else if constexpr (from_db_to_u64) {
  Branch (109:26): [Folded - Ignored]
110
723
        TypeConverter conv;
111
723
        conv.dbl = from;
112
723
        return conv.u64;
113
723
    } else if constexpr (from_i64_to_vec_dt) {
  Branch (113:26): [Folded - Ignored]
114
723
        VecDateTimeInt64Union conv = {.i64 = from};
115
723
        return conv.dt;
116
723
    } else if constexpr (from_ui32_to_date_v2) {
  Branch (116:26): [Folded - Ignored]
117
723
        DateV2UInt32Union conv = {.ui32 = from};
118
723
        return conv.dt;
119
723
    } else if constexpr (from_date_v2_to_ui32) {
  Branch (119:26): [Folded - Ignored]
120
723
        DateV2UInt32Union conv = {.dt = from};
121
723
        return conv.ui32;
122
723
    } else if constexpr (from_ui64_to_datetime_v2) {
  Branch (122:26): [Folded - Ignored]
123
723
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
723
        return conv.dt;
125
723
    } else if constexpr (from_datetime_v2_to_ui64) {
  Branch (125:26): [Folded - Ignored]
126
723
        DateTimeV2UInt64Union conv = {.dt = from};
127
723
        return conv.ui64;
128
723
    } else if constexpr (from_vec_dt_to_i64) {
129
723
        VecDateTimeInt64Union conv = {.dt = from};
130
723
        return conv.i64;
131
723
    } else if constexpr (from_i128_to_decv2) {
132
723
        DecimalInt128Union conv;
133
723
        conv.i128 = from;
134
723
        return conv.decimal;
135
723
    } else if constexpr (from_decv2_to_i128) {
136
723
        DecimalInt128Union conv;
137
723
        conv.decimal = from;
138
723
        return conv.i128;
139
723
    } else {
140
723
        LOG(FATAL) << "__builtin_unreachable";
141
723
        __builtin_unreachable();
142
723
    }
143
723
}
_ZN5doris11binary_castINS_16VecDateTimeValueElEET0_T_
Line
Count
Source
71
20.1k
To binary_cast(From from) {
72
20.1k
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
20.1k
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
20.1k
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
20.1k
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
20.1k
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
20.1k
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
20.1k
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
20.1k
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
20.1k
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
20.1k
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
20.1k
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
20.1k
    constexpr bool from_ui64_to_datetime_v2 =
87
20.1k
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
20.1k
    constexpr bool from_datetime_v2_to_ui64 =
90
20.1k
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
20.1k
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
20.1k
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
20.1k
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
20.1k
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
20.1k
    if constexpr (from_u64_to_db) {
  Branch (97:19): [Folded - Ignored]
98
20.1k
        TypeConverter conv;
99
20.1k
        conv.u64 = from;
100
20.1k
        return conv.dbl;
101
20.1k
    } else if constexpr (from_i64_to_db) {
  Branch (101:26): [Folded - Ignored]
102
20.1k
        TypeConverter conv;
103
20.1k
        conv.i64 = from;
104
20.1k
        return conv.dbl;
105
20.1k
    } else if constexpr (from_db_to_i64) {
  Branch (105:26): [Folded - Ignored]
106
20.1k
        TypeConverter conv;
107
20.1k
        conv.dbl = from;
108
20.1k
        return conv.i64;
109
20.1k
    } else if constexpr (from_db_to_u64) {
  Branch (109:26): [Folded - Ignored]
110
20.1k
        TypeConverter conv;
111
20.1k
        conv.dbl = from;
112
20.1k
        return conv.u64;
113
20.1k
    } else if constexpr (from_i64_to_vec_dt) {
  Branch (113:26): [Folded - Ignored]
114
20.1k
        VecDateTimeInt64Union conv = {.i64 = from};
115
20.1k
        return conv.dt;
116
20.1k
    } else if constexpr (from_ui32_to_date_v2) {
  Branch (116:26): [Folded - Ignored]
117
20.1k
        DateV2UInt32Union conv = {.ui32 = from};
118
20.1k
        return conv.dt;
119
20.1k
    } else if constexpr (from_date_v2_to_ui32) {
  Branch (119:26): [Folded - Ignored]
120
20.1k
        DateV2UInt32Union conv = {.dt = from};
121
20.1k
        return conv.ui32;
122
20.1k
    } else if constexpr (from_ui64_to_datetime_v2) {
  Branch (122:26): [Folded - Ignored]
123
20.1k
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
20.1k
        return conv.dt;
125
20.1k
    } else if constexpr (from_datetime_v2_to_ui64) {
  Branch (125:26): [Folded - Ignored]
126
20.1k
        DateTimeV2UInt64Union conv = {.dt = from};
127
20.1k
        return conv.ui64;
128
20.1k
    } else if constexpr (from_vec_dt_to_i64) {
  Branch (128:26): [Folded - Ignored]
129
20.1k
        VecDateTimeInt64Union conv = {.dt = from};
130
20.1k
        return conv.i64;
131
20.1k
    } else if constexpr (from_i128_to_decv2) {
132
20.1k
        DecimalInt128Union conv;
133
20.1k
        conv.i128 = from;
134
20.1k
        return conv.decimal;
135
20.1k
    } else if constexpr (from_decv2_to_i128) {
136
20.1k
        DecimalInt128Union conv;
137
20.1k
        conv.decimal = from;
138
20.1k
        return conv.i128;
139
20.1k
    } else {
140
20.1k
        LOG(FATAL) << "__builtin_unreachable";
141
20.1k
        __builtin_unreachable();
142
20.1k
    }
143
20.1k
}
_ZN5doris11binary_castINS_11DateV2ValueINS_15DateV2ValueTypeEEEjEET0_T_
Line
Count
Source
71
269
To binary_cast(From from) {
72
269
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
269
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
269
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
269
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
269
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
269
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
269
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
269
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
269
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
269
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
269
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
269
    constexpr bool from_ui64_to_datetime_v2 =
87
269
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
269
    constexpr bool from_datetime_v2_to_ui64 =
90
269
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
269
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
269
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
269
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
269
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
269
    if constexpr (from_u64_to_db) {
  Branch (97:19): [Folded - Ignored]
98
269
        TypeConverter conv;
99
269
        conv.u64 = from;
100
269
        return conv.dbl;
101
269
    } else if constexpr (from_i64_to_db) {
  Branch (101:26): [Folded - Ignored]
102
269
        TypeConverter conv;
103
269
        conv.i64 = from;
104
269
        return conv.dbl;
105
269
    } else if constexpr (from_db_to_i64) {
  Branch (105:26): [Folded - Ignored]
106
269
        TypeConverter conv;
107
269
        conv.dbl = from;
108
269
        return conv.i64;
109
269
    } else if constexpr (from_db_to_u64) {
  Branch (109:26): [Folded - Ignored]
110
269
        TypeConverter conv;
111
269
        conv.dbl = from;
112
269
        return conv.u64;
113
269
    } else if constexpr (from_i64_to_vec_dt) {
  Branch (113:26): [Folded - Ignored]
114
269
        VecDateTimeInt64Union conv = {.i64 = from};
115
269
        return conv.dt;
116
269
    } else if constexpr (from_ui32_to_date_v2) {
  Branch (116:26): [Folded - Ignored]
117
269
        DateV2UInt32Union conv = {.ui32 = from};
118
269
        return conv.dt;
119
269
    } else if constexpr (from_date_v2_to_ui32) {
  Branch (119:26): [Folded - Ignored]
120
269
        DateV2UInt32Union conv = {.dt = from};
121
269
        return conv.ui32;
122
269
    } else if constexpr (from_ui64_to_datetime_v2) {
123
269
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
269
        return conv.dt;
125
269
    } else if constexpr (from_datetime_v2_to_ui64) {
126
269
        DateTimeV2UInt64Union conv = {.dt = from};
127
269
        return conv.ui64;
128
269
    } else if constexpr (from_vec_dt_to_i64) {
129
269
        VecDateTimeInt64Union conv = {.dt = from};
130
269
        return conv.i64;
131
269
    } else if constexpr (from_i128_to_decv2) {
132
269
        DecimalInt128Union conv;
133
269
        conv.i128 = from;
134
269
        return conv.decimal;
135
269
    } else if constexpr (from_decv2_to_i128) {
136
269
        DecimalInt128Union conv;
137
269
        conv.decimal = from;
138
269
        return conv.i128;
139
269
    } else {
140
269
        LOG(FATAL) << "__builtin_unreachable";
141
269
        __builtin_unreachable();
142
269
    }
143
269
}
144
145
} // namespace doris