OmniSciDB  bf83d84833
 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 142 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 209 of file ParquetMetadataValidator.h.

209  {
210  return check_bounds<D>(value);
211  }
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 223 of file ParquetMetadataValidator.h.

223  {
224  auto [min_value, max_value] = get_min_max_bounds<D>();
225  auto signed_value = static_cast<D>(value);
226  return signed_value >= 0 && signed_value <= max_value;
227  }
template<typename T >
static std::pair<std::string, std::string> foreign_storage::IntegralFixedLengthBoundsValidator< T >::getMinMaxBoundsAsStrings ( const SQLTypeInfo column_type)
inlinestaticprivate

Definition at line 181 of file ParquetMetadataValidator.h.

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

182  {
183  CHECK(column_type.is_integer());
184  switch (column_type.get_size()) {
185  case 1:
186  return getMinMaxBoundsAsStrings<int8_t>();
187  case 2:
188  return getMinMaxBoundsAsStrings<int16_t>();
189  case 4:
190  return getMinMaxBoundsAsStrings<int32_t>();
191  case 8:
192  return getMinMaxBoundsAsStrings<int64_t>();
193  default:
194  UNREACHABLE();
195  }
196  return {};
197  }
HOST DEVICE int get_size() const
Definition: sqltypes.h:321
#define UNREACHABLE()
Definition: Logger.h:241
bool is_integer() const
Definition: sqltypes.h:480
#define CHECK(condition)
Definition: Logger.h:197

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

References to_string().

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

230  {
231  auto [min_value, max_value] = get_min_max_bounds<D>();
232  return {std::to_string(min_value), std::to_string(max_value)};
233  }
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 148 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().

148  {
149  if (!valueWithinBounds(data_value, column_type)) {
150  auto [min_allowed_value, max_allowed_value] = getMinMaxBoundsAsStrings(column_type);
151  if (std::is_signed<T>::value) {
153  min_allowed_value, max_allowed_value, std::to_string(data_value));
154  } else {
156  min_allowed_value,
157  max_allowed_value,
158  std::to_string(static_cast<T>(data_value)));
159  }
160  }
161  }
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 164 of file ParquetMetadataValidator.h.

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

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

164  {
165  CHECK(column_type.is_integer());
166  switch (column_type.get_size()) {
167  case 1:
168  return checkBounds<int8_t>(value);
169  case 2:
170  return checkBounds<int16_t>(value);
171  case 4:
172  return checkBounds<int32_t>(value);
173  case 8:
174  return checkBounds<int64_t>(value);
175  default:
176  UNREACHABLE();
177  }
178  return {};
179  }
HOST DEVICE int get_size() const
Definition: sqltypes.h:321
#define UNREACHABLE()
Definition: Logger.h:241
bool is_integer() const
Definition: sqltypes.h:480
#define CHECK(condition)
Definition: Logger.h:197

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