OmniSciDB  ca0c39ec8f
 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 "ImportExport/RenderGroupAnalyzer.h"
#include "Shared/checked_alloc.h"
#include "Shared/enable_assign_render_groups.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  GeoPolygonRenderGroupManager
 
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 41 of file TargetValueConvertersImpl.h.

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

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

+ 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 699 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().

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

+ Here is the caller graph for this function:

template<typename T >
T get_fixed_array_null_value ( )

Definition at line 32 of file TargetValueConvertersImpl.h.

References heavydb.dtypes::T.

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

Definition at line 723 of file TargetValueConvertersImpl.h.

References checked_malloc().

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

723  {
724  ELEM_TYPE* array =
725  reinterpret_cast<ELEM_TYPE*>(checked_malloc(sizeof(ELEM_TYPE) * vector.size()));
726  memcpy(array, vector.data(), vector.size() * sizeof(ELEM_TYPE));
727 
728  return ArrayDatum(
729  (int)(vector.size() * sizeof(ELEM_TYPE)), reinterpret_cast<int8_t*>(array), false);
730 }
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:217
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 733 of file TargetValueConvertersImpl.h.

References to_array_datum().

733  {
734  return to_array_datum(*vector.get());
735 }
ArrayDatum to_array_datum(const std::vector< ELEM_TYPE > &vector)

+ Here is the call graph for this function: