OmniSciDB  c1a53651b2
 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 707 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().

708  {
709  std::vector<double> bounds(4);
710  constexpr auto DOUBLE_MAX = std::numeric_limits<double>::max();
711  constexpr auto DOUBLE_MIN = std::numeric_limits<double>::lowest();
712  bounds[0] = DOUBLE_MAX;
713  bounds[1] = DOUBLE_MAX;
714  bounds[2] = DOUBLE_MIN;
715  bounds[3] = DOUBLE_MIN;
716  auto size_coords = coords->size();
717 
718  for (size_t i = 0; i < size_coords; i += 2) {
719  double x = (*coords)[i];
720  double y = (*coords)[i + 1];
721 
722  bounds[0] = std::min(bounds[0], x);
723  bounds[1] = std::min(bounds[1], y);
724  bounds[2] = std::max(bounds[2], x);
725  bounds[3] = std::max(bounds[3], y);
726  }
727  return bounds;
728 }
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 731 of file TargetValueConvertersImpl.h.

References checked_malloc().

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

731  {
732  ELEM_TYPE* array =
733  reinterpret_cast<ELEM_TYPE*>(checked_malloc(sizeof(ELEM_TYPE) * vector.size()));
734  memcpy(array, vector.data(), vector.size() * sizeof(ELEM_TYPE));
735 
736  return ArrayDatum(
737  (int)(vector.size() * sizeof(ELEM_TYPE)), reinterpret_cast<int8_t*>(array), false);
738 }
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:219
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 741 of file TargetValueConvertersImpl.h.

References to_array_datum().

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

+ Here is the call graph for this function: