OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TargetValueConvertersImpl.h File Reference
#include "Fragmenter/TargetValueConverters.h"
#include "Geospatial/Compression.h"
#include "Shared/checked_alloc.h"
#include "StringDictionary/StringDictionary.h"
#include <atomic>
#include <future>
#include <thread>
+ Include dependency graph for TargetValueConvertersImpl.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >
 
struct  DictionaryValueConverter< TARGET_TYPE >
 
struct  StringValueConverter
 
struct  ArrayValueConverter< ELEMENT_CONVERTER >
 
struct  GeoPointValueConverter
 
struct  GeoMultiPointValueConverter
 
struct  GeoLinestringValueConverter
 
struct  GeoMultiLinestringValueConverter
 
struct  GeoPolygonValueConverter
 
struct  GeoMultiPolygonValueConverter
 

Functions

template<typename T >
get_fixed_array_null_value ()
 
template<typename SOURCE_TYPE , typename RETURN_TYPE , typename CHECKED_CAST_TYPE >
RETURN_TYPE checked_cast (SOURCE_TYPE val, bool check_null, RETURN_TYPE null_value)
 
std::vector< double > compute_bounds_of_coords (const std::shared_ptr< std::vector< double >> &coords)
 
template<typename ELEM_TYPE >
ArrayDatum to_array_datum (const std::vector< ELEM_TYPE > &vector)
 
template<typename ELEM_TYPE >
ArrayDatum to_array_datum (const std::shared_ptr< std::vector< ELEM_TYPE >> &vector)
 

Function Documentation

template<typename SOURCE_TYPE , typename RETURN_TYPE , typename CHECKED_CAST_TYPE >
RETURN_TYPE checked_cast ( SOURCE_TYPE  val,
bool  check_null,
RETURN_TYPE  null_value 
)

Definition at line 39 of file TargetValueConvertersImpl.h.

Referenced by NumericConverterFactory< SOURCE_TYPE, TARGET_TYPE >::create().

39  {
40  if (!std::is_same<SOURCE_TYPE, CHECKED_CAST_TYPE>::value) {
41  // do an overflow check
42  try {
43  CHECKED_CAST_TYPE castedVal = boost::numeric_cast<CHECKED_CAST_TYPE>(val);
44  if (check_null && castedVal == null_value) {
45  throw std::runtime_error("Overflow or underflow");
46  }
47  } catch (...) {
48  throw std::runtime_error("Overflow or underflow");
49  }
50  }
51 
52  return static_cast<RETURN_TYPE>(val);
53 }

+ Here is the caller graph for this function:

std::vector<double> compute_bounds_of_coords ( const std::shared_ptr< std::vector< double >> &  coords)
inline

Definition at line 705 of file TargetValueConvertersImpl.h.

References anonymous_namespace{Types.cpp}::DOUBLE_MAX, and anonymous_namespace{Types.cpp}::DOUBLE_MIN.

Referenced by GeoMultiPointValueConverter::convertToColumnarFormat(), GeoLinestringValueConverter::convertToColumnarFormat(), GeoMultiLinestringValueConverter::convertToColumnarFormat(), GeoPolygonValueConverter::convertToColumnarFormat(), and GeoMultiPolygonValueConverter::convertToColumnarFormat().

706  {
707  std::vector<double> bounds(4);
708  constexpr auto DOUBLE_MAX = std::numeric_limits<double>::max();
709  constexpr auto DOUBLE_MIN = std::numeric_limits<double>::lowest();
710  bounds[0] = DOUBLE_MAX;
711  bounds[1] = DOUBLE_MAX;
712  bounds[2] = DOUBLE_MIN;
713  bounds[3] = DOUBLE_MIN;
714  auto size_coords = coords->size();
715 
716  for (size_t i = 0; i < size_coords; i += 2) {
717  double x = (*coords)[i];
718  double y = (*coords)[i + 1];
719 
720  bounds[0] = std::min(bounds[0], x);
721  bounds[1] = std::min(bounds[1], y);
722  bounds[2] = std::max(bounds[2], x);
723  bounds[3] = std::max(bounds[3], y);
724  }
725  return bounds;
726 }
constexpr auto DOUBLE_MAX
Definition: Types.cpp:41
constexpr auto DOUBLE_MIN
Definition: Types.cpp:42

+ Here is the caller graph for this function:

template<typename T >
T get_fixed_array_null_value ( )

Definition at line 30 of file TargetValueConvertersImpl.h.

References heavydb.dtypes::T.

30  {
31  if (std::is_floating_point<T>::value) {
32  return static_cast<T>(inline_fp_null_array_value<T>());
33  } else {
34  return static_cast<T>(inline_int_null_array_value<T>());
35  }
36 }
template<typename ELEM_TYPE >
ArrayDatum to_array_datum ( const std::vector< ELEM_TYPE > &  vector)
inline

Definition at line 729 of file TargetValueConvertersImpl.h.

References checked_malloc().

Referenced by GeoMultiPointValueConverter::convertToColumnarFormat(), GeoLinestringValueConverter::convertToColumnarFormat(), GeoMultiLinestringValueConverter::convertToColumnarFormat(), GeoPolygonValueConverter::convertToColumnarFormat(), GeoMultiPolygonValueConverter::convertToColumnarFormat(), and to_array_datum().

729  {
730  ELEM_TYPE* array =
731  reinterpret_cast<ELEM_TYPE*>(checked_malloc(sizeof(ELEM_TYPE) * vector.size()));
732  memcpy(array, vector.data(), vector.size() * sizeof(ELEM_TYPE));
733 
734  return ArrayDatum(
735  (int)(vector.size() * sizeof(ELEM_TYPE)), reinterpret_cast<int8_t*>(array), false);
736 }
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:229
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename ELEM_TYPE >
ArrayDatum to_array_datum ( const std::shared_ptr< std::vector< ELEM_TYPE >> &  vector)
inline

Definition at line 739 of file TargetValueConvertersImpl.h.

References to_array_datum().

739  {
740  return to_array_datum(*vector.get());
741 }
ArrayDatum to_array_datum(const std::vector< ELEM_TYPE > &vector)

+ Here is the call graph for this function: