Coverage Report

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