OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DateDaysOverflowValidator Class Reference

#include <Encoder.h>

Public Member Functions

 DateDaysOverflowValidator (SQLTypeInfo type)
 
template<typename T >
void validate (T value)
 

Private Attributes

bool is_date_in_days_
 
int64_t max_
 
int64_t min_
 

Detailed Description

Definition at line 109 of file Encoder.h.

Constructor & Destructor Documentation

DateDaysOverflowValidator::DateDaysOverflowValidator ( SQLTypeInfo  type)
inline

Definition at line 111 of file Encoder.h.

References SQLTypeInfoCore< TYPE_FACET_PACK >::get_comp_param(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_elem_type(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_array(), is_date_in_days_, max_, and min_.

111  {
113  type.is_array() ? type.get_elem_type().is_date_in_days() : type.is_date_in_days();
114  const bool is_date_16_ = is_date_in_days_ ? type.get_comp_param() == 16 : false;
115  max_ = is_date_16_ ? static_cast<int64_t>(std::numeric_limits<int16_t>::max())
116  : static_cast<int64_t>(std::numeric_limits<int32_t>::max());
117  min_ = is_date_16_ ? static_cast<int64_t>(std::numeric_limits<int16_t>::min())
118  : static_cast<int64_t>(std::numeric_limits<int32_t>::min());
119  }
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:335
bool is_array() const
Definition: sqltypes.h:485
SQLTypeInfoCore get_elem_type() const
Definition: sqltypes.h:659

+ Here is the call graph for this function:

Member Function Documentation

template<typename T >
void DateDaysOverflowValidator::validate ( value)
inline

Definition at line 122 of file Encoder.h.

References DateConverters::get_epoch_days_from_seconds(), is_date_in_days_, max_, min_, and to_string().

Referenced by DateDaysEncoder< T, V >::appendData().

122  {
123  if (!is_date_in_days_ || !std::is_integral<T>::value) {
124  return;
125  }
126  const int64_t days =
127  DateConverters::get_epoch_days_from_seconds(static_cast<int64_t>(value));
128  if (days > max_) {
129  throw std::runtime_error("Date encoding overflow: Epoch days " +
130  std::to_string(days) + " greater than maximum capacity " +
132  }
133  if (days < min_) {
134  throw std::runtime_error("Date encoding underflow: Epoch days " +
135  std::to_string(days) + " less than minumum capacity " +
137  }
138  }
std::string to_string(char const *&&v)
int64_t get_epoch_days_from_seconds(const int64_t seconds)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

bool DateDaysOverflowValidator::is_date_in_days_
private

Definition at line 141 of file Encoder.h.

Referenced by DateDaysOverflowValidator(), and validate().

int64_t DateDaysOverflowValidator::max_
private

Definition at line 142 of file Encoder.h.

Referenced by DateDaysOverflowValidator(), and validate().

int64_t DateDaysOverflowValidator::min_
private

Definition at line 143 of file Encoder.h.

Referenced by DateDaysOverflowValidator(), and validate().


The documentation for this class was generated from the following file: