OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
< TargetValueConverter
operator() (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

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

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(), ConverterCreateParameter::num_rows, ConverterCreateParameter::source, ConverterCreateParameter::target, and ConverterCreateParameter::type.

Referenced by NumericConverterFactory< SOURCE_TYPE, TARGET_TYPE >::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()) {
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  }
HOST DEVICE int get_size() const
Definition: sqltypes.h:403
const SQLTypeInfo & get_physical_type_info() const
bool is_integer() const
Definition: sqltypes.h:567
RETURN_TYPE checked_cast(SOURCE_TYPE val, bool check_null, RETURN_TYPE null_value)
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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:

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:

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: