OmniSciDB  6686921089
 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 "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 40 of file TargetValueConvertersImpl.h.

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

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

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

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

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

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

References omnisci.dtypes::T.

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

Definition at line 728 of file TargetValueConvertersImpl.h.

References checked_malloc().

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

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

References to_array_datum().

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

+ Here is the call graph for this function: