OmniSciDB  dfae7c3b14
NumericConverterFactory< SOURCE_TYPE, TARGET_TYPE > Struct Template Reference

Public Types

using ConverterType = NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >
 

Public Member Functions

std::unique_ptr< ConverterTypecreate (ConverterCreateParameter param)
 
std::unique_ptr< TargetValueConverteroperator() (ConverterCreateParameter param)
 
template<>
std::unique_ptr< NumericValueConverter< double, double > > create (ConverterCreateParameter param)
 
template<>
std::unique_ptr< NumericValueConverter< float, float > > create (ConverterCreateParameter param)
 

Detailed Description

template<typename SOURCE_TYPE, typename TARGET_TYPE>
struct NumericConverterFactory< SOURCE_TYPE, TARGET_TYPE >

Definition at line 21 of file TargetValueConvertersFactories.cpp.

Member Typedef Documentation

◆ ConverterType

template<typename SOURCE_TYPE , typename TARGET_TYPE >
using NumericConverterFactory< SOURCE_TYPE, TARGET_TYPE >::ConverterType = NumericValueConverter<SOURCE_TYPE, TARGET_TYPE>

Definition at line 22 of file TargetValueConvertersFactories.cpp.

Member Function Documentation

◆ create() [1/3]

template<typename SOURCE_TYPE , typename TARGET_TYPE >
std::unique_ptr<ConverterType> NumericConverterFactory< SOURCE_TYPE, TARGET_TYPE >::create ( ConverterCreateParameter  param)
inline

Definition at line 24 of file TargetValueConvertersFactories.cpp.

References ConverterCreateParameter::can_be_null, CHECK, checked_cast(), TargetMetaInfo::get_physical_type_info(), SQLTypeInfo::get_size(), SQLTypeInfo::is_integer(), SQLTypeInfo::is_time(), SQLTypeInfo::is_timestamp(), ConverterCreateParameter::num_rows, ConverterCreateParameter::source, ConverterCreateParameter::target, and ConverterCreateParameter::type.

Referenced by NumericConverterFactory< SOURCE_TYPE, TARGET_TYPE >::operator()(), DictionaryConverterFactory< TARGET_TYPE >::operator()(), and ArrayConverterFactory< ELEMENT_FACTORY >::operator()().

24  {
25  SOURCE_TYPE source_null_value =
26  static_cast<SOURCE_TYPE>(inline_int_null_value<SOURCE_TYPE>());
27 
28  using CasterFunc = std::function<TARGET_TYPE(SOURCE_TYPE, bool, TARGET_TYPE)>;
29 
30  CasterFunc caster = nullptr;
31 
32  switch (param.type.get_size()) {
33  case 8:
34  source_null_value = static_cast<SOURCE_TYPE>(inline_int_null_value<int64_t>());
35  caster = checked_cast<SOURCE_TYPE, TARGET_TYPE, int64_t>;
36  break;
37  case 4:
38  source_null_value = static_cast<SOURCE_TYPE>(inline_int_null_value<int32_t>());
39  if (param.source.get_physical_type_info().get_size() > 4) {
40  caster = checked_cast<SOURCE_TYPE, TARGET_TYPE, int32_t>;
41  }
42  break;
43  case 2:
44  source_null_value = static_cast<SOURCE_TYPE>(inline_int_null_value<int16_t>());
45  if (param.source.get_physical_type_info().get_size() > 2) {
46  caster = checked_cast<SOURCE_TYPE, TARGET_TYPE, int16_t>;
47  }
48  break;
49  case 1:
50  source_null_value = static_cast<SOURCE_TYPE>(inline_int_null_value<int8_t>());
51  if (param.source.get_physical_type_info().get_size() > 1) {
52  caster = checked_cast<SOURCE_TYPE, TARGET_TYPE, int8_t>;
53  }
54  break;
55  default:
56  CHECK(false);
57  }
58 
59  TARGET_TYPE target_null_value =
60  static_cast<TARGET_TYPE>(inline_int_null_value<TARGET_TYPE>());
61 
62  auto ret = std::make_unique<NumericValueConverter<SOURCE_TYPE, TARGET_TYPE>>(
63  param.target,
64  param.num_rows,
65  source_null_value,
66  target_null_value,
67  param.can_be_null);
68 
69  if (param.type.is_integer() || param.type.is_timestamp() || param.type.is_time()) {
70  // only apply overflow checks for
71  // the types using the fixed encoder
72  ret->setValueCaster(std::move(caster));
73  }
74 
75  return ret;
76  }
bool is_time() const
Definition: sqltypes.h:423
bool is_integer() const
Definition: sqltypes.h:419
HOST DEVICE int get_size() const
Definition: sqltypes.h:269
const SQLTypeInfo & get_physical_type_info() const
RETURN_TYPE checked_cast(SOURCE_TYPE val, bool check_null, RETURN_TYPE null_value)
#define CHECK(condition)
Definition: Logger.h:197
bool is_timestamp() const
Definition: sqltypes.h:654
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create() [2/3]

template<>
std::unique_ptr< NumericValueConverter< double, double > > NumericConverterFactory< double, double >::create ( ConverterCreateParameter  param)

Definition at line 85 of file TargetValueConvertersFactories.cpp.

References ConverterCreateParameter::can_be_null, inline_fp_null_value< double >(), ConverterCreateParameter::num_rows, and ConverterCreateParameter::target.

85  {
86  double null_value = inline_fp_null_value<double>();
87  return std::make_unique<NumericValueConverter<double, double>>(
88  param.target, param.num_rows, null_value, null_value, param.can_be_null);
89 }
constexpr double inline_fp_null_value< double >()
+ Here is the call graph for this function:

◆ create() [3/3]

template<>
std::unique_ptr< NumericValueConverter< float, float > > NumericConverterFactory< float, float >::create ( ConverterCreateParameter  param)

Definition at line 93 of file TargetValueConvertersFactories.cpp.

References ConverterCreateParameter::can_be_null, inline_fp_null_value< float >(), ConverterCreateParameter::num_rows, and ConverterCreateParameter::target.

93  {
94  float null_value = inline_fp_null_value<float>();
95  return std::make_unique<NumericValueConverter<float, float>>(
96  param.target, param.num_rows, null_value, null_value, param.can_be_null);
97 }
constexpr float inline_fp_null_value< float >()
+ Here is the call graph for this function:

◆ operator()()

template<typename SOURCE_TYPE , typename TARGET_TYPE >
std::unique_ptr<TargetValueConverter> NumericConverterFactory< SOURCE_TYPE, TARGET_TYPE >::operator() ( ConverterCreateParameter  param)
inline

Definition at line 78 of file TargetValueConvertersFactories.cpp.

References NumericConverterFactory< SOURCE_TYPE, TARGET_TYPE >::create().

78  {
79  return create(param);
80  }
std::unique_ptr< ConverterType > create(ConverterCreateParameter param)
+ Here is the call graph for this function:

The documentation for this struct was generated from the following file: