17
17
#ifndef INLINENULLVALUES_H
18
18
#define INLINENULLVALUES_H
19
19
20
- #include " ../Logger/Logger.h"
21
20
#include " funcannotations.h"
22
21
23
22
#ifndef _MSC_VER
@@ -75,14 +74,7 @@ constexpr inline int64_t max_valid_int_value() {
75
74
}
76
75
77
76
template <typename T>
78
- constexpr inline T inline_fp_null_value () {
79
- #if !(defined(__CUDACC__) || defined(NO_BOOST))
80
- LOG (FATAL) << " Only float or double overloads should be called." ;
81
- #else
82
- LOG (FATAL);
83
- #endif
84
- return T{};
85
- }
77
+ constexpr inline T inline_fp_null_value () = delete;
86
78
87
79
template <>
88
80
constexpr inline float inline_fp_null_value<float >() {
@@ -95,14 +87,7 @@ constexpr inline double inline_fp_null_value<double>() {
95
87
}
96
88
97
89
template <typename T>
98
- DEVICE T inline_fp_null_array_value () {
99
- #if !(defined(__CUDACC__) || defined(NO_BOOST))
100
- LOG (FATAL) << " Only float or double overloads should be called." ;
101
- #else
102
- assert (false );
103
- #endif
104
- return T{};
105
- }
90
+ DEVICE T inline_fp_null_array_value () = delete;
106
91
107
92
template <>
108
93
DEVICE inline float inline_fp_null_array_value<float >() {
@@ -147,8 +132,8 @@ inline int64_t inline_int_null_value(const TYPE* type) {
147
132
148
133
template <typename TYPE>
149
134
inline int64_t inline_fixed_encoding_null_value (const TYPE* type) {
150
- CHECK (type->isBoolean () || type->isInteger () || type->isDecimal () ||
151
- type->isDateTime () || type->isExtDictionary ());
135
+ assert (type->isBoolean () || type->isInteger () || type->isDecimal () ||
136
+ type->isDateTime () || type->isExtDictionary ());
152
137
153
138
if (type->isExtDictionary ()) {
154
139
switch (type->size ()) {
@@ -159,12 +144,7 @@ inline int64_t inline_fixed_encoding_null_value(const TYPE* type) {
159
144
case 4 :
160
145
return inline_int_null_value<int32_t >();
161
146
default :
162
- #ifndef __CUDACC__
163
- CHECK (false ) << " Unexpected type size: " << type->toString () << " "
164
- << type->size ();
165
- #else
166
- CHECK (false );
167
- #endif
147
+ abort ();
168
148
}
169
149
}
170
150
@@ -178,11 +158,7 @@ inline int64_t inline_fixed_encoding_null_value(const TYPE* type) {
178
158
case 8 :
179
159
return inline_int_null_value<int64_t >();
180
160
default :
181
- #ifndef __CUDACC__
182
- CHECK (false ) << " Unexpected type size: " << type->toString () << " " << type->size ();
183
- #else
184
- CHECK (false );
185
- #endif
161
+ abort ();
186
162
}
187
163
return 0 ;
188
164
}
@@ -199,6 +175,40 @@ inline double inline_fp_null_value(const TYPE* type) {
199
175
200
176
#endif // NO_BOOST
201
177
178
+ template <typename V,
179
+ std::enable_if_t <!std::is_same<V, bool >::value && std::is_integral<V>::value,
180
+ int > = 0 >
181
+ CONSTEXPR DEVICE inline V inline_null_value () {
182
+ return inline_int_null_value<V>();
183
+ }
184
+
185
+ template <typename V, std::enable_if_t <std::is_same<V, bool >::value, int > = 0 >
186
+ CONSTEXPR DEVICE inline int8_t inline_null_value () {
187
+ return inline_int_null_value<int8_t >();
188
+ }
189
+
190
+ template <typename V, std::enable_if_t <std::is_floating_point<V>::value, int > = 0 >
191
+ CONSTEXPR DEVICE inline V inline_null_value () {
192
+ return inline_fp_null_value<V>();
193
+ }
194
+
195
+ template <typename V,
196
+ std::enable_if_t <!std::is_same<V, bool >::value && std::is_integral<V>::value,
197
+ int > = 0 >
198
+ CONSTEXPR DEVICE inline V inline_null_array_value () {
199
+ return inline_int_null_array_value<V>();
200
+ }
201
+
202
+ template <typename V, std::enable_if_t <std::is_same<V, bool >::value, int > = 0 >
203
+ CONSTEXPR DEVICE inline int8_t inline_null_array_value () {
204
+ return inline_int_null_array_value<int8_t >();
205
+ }
206
+
207
+ template <typename V, std::enable_if_t <std::is_floating_point<V>::value, int > = 0 >
208
+ CONSTEXPR DEVICE inline V inline_null_array_value () {
209
+ return inline_fp_null_array_value<V>();
210
+ }
211
+
202
212
#include < type_traits>
203
213
204
214
namespace serialize_detail {
@@ -227,25 +237,11 @@ CONSTEXPR DEVICE inline typename serialize_detail::IntType<sizeof(T)>::type
227
237
serialized_null_value () {
228
238
using TT = typename serialize_detail::IntType<sizeof (T)>::type;
229
239
T nv = 0 ;
230
- if CONSTEXPR (std::is_floating_point<T>::value) {
231
- if CONSTEXPR (array) {
232
- nv = inline_fp_null_array_value<T>();
233
- } else {
234
- nv = inline_fp_null_value<T>();
235
- }
236
- } else if CONSTEXPR (std::is_integral<T>::value) {
237
- if CONSTEXPR (array) {
238
- nv = inline_int_null_array_value<T>();
239
- } else {
240
- nv = inline_int_null_value<T>();
241
- }
240
+ if CONSTEXPR (array) {
241
+ nv = inline_null_array_value<T>();
242
+ } else {
243
+ nv = inline_null_value<T>();
242
244
}
243
- #if !(defined(__CUDACC__) || defined(NO_BOOST))
244
- else {
245
- CHECK (false ) << " Serializing null values of floating point or integral types only is "
246
- " supported." ;
247
- }
248
- #endif
249
245
return *(TT*)(&nv);
250
246
}
251
247
@@ -261,38 +257,4 @@ CONSTEXPR DEVICE inline void set_null(T& value) {
261
257
*(TT*)(&value) = serialized_null_value<T, array>();
262
258
}
263
259
264
- template <typename V,
265
- std::enable_if_t <!std::is_same<V, bool >::value && std::is_integral<V>::value,
266
- int > = 0 >
267
- CONSTEXPR DEVICE inline V inline_null_value () {
268
- return inline_int_null_value<V>();
269
- }
270
-
271
- template <typename V, std::enable_if_t <std::is_same<V, bool >::value, int > = 0 >
272
- CONSTEXPR DEVICE inline int8_t inline_null_value () {
273
- return inline_int_null_value<int8_t >();
274
- }
275
-
276
- template <typename V, std::enable_if_t <std::is_floating_point<V>::value, int > = 0 >
277
- CONSTEXPR DEVICE inline V inline_null_value () {
278
- return inline_fp_null_value<V>();
279
- }
280
-
281
- template <typename V,
282
- std::enable_if_t <!std::is_same<V, bool >::value && std::is_integral<V>::value,
283
- int > = 0 >
284
- CONSTEXPR DEVICE inline V inline_null_array_value () {
285
- return inline_int_null_array_value<V>();
286
- }
287
-
288
- template <typename V, std::enable_if_t <std::is_same<V, bool >::value, int > = 0 >
289
- CONSTEXPR DEVICE inline int8_t inline_null_array_value () {
290
- return inline_int_null_array_value<int8_t >();
291
- }
292
-
293
- template <typename V, std::enable_if_t <std::is_floating_point<V>::value, int > = 0 >
294
- CONSTEXPR DEVICE inline V inline_null_array_value () {
295
- return inline_fp_null_array_value<V>();
296
- }
297
-
298
260
#endif
0 commit comments