Coverage Report

Created: 2025-04-11 20:35

/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
1.46M
    ~VecDateTimeInt64Union() {}
55
};
56
57
union DateV2UInt32Union {
58
    DateV2Value<DateV2ValueType> dt;
59
    uint32_t ui32;
60
1.16M
    ~DateV2UInt32Union() {}
61
};
62
63
union DateTimeV2UInt64Union {
64
    DateV2Value<DateTimeV2ValueType> dt;
65
    uint64_t ui64;
66
3.66M
    ~DateTimeV2UInt64Union() {}
67
};
68
69
// similar to reinterpret_cast but won't break strict-aliasing rules
70
template <typename From, typename To>
71
6.29M
To binary_cast(From from) {
72
6.29M
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
6.29M
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
6.29M
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
6.29M
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
6.29M
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
6.29M
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
6.29M
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
6.29M
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
6.29M
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
6.29M
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
6.29M
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
6.29M
    constexpr bool from_ui64_to_datetime_v2 =
87
6.29M
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
6.29M
    constexpr bool from_datetime_v2_to_ui64 =
90
6.29M
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
6.29M
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
6.29M
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
6.29M
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
6.29M
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
6.29M
    if constexpr (from_u64_to_db) {
98
6.29M
        TypeConverter conv;
99
6.29M
        conv.u64 = from;
100
6.29M
        return conv.dbl;
101
6.29M
    } else if constexpr (from_i64_to_db) {
102
6.29M
        TypeConverter conv;
103
6.29M
        conv.i64 = from;
104
6.29M
        return conv.dbl;
105
6.29M
    } else if constexpr (from_db_to_i64) {
106
6.29M
        TypeConverter conv;
107
6.29M
        conv.dbl = from;
108
6.29M
        return conv.i64;
109
6.29M
    } else if constexpr (from_db_to_u64) {
110
6.29M
        TypeConverter conv;
111
6.29M
        conv.dbl = from;
112
6.29M
        return conv.u64;
113
6.29M
    } else if constexpr (from_i64_to_vec_dt) {
114
4.91M
        VecDateTimeInt64Union conv = {.i64 = from};
115
4.91M
        return conv.dt;
116
4.91M
    } else if constexpr (from_ui32_to_date_v2) {
117
3.77M
        DateV2UInt32Union conv = {.ui32 = from};
118
3.77M
        return conv.dt;
119
3.77M
    } else if constexpr (from_date_v2_to_ui32) {
120
3.75M
        DateV2UInt32Union conv = {.dt = from};
121
3.75M
        return conv.ui32;
122
3.75M
    } else if constexpr (from_ui64_to_datetime_v2) {
123
235k
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
235k
        return conv.dt;
125
235k
    } else if constexpr (from_datetime_v2_to_ui64) {
126
87.9k
        DateTimeV2UInt64Union conv = {.dt = from};
127
87.9k
        return conv.ui64;
128
87.9k
    } else if constexpr (from_vec_dt_to_i64) {
129
48
        VecDateTimeInt64Union conv = {.dt = from};
130
48
        return conv.i64;
131
48
    } else if constexpr (from_i128_to_decv2) {
132
48
        DecimalInt128Union conv;
133
48
        conv.i128 = from;
134
48
        return conv.decimal;
135
48
    } else if constexpr (from_decv2_to_i128) {
136
48
        DecimalInt128Union conv;
137
48
        conv.decimal = from;
138
48
        return conv.i128;
139
48
    } else {
140
6.29M
        throw Exception(Status::FatalError("__builtin_unreachable"));
141
6.29M
    }
142
6.29M
}
Unexecuted instantiation: _ZN5doris11binary_castIdlEET0_T_
Unexecuted instantiation: _ZN5doris11binary_castIldEET0_T_
_ZN5doris11binary_castIjNS_11DateV2ValueINS_15DateV2ValueTypeEEEEET0_T_
Line
Count
Source
71
1.13M
To binary_cast(From from) {
72
1.13M
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
1.13M
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
1.13M
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
1.13M
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
1.13M
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
1.13M
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
1.13M
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
1.13M
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
1.13M
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
1.13M
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
1.13M
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
1.13M
    constexpr bool from_ui64_to_datetime_v2 =
87
1.13M
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
1.13M
    constexpr bool from_datetime_v2_to_ui64 =
90
1.13M
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
1.13M
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
1.13M
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
1.13M
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
1.13M
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
1.13M
    if constexpr (from_u64_to_db) {
98
1.13M
        TypeConverter conv;
99
1.13M
        conv.u64 = from;
100
1.13M
        return conv.dbl;
101
1.13M
    } else if constexpr (from_i64_to_db) {
102
1.13M
        TypeConverter conv;
103
1.13M
        conv.i64 = from;
104
1.13M
        return conv.dbl;
105
1.13M
    } else if constexpr (from_db_to_i64) {
106
1.13M
        TypeConverter conv;
107
1.13M
        conv.dbl = from;
108
1.13M
        return conv.i64;
109
1.13M
    } else if constexpr (from_db_to_u64) {
110
1.13M
        TypeConverter conv;
111
1.13M
        conv.dbl = from;
112
1.13M
        return conv.u64;
113
1.13M
    } else if constexpr (from_i64_to_vec_dt) {
114
1.13M
        VecDateTimeInt64Union conv = {.i64 = from};
115
1.13M
        return conv.dt;
116
1.13M
    } else if constexpr (from_ui32_to_date_v2) {
117
1.13M
        DateV2UInt32Union conv = {.ui32 = from};
118
1.13M
        return conv.dt;
119
1.13M
    } else if constexpr (from_date_v2_to_ui32) {
120
1.13M
        DateV2UInt32Union conv = {.dt = from};
121
1.13M
        return conv.ui32;
122
1.13M
    } else if constexpr (from_ui64_to_datetime_v2) {
123
1.13M
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
1.13M
        return conv.dt;
125
1.13M
    } else if constexpr (from_datetime_v2_to_ui64) {
126
1.13M
        DateTimeV2UInt64Union conv = {.dt = from};
127
1.13M
        return conv.ui64;
128
1.13M
    } else if constexpr (from_vec_dt_to_i64) {
129
1.13M
        VecDateTimeInt64Union conv = {.dt = from};
130
1.13M
        return conv.i64;
131
1.13M
    } else if constexpr (from_i128_to_decv2) {
132
1.13M
        DecimalInt128Union conv;
133
1.13M
        conv.i128 = from;
134
1.13M
        return conv.decimal;
135
1.13M
    } else if constexpr (from_decv2_to_i128) {
136
1.13M
        DecimalInt128Union conv;
137
1.13M
        conv.decimal = from;
138
1.13M
        return conv.i128;
139
1.13M
    } else {
140
1.13M
        throw Exception(Status::FatalError("__builtin_unreachable"));
141
1.13M
    }
142
1.13M
}
_ZN5doris11binary_castImNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEEEET0_T_
Line
Count
Source
71
3.51M
To binary_cast(From from) {
72
3.51M
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
3.51M
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
3.51M
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
3.51M
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
3.51M
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
3.51M
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
3.51M
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
3.51M
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
3.51M
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
3.51M
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
3.51M
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
3.51M
    constexpr bool from_ui64_to_datetime_v2 =
87
3.51M
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
3.51M
    constexpr bool from_datetime_v2_to_ui64 =
90
3.51M
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
3.51M
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
3.51M
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
3.51M
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
3.51M
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
3.51M
    if constexpr (from_u64_to_db) {
98
3.51M
        TypeConverter conv;
99
3.51M
        conv.u64 = from;
100
3.51M
        return conv.dbl;
101
3.51M
    } else if constexpr (from_i64_to_db) {
102
3.51M
        TypeConverter conv;
103
3.51M
        conv.i64 = from;
104
3.51M
        return conv.dbl;
105
3.51M
    } else if constexpr (from_db_to_i64) {
106
3.51M
        TypeConverter conv;
107
3.51M
        conv.dbl = from;
108
3.51M
        return conv.i64;
109
3.51M
    } else if constexpr (from_db_to_u64) {
110
3.51M
        TypeConverter conv;
111
3.51M
        conv.dbl = from;
112
3.51M
        return conv.u64;
113
3.51M
    } else if constexpr (from_i64_to_vec_dt) {
114
3.51M
        VecDateTimeInt64Union conv = {.i64 = from};
115
3.51M
        return conv.dt;
116
3.51M
    } else if constexpr (from_ui32_to_date_v2) {
117
3.51M
        DateV2UInt32Union conv = {.ui32 = from};
118
3.51M
        return conv.dt;
119
3.51M
    } else if constexpr (from_date_v2_to_ui32) {
120
3.51M
        DateV2UInt32Union conv = {.dt = from};
121
3.51M
        return conv.ui32;
122
3.51M
    } else if constexpr (from_ui64_to_datetime_v2) {
123
3.51M
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
3.51M
        return conv.dt;
125
3.51M
    } else if constexpr (from_datetime_v2_to_ui64) {
126
3.51M
        DateTimeV2UInt64Union conv = {.dt = from};
127
3.51M
        return conv.ui64;
128
3.51M
    } else if constexpr (from_vec_dt_to_i64) {
129
3.51M
        VecDateTimeInt64Union conv = {.dt = from};
130
3.51M
        return conv.i64;
131
3.51M
    } else if constexpr (from_i128_to_decv2) {
132
3.51M
        DecimalInt128Union conv;
133
3.51M
        conv.i128 = from;
134
3.51M
        return conv.decimal;
135
3.51M
    } else if constexpr (from_decv2_to_i128) {
136
3.51M
        DecimalInt128Union conv;
137
3.51M
        conv.decimal = from;
138
3.51M
        return conv.i128;
139
3.51M
    } else {
140
3.51M
        throw Exception(Status::FatalError("__builtin_unreachable"));
141
3.51M
    }
142
3.51M
}
_ZN5doris11binary_castIlNS_16VecDateTimeValueEEET0_T_
Line
Count
Source
71
1.37M
To binary_cast(From from) {
72
1.37M
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
1.37M
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
1.37M
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
1.37M
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
1.37M
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
1.37M
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
1.37M
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
1.37M
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
1.37M
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
1.37M
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
1.37M
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
1.37M
    constexpr bool from_ui64_to_datetime_v2 =
87
1.37M
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
1.37M
    constexpr bool from_datetime_v2_to_ui64 =
90
1.37M
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
1.37M
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
1.37M
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
1.37M
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
1.37M
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
1.37M
    if constexpr (from_u64_to_db) {
98
1.37M
        TypeConverter conv;
99
1.37M
        conv.u64 = from;
100
1.37M
        return conv.dbl;
101
1.37M
    } else if constexpr (from_i64_to_db) {
102
1.37M
        TypeConverter conv;
103
1.37M
        conv.i64 = from;
104
1.37M
        return conv.dbl;
105
1.37M
    } else if constexpr (from_db_to_i64) {
106
1.37M
        TypeConverter conv;
107
1.37M
        conv.dbl = from;
108
1.37M
        return conv.i64;
109
1.37M
    } else if constexpr (from_db_to_u64) {
110
1.37M
        TypeConverter conv;
111
1.37M
        conv.dbl = from;
112
1.37M
        return conv.u64;
113
1.37M
    } else if constexpr (from_i64_to_vec_dt) {
114
1.37M
        VecDateTimeInt64Union conv = {.i64 = from};
115
1.37M
        return conv.dt;
116
1.37M
    } else if constexpr (from_ui32_to_date_v2) {
117
1.37M
        DateV2UInt32Union conv = {.ui32 = from};
118
1.37M
        return conv.dt;
119
1.37M
    } else if constexpr (from_date_v2_to_ui32) {
120
1.37M
        DateV2UInt32Union conv = {.dt = from};
121
1.37M
        return conv.ui32;
122
1.37M
    } else if constexpr (from_ui64_to_datetime_v2) {
123
1.37M
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
1.37M
        return conv.dt;
125
1.37M
    } else if constexpr (from_datetime_v2_to_ui64) {
126
1.37M
        DateTimeV2UInt64Union conv = {.dt = from};
127
1.37M
        return conv.ui64;
128
1.37M
    } else if constexpr (from_vec_dt_to_i64) {
129
1.37M
        VecDateTimeInt64Union conv = {.dt = from};
130
1.37M
        return conv.i64;
131
1.37M
    } else if constexpr (from_i128_to_decv2) {
132
1.37M
        DecimalInt128Union conv;
133
1.37M
        conv.i128 = from;
134
1.37M
        return conv.decimal;
135
1.37M
    } else if constexpr (from_decv2_to_i128) {
136
1.37M
        DecimalInt128Union conv;
137
1.37M
        conv.decimal = from;
138
1.37M
        return conv.i128;
139
1.37M
    } else {
140
1.37M
        throw Exception(Status::FatalError("__builtin_unreachable"));
141
1.37M
    }
142
1.37M
}
_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) {
98
48
        TypeConverter conv;
99
48
        conv.u64 = from;
100
48
        return conv.dbl;
101
48
    } else if constexpr (from_i64_to_db) {
102
48
        TypeConverter conv;
103
48
        conv.i64 = from;
104
48
        return conv.dbl;
105
48
    } else if constexpr (from_db_to_i64) {
106
48
        TypeConverter conv;
107
48
        conv.dbl = from;
108
48
        return conv.i64;
109
48
    } else if constexpr (from_db_to_u64) {
110
48
        TypeConverter conv;
111
48
        conv.dbl = from;
112
48
        return conv.u64;
113
48
    } else if constexpr (from_i64_to_vec_dt) {
114
48
        VecDateTimeInt64Union conv = {.i64 = from};
115
48
        return conv.dt;
116
48
    } else if constexpr (from_ui32_to_date_v2) {
117
48
        DateV2UInt32Union conv = {.ui32 = from};
118
48
        return conv.dt;
119
48
    } else if constexpr (from_date_v2_to_ui32) {
120
48
        DateV2UInt32Union conv = {.dt = from};
121
48
        return conv.ui32;
122
48
    } else if constexpr (from_ui64_to_datetime_v2) {
123
48
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
48
        return conv.dt;
125
48
    } else if constexpr (from_datetime_v2_to_ui64) {
126
48
        DateTimeV2UInt64Union conv = {.dt = from};
127
48
        return conv.ui64;
128
48
    } else if constexpr (from_vec_dt_to_i64) {
129
48
        VecDateTimeInt64Union conv = {.dt = from};
130
48
        return conv.i64;
131
48
    } else if constexpr (from_i128_to_decv2) {
132
48
        DecimalInt128Union conv;
133
48
        conv.i128 = from;
134
48
        return conv.decimal;
135
48
    } else if constexpr (from_decv2_to_i128) {
136
48
        DecimalInt128Union conv;
137
48
        conv.decimal = from;
138
48
        return conv.i128;
139
48
    } else {
140
48
        throw Exception(Status::FatalError("__builtin_unreachable"));
141
48
    }
