OmniSciDB  8fa3bf436f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 135 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 202 of file ParquetMetadataValidator.h.

202  {
203  return check_bounds<D>(value);
204  }
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 216 of file ParquetMetadataValidator.h.

216  {
217  auto [min_value, max_value] = get_min_max_bounds<D>();
218  auto signed_value = static_cast<D>(value);
219  return signed_value >= 0 && signed_value <= max_value;
220  }
template<typename T >
static std::pair<std::string, std::string> foreign_storage::IntegralFixedLengthBoundsValidator< T >::getMinMaxBoundsAsStrings ( const SQLTypeInfo column_type)
inlinestaticprivate

Definition at line 174 of file ParquetMetadataValidator.h.

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

175  {
176  CHECK(column_type.is_integer());
177  switch (column_type.get_size()) {
178  case 1:
179  return getMinMaxBoundsAsStrings<int8_t>();
180  case 2:
181  return getMinMaxBoundsAsStrings<int16_t>();
182  case 4:
183  return getMinMaxBoundsAsStrings<int32_t>();
184  case 8:
185  return getMinMaxBoundsAsStrings<int64_t>();
186  default:
187  UNREACHABLE();
188  }
189  return {};
190  }
HOST DEVICE int get_size() const
Definition: sqltypes.h:324
#define UNREACHABLE()
Definition: Logger.h:247
bool is_integer() const
Definition: sqltypes.h:491
#define CHECK(condition)
Definition: Logger.h:203

+ 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 223 of file ParquetMetadataValidator.h.

References to_string().

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

223  {
224  auto [min_value, max_value] = get_min_max_bounds<D>();
225  return {std::to_string(min_value), std::to_string(max_value)};
226  }
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 141 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 >::validate(), and foreign_storage::ParquetFixedLengthEncoder< V, T >::validateIntegralOrFloatingPointValue().

141  {
142  if (!valueWithinBounds(data_value, column_type)) {
143  auto [min_allowed_value, max_allowed_value] = getMinMaxBoundsAsStrings(column_type);
144  if (std::is_signed<T>::value) {
146  min_allowed_value, max_allowed_value, std::to_string(data_value));
147  } else {
149  min_allowed_value,
150  max_allowed_value,
151  std::to_string(static_cast<T>(data_value)));
152  }
153  }
154  }
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 157 of file ParquetMetadataValidator.h.

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

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

157  {
158  CHECK(column_type.is_integer());
159  switch (column_type.get_size()) {
160  case 1:
161  return checkBounds<int8_t>(value);
162  case 2:
163  return checkBounds<int16_t>(value);
164  case 4:
165  return checkBounds<int32_t>(value);
166  case 8:
167  return checkBounds<int64_t>(value);
168  default:
169  UNREACHABLE();
170  }
171  return {};
172  }
HOST DEVICE int get_size() const
Definition: sqltypes.h:324
#define UNREACHABLE()
Definition: Logger.h:247
bool is_integer() const
Definition: sqltypes.h:491
#define CHECK(condition)
Definition: Logger.h:203

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