Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 318b74c

Browse files
committed
Remove Logger usages from InlineNullValues.h.
Signed-off-by: ienkovich <[email protected]>
1 parent 8be5f25 commit 318b74c

File tree

3 files changed

+46
-89
lines changed

3 files changed

+46
-89
lines changed

omniscidb/DataMgr/NoneEncoder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828

2929
template <typename T>
3030
T none_encoded_null_value() {
31-
return std::is_integral<T>::value ? inline_int_null_value<T>()
32-
: inline_fp_null_value<T>();
31+
return inline_null_value<T>();
3332
}
3433

3534
template <typename T>

omniscidb/Shared/InlineNullValues.h

Lines changed: 44 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#ifndef INLINENULLVALUES_H
1818
#define INLINENULLVALUES_H
1919

20-
#include "../Logger/Logger.h"
2120
#include "funcannotations.h"
2221

2322
#ifndef _MSC_VER
@@ -75,14 +74,7 @@ constexpr inline int64_t max_valid_int_value() {
7574
}
7675

7776
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;
8678

8779
template <>
8880
constexpr inline float inline_fp_null_value<float>() {
@@ -95,14 +87,7 @@ constexpr inline double inline_fp_null_value<double>() {
9587
}
9688

9789
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;
10691

10792
template <>
10893
DEVICE inline float inline_fp_null_array_value<float>() {
@@ -147,8 +132,8 @@ inline int64_t inline_int_null_value(const TYPE* type) {
147132

148133
template <typename TYPE>
149134
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());
152137

153138
if (type->isExtDictionary()) {
154139
switch (type->size()) {
@@ -159,12 +144,7 @@ inline int64_t inline_fixed_encoding_null_value(const TYPE* type) {
159144
case 4:
160145
return inline_int_null_value<int32_t>();
161146
default:
162-
#ifndef __CUDACC__
163-
CHECK(false) << "Unexpected type size: " << type->toString() << " "
164-
<< type->size();
165-
#else
166-
CHECK(false);
167-
#endif
147+
abort();
168148
}
169149
}
170150

@@ -178,11 +158,7 @@ inline int64_t inline_fixed_encoding_null_value(const TYPE* type) {
178158
case 8:
179159
return inline_int_null_value<int64_t>();
180160
default:
181-
#ifndef __CUDACC__
182-
CHECK(false) << "Unexpected type size: " << type->toString() << " " << type->size();
183-
#else
184-
CHECK(false);
185-
#endif
161+
abort();
186162
}
187163
return 0;
188164
}
@@ -199,6 +175,40 @@ inline double inline_fp_null_value(const TYPE* type) {
199175

200176
#endif // NO_BOOST
201177

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+
202212
#include <type_traits>
203213

204214
namespace serialize_detail {
@@ -227,25 +237,11 @@ CONSTEXPR DEVICE inline typename serialize_detail::IntType<sizeof(T)>::type
227237
serialized_null_value() {
228238
using TT = typename serialize_detail::IntType<sizeof(T)>::type;
229239
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>();
242244
}
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
249245
return *(TT*)(&nv);
250246
}
251247

@@ -261,38 +257,4 @@ CONSTEXPR DEVICE inline void set_null(T& value) {
261257
*(TT*)(&value) = serialized_null_value<T, array>();
262258
}
263259

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-
298260
#endif

omniscidb/Tests/EncoderTest.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,7 @@ template <typename T>
235235
class NoneEncoderUpdateStatsTest : public EncoderUpdateStatsTest {
236236
protected:
237237
void runTest() {
238-
std::vector<T> data = {-1,
239-
2,
240-
3,
241-
(std::is_integral<T>::value ? inline_int_null_value<T>()
242-
: inline_fp_null_value<T>())};
238+
std::vector<T> data = {-1, 2, 3, inline_null_value<T>()};
243239
createEncoder(NoneEncoderTraits<T>::getSqlType());
244240
updateWithData(data);
245241
assertExpectedStats<T>(-1, 3, true);

0 commit comments

Comments
 (0)