OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::IntegralFixedLengthBoundsValidator< T > Class Template Reference

#include <ParquetMetadataValidator.h>

Static Public Member Functions

template<typename D >
static void validateValue (const D &data_value, const SQLTypeInfo &column_type)
 

Static Private Member Functions

static bool valueWithinBounds (const T &value, const SQLTypeInfo &column_type)
 
static std::pair< std::string,
std::string > 
getMinMaxBoundsAsStrings (const SQLTypeInfo &column_type)
 
template<typename D , typename TT = T, std::enable_if_t< std::is_signed< TT >::value, int > = 0>
static bool checkBounds (const T &value)
 Check bounds for value in signed case. More...
 
template<typename D , typename TT = T, std::enable_if_t<!std::is_signed< TT >::value, int > = 0>
static bool checkBounds (const T &value)
 Check bounds for value in unsigned case. More...
 
template<typename D >
static std::pair< std::string,
std::string > 
getMinMaxBoundsAsStrings ()
 

Detailed Description

template<typename T>
class foreign_storage::IntegralFixedLengthBoundsValidator< T >

Definition at line 114 of file ParquetMetadataValidator.h.

Member Function Documentation

template<typename T >
template<typename D , typename TT = T, std::enable_if_t< std::is_signed< TT >::value, int > = 0>
static bool foreign_storage::IntegralFixedLengthBoundsValidator< T >::checkBounds ( const T &  value)
inlinestaticprivate

Check bounds for value in signed case.

Parameters
value- value to check
Returns
true if value within bounds

Definition at line 181 of file ParquetMetadataValidator.h.

181  {
182  return check_bounds<D>(value);
183  }
template<typename T >
template<typename D , typename TT = T, std::enable_if_t<!std::is_signed< TT >::value, int > = 0>
static bool foreign_storage::IntegralFixedLengthBoundsValidator< T >::checkBounds ( const T &  value)
inlinestaticprivate

Check bounds for value in unsigned case.

Parameters
value- value to check
Returns
true if value within bounds

Definition at line 195 of file ParquetMetadataValidator.h.

195  {
196  auto [min_value, max_value] = get_min_max_bounds<D>();
197  auto signed_value = static_cast<D>(value);
198  return signed_value >= 0 && signed_value <= max_value;
199  }
template<typename T >
static std::pair<std::string, std::string> foreign_storage::IntegralFixedLengthBoundsValidator< T >::getMinMaxBoundsAsStrings ( const SQLTypeInfo column_type)
inlinestaticprivate

Definition at line 153 of file ParquetMetadataValidator.h.

References CHECK, SQLTypeInfo::get_size(), SQLTypeInfo::is_integer(), and UNREACHABLE.

154  {
155  CHECK(column_type.is_integer());
156  switch (column_type.get_size()) {
157  case 1:
158  return getMinMaxBoundsAsStrings<int8_t>();
159  case 2:
160  return getMinMaxBoundsAsStrings<int16_t>();
161  case 4:
162  return getMinMaxBoundsAsStrings<int32_t>();
163  case 8:
164  return getMinMaxBoundsAsStrings<int64_t>();
165  default:
166  UNREACHABLE();
167  }
168  return {};
169  }
HOST DEVICE int get_size() const
Definition: sqltypes.h:403
#define UNREACHABLE()
Definition: Logger.h:338
bool is_integer() const
Definition: sqltypes.h:565
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

template<typename T >
template<typename D >
static std::pair<std::string, std::string> foreign_storage::IntegralFixedLengthBoundsValidator< T >::getMinMaxBoundsAsStrings ( )
inlinestaticprivate

Definition at line 202 of file ParquetMetadataValidator.h.

References to_string().

Referenced by foreign_storage::IntegralFixedLengthBoundsValidator< T >::validateValue().

202  {
203  auto [min_value, max_value] = get_min_max_bounds<D>();
204  return {std::to_string(min_value), std::to_string(max_value)};
205  }
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
template<typename D >
static void foreign_storage::IntegralFixedLengthBoundsValidator< T >::validateValue ( const D &  data_value,
const SQLTypeInfo column_type 
)
inlinestatic

Definition at line 120 of file ParquetMetadataValidator.h.

References foreign_storage::IntegralFixedLengthBoundsValidator< T >::getMinMaxBoundsAsStrings(), foreign_storage::throw_parquet_metadata_out_of_bounds_error(), to_string(), and foreign_storage::IntegralFixedLengthBoundsValidator< T >::valueWithinBounds().

Referenced by foreign_storage::ParquetUnsignedFixedLengthEncoder< V, T, U, NullType >::validate(), and foreign_storage::ParquetFixedLengthEncoder< V, T, NullType >::validateIntegralOrFloatingPointValue().

120  {
121  if (!valueWithinBounds(data_value, column_type)) {
122  auto [min_allowed_value, max_allowed_value] = getMinMaxBoundsAsStrings(column_type);
123  if (std::is_signed<T>::value) {
125  min_allowed_value, max_allowed_value, std::to_string(data_value));
126  } else {
128  min_allowed_value,
129  max_allowed_value,
130  std::to_string(static_cast<T>(data_value)));
131  }
132  }
133  }
void throw_parquet_metadata_out_of_bounds_error(const std::string &min_value, const std::string &max_value, const std::string &encountered_value)
std::string to_string(char const *&&v)
static std::pair< std::string, std::string > getMinMaxBoundsAsStrings()
static bool valueWithinBounds(const T &value, const SQLTypeInfo &column_type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
static bool foreign_storage::IntegralFixedLengthBoundsValidator< T >::valueWithinBounds ( const T &  value,
const SQLTypeInfo column_type 
)
inlinestaticprivate

Definition at line 136 of file ParquetMetadataValidator.h.

References CHECK, SQLTypeInfo::get_size(), SQLTypeInfo::is_integer(), and UNREACHABLE.

Referenced by foreign_storage::IntegralFixedLengthBoundsValidator< T >::validateValue().

136  {
137  CHECK(column_type.is_integer());
138  switch (column_type.get_size()) {
139  case 1:
140  return checkBounds<int8_t>(value);
141  case 2:
142  return checkBounds<int16_t>(value);
143  case 4:
144  return checkBounds<int32_t>(value);
145  case 8:
146  return checkBounds<int64_t>(value);
147  default:
148  UNREACHABLE();
149  }
150  return {};
151  }
HOST DEVICE int get_size() const
Definition: sqltypes.h:403
#define UNREACHABLE()
Definition: Logger.h:338
bool is_integer() const
Definition: sqltypes.h:565
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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