17 #ifndef H_TypedDataAccessors__
18 #define H_TypedDataAccessors__
29 template <
typename LHT,
typename RHT>
31 std::ostringstream os;
32 os <<
"Value " << rhs <<
" would be truncated to "
33 << (std::is_same<LHT, uint8_t>::value || std::is_same<LHT, int8_t>::value
36 throw std::runtime_error(os.str());
41 if (std::is_floating_point<T>::value) {
42 return v == inline_fp_null_value<T>();
46 return v == inline_int_null_value<int8_t>();
48 return v == inline_int_null_value<int16_t>();
50 return v == inline_int_null_value<int32_t>();
52 return v == inline_int_null_value<int64_t>();
58 template <
typename LHT,
typename RHT>
60 const int64_t r =
is_null(rhs, t) ? inline_int_null_value<LHT>() : rhs;
69 return sizeof(int32_t);
87 return sidx == inline_int_null_value<uint8_t>();
89 return sidx == inline_int_null_value<uint16_t>();
91 return sidx == inline_int_null_value<int32_t>();
100 return *(uint8_t*)ptr;
102 return *(uint16_t*)ptr;
104 return *(int32_t*)ptr;
126 template <
typename T>
133 if (std::is_floating_point<T>::value) {
170 *(
float*)ndptr = rval;
173 *(
double*)ndptr = rval;
186 return oval / pow(10, otype.
get_scale());
189 template <
typename T>
193 const std::string col_name,
204 const auto isnull =
is_null(oval, etype);
205 if (etype.get_notnull() && isnull) {
206 throw std::runtime_error(
"NULL value on NOT NULL column '" + col_name +
"'");
209 switch (etype.get_type()) {
212 if (otype && otype->is_decimal()) {
213 put_scalar<int64_t>(ndptr,
216 isnull ? inline_int_null_value<int64_t>()
222 isnull ? inline_int_null_value<int64_t>()
223 : oval * pow(10, etype.get_scale()));
233 if (etype.is_date_in_days()) {
237 isnull ? inline_int_null_value<int64_t>()
239 static_cast<int64_t>(oval)));
245 if (otype && otype->is_decimal()) {
256 throw std::runtime_error(
"NULL value on NOT NULL column '" + col_name +
"'");
275 *(int8_t*)ndptr = inline_int_null_value<int8_t>();
278 *(int16_t*)ndptr = inline_int_null_value<int16_t>();
281 *(int32_t*)ndptr = inline_int_null_value<int32_t>();
284 *(int64_t*)ndptr = inline_int_null_value<int64_t>();
305 const std::string col_name) {
307 throw std::runtime_error(
"NULL value on NOT NULL column '" + col_name +
"'");
326 *(int8_t*)ndptr = inline_int_null_array_value<int8_t>();
329 *(int16_t*)ndptr = inline_int_null_array_value<int16_t>();
332 *(int32_t*)ndptr = inline_int_null_array_value<int32_t>();
335 *(int64_t*)ndptr = inline_int_null_array_value<int64_t>();
354 template <
typename T>
371 return inline_int_null_value<int8_t>() == (v = *(int8_t*)ndptr);
373 return inline_int_null_value<int16_t>() == (v = *(int16_t*)ndptr);
375 return inline_int_null_value<int32_t>() == (v = *(int32_t*)ndptr);
377 return inline_int_null_value<int64_t>() == (v = *(int64_t*)ndptr);
397 template <
typename TYPE_INFO,
typename VAL>
399 using FloatOrIntSelector =
400 typename std::conditional<std::is_floating_point<std::decay_t<VAL> >::value,
403 return get_null_sentinel_for_type(ti, FloatOrIntSelector());
410 template <
typename TYPE_INFO>
415 template <
typename TYPE_INFO>
421 template <
typename T>
431 template <
typename T>
432 inline void set_minmax(
T& min,
T& max,
bool& null_flag,
T const val,
T null_sentinel) {
433 if (val == null_sentinel) {
HOST DEVICE SQLTypes get_subtype() const
HOST DEVICE int get_size() const
double decimal_to_double(const SQLTypeInfo &otype, int64_t oval)
bool is_null_string_index(const int size, const int32_t sidx)
HOST DEVICE int get_scale() const
DEVICE float inline_fp_null_array_value< float >()
void value_truncated(const LHT &lhs, const RHT &rhs)
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
size_t get_element_size(const Type element_type)
Constants for Builtin SQL Types supported by HEAVY.AI.
HOST DEVICE SQLTypes get_type() const
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
static void put_scalar(void *ndptr, const SQLTypeInfo &etype, const int esize, const T oval)
CONSTEXPR DEVICE bool is_null(const T &value)
bool get_scalar(void *ndptr, const SQLTypeInfo &ntype, T &v)
DEVICE double inline_fp_null_array_value< double >()
int get_logical_size() const
void put_null_array(void *ndptr, const SQLTypeInfo &ntype, const std::string col_name)
bool is_timeinterval() const
auto operator()(TYPE_INFO const &ti, VAL const &) const
double get_null_sentinel_for_type(TYPE_INFO const &ti, FPSelector const &) const
int64_t get_null_sentinel_for_type(TYPE_INFO const &ti, IntSelector const &) const
void put_null(void *ndptr, const SQLTypeInfo &ntype, const std::string col_name)
HOST DEVICE EncodingType get_compression() const
int64_t convert_decimal_value_to_scale(const int64_t decimal_value, const SQLTypeInfo &type_info, const SQLTypeInfo &new_type_info)
constexpr float inline_fp_null_value< float >()
HOST DEVICE int get_dimension() const
constexpr double inline_fp_null_value< double >()
HOST DEVICE int get_comp_param() const
bool set_string_index(void *ptr, const SQLTypeInfo &etype, int32_t sidx)
bool integer_setter(LHT &lhs, const RHT &rhs, const SQLTypeInfo &t)
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
int64_t get_epoch_days_from_seconds(const int64_t seconds)
HOST DEVICE bool get_notnull() const
void set_minmax(T &min, T &max, T const val)
int32_t get_string_index(void *ptr, const int size)
bool is_string_array() const