142
48
}
Unexecuted instantiation: _ZN5doris11binary_castInNS_14DecimalV2ValueEEET0_T_
_ZN5doris11binary_castINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEEmEET0_T_
Line
Count
Source
71
147k
To binary_cast(From from) {
72
147k
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
147k
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
147k
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
147k
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
147k
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
147k
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
147k
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
147k
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
147k
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
147k
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
147k
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
147k
    constexpr bool from_ui64_to_datetime_v2 =
87
147k
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
147k
    constexpr bool from_datetime_v2_to_ui64 =
90
147k
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
147k
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
147k
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
147k
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
147k
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
147k
    if constexpr (from_u64_to_db) {
98
147k
        TypeConverter conv;
99
147k
        conv.u64 = from;
100
147k
        return conv.dbl;
101
147k
    } else if constexpr (from_i64_to_db) {
102
147k
        TypeConverter conv;
103
147k
        conv.i64 = from;
104
147k
        return conv.dbl;
105
147k
    } else if constexpr (from_db_to_i64) {
106
147k
        TypeConverter conv;
107
147k
        conv.dbl = from;
108
147k
        return conv.i64;
109
147k
    } else if constexpr (from_db_to_u64) {
110
147k
        TypeConverter conv;
111
147k
        conv.dbl = from;
112
147k
        return conv.u64;
113
147k
    } else if constexpr (from_i64_to_vec_dt) {
114
147k
        VecDateTimeInt64Union conv = {.i64 = from};
115
147k
        return conv.dt;
116
147k
    } else if constexpr (from_ui32_to_date_v2) {
117
147k
        DateV2UInt32Union conv = {.ui32 = from};
118
147k
        return conv.dt;
119
147k
    } else if constexpr (from_date_v2_to_ui32) {
120
147k
        DateV2UInt32Union conv = {.dt = from};
121
147k
        return conv.ui32;
122
147k
    } else if constexpr (from_ui64_to_datetime_v2) {
123
147k
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
147k
        return conv.dt;
125
147k
    } else if constexpr (from_datetime_v2_to_ui64) {
126
147k
        DateTimeV2UInt64Union conv = {.dt = from};
127
147k
        return conv.ui64;
128
147k
    } else if constexpr (from_vec_dt_to_i64) {
129
147k
        VecDateTimeInt64Union conv = {.dt = from};
130
147k
        return conv.i64;
131
147k
    } else if constexpr (from_i128_to_decv2) {
132
147k
        DecimalInt128Union conv;
133
147k
        conv.i128 = from;
134
147k
        return conv.decimal;
135
147k
    } else if constexpr (from_decv2_to_i128) {
136
147k
        DecimalInt128Union conv;
137
147k
        conv.decimal = from;
138
147k
        return conv.i128;
139
147k
    } else {
140
147k
        throw Exception(Status::FatalError("__builtin_unreachable"));
141
147k
    }
142
147k
}
_ZN5doris11binary_castINS_16VecDateTimeValueElEET0_T_
Line
Count
Source
71
87.9k
To binary_cast(From from) {
72
87.9k
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
87.9k
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
87.9k
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
87.9k
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
87.9k
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
87.9k
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
87.9k
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
87.9k
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
87.9k
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
87.9k
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
87.9k
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
87.9k
    constexpr bool from_ui64_to_datetime_v2 =
87
87.9k
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
87.9k
    constexpr bool from_datetime_v2_to_ui64 =
90
87.9k
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
87.9k
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
87.9k
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
87.9k
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
87.9k
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
87.9k
    if constexpr (from_u64_to_db) {
98
87.9k
        TypeConverter conv;
99
87.9k
        conv.u64 = from;
100
87.9k
        return conv.dbl;
101
87.9k
    } else if constexpr (from_i64_to_db) {
102
87.9k
        TypeConverter conv;
103
87.9k
        conv.i64 = from;
104
87.9k
        return conv.dbl;
105
87.9k
    } else if constexpr (from_db_to_i64) {
106
87.9k
        TypeConverter conv;
107
87.9k
        conv.dbl = from;
108
87.9k
        return conv.i64;
109
87.9k
    } else if constexpr (from_db_to_u64) {
110
87.9k
        TypeConverter conv;
111
87.9k
        conv.dbl = from;
112
87.9k
        return conv.u64;
113
87.9k
    } else if constexpr (from_i64_to_vec_dt) {
114
87.9k
        VecDateTimeInt64Union conv = {.i64 = from};
115
87.9k
        return conv.dt;
116
87.9k
    } else if constexpr (from_ui32_to_date_v2) {
117
87.9k
        DateV2UInt32Union conv = {.ui32 = from};
118
87.9k
        return conv.dt;
119
87.9k
    } else if constexpr (from_date_v2_to_ui32) {
120
87.9k
        DateV2UInt32Union conv = {.dt = from};
121
87.9k
        return conv.ui32;
122
87.9k
    } else if constexpr (from_ui64_to_datetime_v2) {
123
87.9k
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
87.9k
        return conv.dt;
125
87.9k
    } else if constexpr (from_datetime_v2_to_ui64) {
126
87.9k
        DateTimeV2UInt64Union conv = {.dt = from};
127
87.9k
        return conv.ui64;
128
87.9k
    } else if constexpr (from_vec_dt_to_i64) {
129
87.9k
        VecDateTimeInt64Union conv = {.dt = from};
130
87.9k
        return conv.i64;
131
87.9k
    } else if constexpr (from_i128_to_decv2) {
132
87.9k
        DecimalInt128Union conv;
133
87.9k
        conv.i128 = from;
134
87.9k
        return conv.decimal;
135
87.9k
    } else if constexpr (from_decv2_to_i128) {
136
87.9k
        DecimalInt128Union conv;
137
87.9k
        conv.decimal = from;
138
87.9k
        return conv.i128;
139
87.9k
    } else {
140
87.9k
        throw Exception(Status::FatalError("__builtin_unreachable"));
141
87.9k
    }
142
87.9k
}
_ZN5doris11binary_castINS_11DateV2ValueINS_15DateV2ValueTypeEEEjEET0_T_
Line
Count
Source
71
27.1k
To binary_cast(From from) {
72
27.1k
    constexpr bool from_u64_to_db = match_v<From, uint64_t, To, double>;
73
27.1k
    constexpr bool from_i64_to_db = match_v<From, int64_t, To, double>;
74
27.1k
    constexpr bool from_db_to_i64 = match_v<From, double, To, int64_t>;
75
27.1k
    constexpr bool from_db_to_u64 = match_v<From, double, To, uint64_t>;
76
27.1k
    constexpr bool from_i64_to_vec_dt = match_v<From, __int64_t, To, doris::VecDateTimeValue>;
77
27.1k
    constexpr bool from_vec_dt_to_i64 = match_v<From, doris::VecDateTimeValue, To, __int64_t>;
78
27.1k
    constexpr bool from_i128_to_decv2 = match_v<From, __int128_t, To, DecimalV2Value>;
79
27.1k
    constexpr bool from_decv2_to_i128 = match_v<From, DecimalV2Value, To, __int128_t>;
80
27.1k
    constexpr bool from_decv2_to_i256 = match_v<From, DecimalV2Value, To, wide::Int256>;
81
82
27.1k
    constexpr bool from_ui32_to_date_v2 = match_v<From, uint32_t, To, DateV2Value<DateV2ValueType>>;
83
84
27.1k
    constexpr bool from_date_v2_to_ui32 = match_v<From, DateV2Value<DateV2ValueType>, To, uint32_t>;
85
86
27.1k
    constexpr bool from_ui64_to_datetime_v2 =
87
27.1k
            match_v<From, uint64_t, To, DateV2Value<DateTimeV2ValueType>>;
88
89
27.1k
    constexpr bool from_datetime_v2_to_ui64 =
90
27.1k
            match_v<From, DateV2Value<DateTimeV2ValueType>, To, uint64_t>;
91
92
27.1k
    static_assert(from_u64_to_db || from_i64_to_db || from_db_to_i64 || from_db_to_u64 ||
93
27.1k
                  from_i64_to_vec_dt || from_vec_dt_to_i64 || from_i128_to_decv2 ||
94
27.1k
                  from_decv2_to_i128 || from_decv2_to_i256 || from_ui32_to_date_v2 ||
95
27.1k
                  from_date_v2_to_ui32 || from_ui64_to_datetime_v2 || from_datetime_v2_to_ui64);
96
97
27.1k
    if constexpr (from_u64_to_db) {
98
27.1k
        TypeConverter conv;
99
27.1k
        conv.u64 = from;
100
27.1k
        return conv.dbl;
101
27.1k
    } else if constexpr (from_i64_to_db) {
102
27.1k
        TypeConverter conv;
103
27.1k
        conv.i64 = from;
104
27.1k
        return conv.dbl;
105
27.1k
    } else if constexpr (from_db_to_i64) {
106
27.1k
        TypeConverter conv;
107
27.1k
        conv.dbl = from;
108
27.1k
        return conv.i64;
109
27.1k
    } else if constexpr (from_db_to_u64) {
110
27.1k
        TypeConverter conv;
111
27.1k
        conv.dbl = from;
112
27.1k
        return conv.u64;
113
27.1k
    } else if constexpr (from_i64_to_vec_dt) {
114
27.1k
        VecDateTimeInt64Union conv = {.i64 = from};
115
27.1k
        return conv.dt;
116
27.1k
    } else if constexpr (from_ui32_to_date_v2) {
117
27.1k
        DateV2UInt32Union conv = {.ui32 = from};
118
27.1k
        return conv.dt;
119
27.1k
    } else if constexpr (from_date_v2_to_ui32) {
120
27.1k
        DateV2UInt32Union conv = {.dt = from};
121
27.1k
        return conv.ui32;
122
27.1k
    } else if constexpr (from_ui64_to_datetime_v2) {
123
27.1k
        DateTimeV2UInt64Union conv = {.ui64 = from};
124
27.1k
        return conv.dt;
125
27.1k
    } else if constexpr (from_datetime_v2_to_ui64) {
126
27.1k
        DateTimeV2UInt64Union conv = {.dt = from};
127
27.1k
        return conv.ui64;
128
27.1k
    } else if constexpr (from_vec_dt_to_i64) {
129
27.1k
        VecDateTimeInt64Union conv = {.dt = from};
130
27.1k
        return conv.i64;
131
27.1k
    } else if constexpr (from_i128_to_decv2) {
132
27.1k
        DecimalInt128Union conv;
133
27.1k
        conv.i128 = from;
134
27.1k
        return conv.decimal;
135
27.1k
    } else if constexpr (from_decv2_to_i128) {
136
27.1k
        DecimalInt128Union conv;
137
27.1k
        conv.decimal = from;
138
27.1k
        return conv.i128;
139
27.1k
    } else {
140
27.1k
        throw Exception(Status::FatalError("__builtin_unreachable"));
141
27.1k
    }
142
27.1k
}
Unexecuted instantiation: _ZN5doris11binary_castImdEET0_T_
143
144
} // namespace doris