OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TargetValueConvertersImpl.h File Reference
#include "Fragmenter/TargetValueConverters.h"
#include "Geospatial/Compression.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  GeoLinestringValueConverter
 
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 38 of file TargetValueConvertersImpl.h.

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

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

+ 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 700 of file TargetValueConvertersImpl.h.

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

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

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

+ Here is the caller graph for this function:

template<typename T >
T get_fixed_array_null_value ( )

Definition at line 29 of file TargetValueConvertersImpl.h.

References omnisci.dtypes::T.

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

Definition at line 724 of file TargetValueConvertersImpl.h.

References checked_malloc().

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

724  {
725  ELEM_TYPE* array =
726  reinterpret_cast<ELEM_TYPE*>(checked_malloc(sizeof(ELEM_TYPE) * vector.size()));
727  memcpy(array, vector.data(), vector.size() * sizeof(ELEM_TYPE));
728 
729  return ArrayDatum(
730  (int)(vector.size() * sizeof(ELEM_TYPE)), reinterpret_cast<int8_t*>(array), false);
731 }
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:202
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:44

+ 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 734 of file TargetValueConvertersImpl.h.

References to_array_datum().

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

+ Here is the call graph for this function: