OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_elem_type(), SQLTypeInfo::is_array(), SQLTypeInfo::is_date_in_days(), 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  }
bool is_date_in_days() const
Definition: sqltypes.h:1018
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:402
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:977
bool is_array() const
Definition: sqltypes.h:585

+ 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 >::encodeDataAndUpdateStats(), and ddl_utils::anonymous_namespace{DdlUtils.cpp}::validate_literal().

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 minimum 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: