OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NumericValueConverter< SOURCE_TYPE, TARGET_TYPE > Struct Template Reference

#include <TargetValueConvertersImpl.h>

+ Inheritance diagram for NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >:
+ Collaboration diagram for NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >:

Public Types

using ColumnDataPtr = std::unique_ptr< TARGET_TYPE, CheckedMallocDeleter< TARGET_TYPE >>
 
using ElementsBufferColumnPtr = ColumnDataPtr
 
using CasterFunc = std::function< TARGET_TYPE(SOURCE_TYPE, bool, TARGET_TYPE)>
 

Public Member Functions

 NumericValueConverter (const ColumnDescriptor *cd, size_t num_rows, TARGET_TYPE nullValue, SOURCE_TYPE nullCheckValue, bool doNullCheck)
 
 ~NumericValueConverter () override
 
void setValueCaster (CasterFunc caster)
 
bool allowFixedNullArray ()
 
void populateFixedArrayNullSentinel (size_t num_rows)
 
void allocateColumnarData (size_t num_rows) override
 
ElementsBufferColumnPtr allocateColumnarBuffer (size_t num_rows)
 
void convertElementToColumnarFormat (size_t row, typename ElementsBufferColumnPtr::pointer columnData, const ScalarTargetValue *scalarValue)
 
void convertToColumnarFormat (size_t row, const ScalarTargetValue *scalarValue)
 
void convertToColumnarFormat (size_t row, const TargetValue *value) override
 
void processArrayBuffer (std::unique_ptr< std::vector< std::pair< size_t, ElementsBufferColumnPtr >>> &array_buffer, std::unique_ptr< std::vector< ArrayDatum >>::pointer arrayData)
 
void addDataBlocksToInsertData (Fragmenter_Namespace::InsertData &insertData) override
 
- Public Member Functions inherited from TargetValueConverter
 TargetValueConverter (const ColumnDescriptor *cd)
 
virtual ~TargetValueConverter ()
 
virtual void finalizeDataBlocksForInsertData ()
 

Public Attributes

ColumnDataPtr column_data_
 
TARGET_TYPE null_value_
 
SOURCE_TYPE null_check_value_
 
bool do_null_check_
 
TARGET_TYPE fixed_array_null_value_
 
CasterFunc checked_caster_ = nullptr
 
boost_variant_accessor
< SOURCE_TYPE > 
SOURCE_TYPE_ACCESSOR
 
- Public Attributes inherited from TargetValueConverter
const ColumnDescriptorcolumn_descriptor_
 
boost_variant_accessor
< ScalarTargetValue
SCALAR_TARGET_VALUE_ACCESSOR
 
boost_variant_accessor
< ArrayTargetValue
ARRAY_TARGET_VALUE_ACCESSOR
 
boost_variant_accessor
< GeoTargetValue
GEO_TARGET_VALUE_ACCESSOR
 
boost_variant_accessor
< NullableString
NULLABLE_STRING_ACCESSOR
 
boost_variant_accessor
< std::string > 
STRING_ACCESSOR
 

Detailed Description

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

Definition at line 55 of file TargetValueConvertersImpl.h.

Member Typedef Documentation

template<typename SOURCE_TYPE, typename TARGET_TYPE>
using NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::CasterFunc = std::function<TARGET_TYPE(SOURCE_TYPE, bool, TARGET_TYPE)>

Definition at line 58 of file TargetValueConvertersImpl.h.

template<typename SOURCE_TYPE, typename TARGET_TYPE>
using NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::ColumnDataPtr = std::unique_ptr<TARGET_TYPE, CheckedMallocDeleter<TARGET_TYPE>>

Definition at line 56 of file TargetValueConvertersImpl.h.

template<typename SOURCE_TYPE, typename TARGET_TYPE>
using NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::ElementsBufferColumnPtr = ColumnDataPtr

Definition at line 57 of file TargetValueConvertersImpl.h.

Constructor & Destructor Documentation

template<typename SOURCE_TYPE, typename TARGET_TYPE>
NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::NumericValueConverter ( const ColumnDescriptor cd,
size_t  num_rows,
TARGET_TYPE  nullValue,
SOURCE_TYPE  nullCheckValue,
bool  doNullCheck 
)
inline

Definition at line 69 of file TargetValueConvertersImpl.h.

75  , null_value_(nullValue)
76  , null_check_value_(nullCheckValue)
77  , do_null_check_(doNullCheck) {
78  fixed_array_null_value_ = get_fixed_array_null_value<TARGET_TYPE>();
79  if (num_rows) {
81  }
82  }
const int8_t const int64_t * num_rows
TargetValueConverter(const ColumnDescriptor *cd)
void allocateColumnarData(size_t num_rows) override
template<typename SOURCE_TYPE, typename TARGET_TYPE>
NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::~NumericValueConverter ( )
inlineoverride

Definition at line 84 of file TargetValueConvertersImpl.h.

84 {}

Member Function Documentation

template<typename SOURCE_TYPE, typename TARGET_TYPE>
void NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::addDataBlocksToInsertData ( Fragmenter_Namespace::InsertData insertData)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 152 of file TargetValueConvertersImpl.h.

152  {
153  DataBlockPtr dataBlock;
154  dataBlock.numbersPtr = reinterpret_cast<int8_t*>(column_data_.get());
155  insertData.data.push_back(dataBlock);
156  insertData.columnIds.push_back(column_descriptor_->columnId);
157  }
const ColumnDescriptor * column_descriptor_
std::vector< DataBlockPtr > data
the number of rows being inserted
Definition: Fragmenter.h:64
int8_t * numbersPtr
Definition: sqltypes.h:149
std::vector< int > columnIds
identifies the table into which the data is being inserted
Definition: Fragmenter.h:62
template<typename SOURCE_TYPE, typename TARGET_TYPE>
ElementsBufferColumnPtr NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::allocateColumnarBuffer ( size_t  num_rows)
inline

Definition at line 102 of file TargetValueConvertersImpl.h.

102  {
103  CHECK(num_rows > 0);
105  reinterpret_cast<TARGET_TYPE*>(checked_malloc(num_rows * sizeof(TARGET_TYPE))));
106  }
const int8_t const int64_t * num_rows
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:44
#define CHECK(condition)
Definition: Logger.h:197
template<typename SOURCE_TYPE, typename TARGET_TYPE>
void NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::allocateColumnarData ( size_t  num_rows)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 96 of file TargetValueConvertersImpl.h.

Referenced by NumericValueConverter< int64_t, TARGET_TYPE >::NumericValueConverter(), and NumericValueConverter< int64_t, TARGET_TYPE >::populateFixedArrayNullSentinel().

96  {
97  CHECK(num_rows > 0);
99  reinterpret_cast<TARGET_TYPE*>(checked_malloc(num_rows * sizeof(TARGET_TYPE))));
100  }
std::unique_ptr< TARGET_TYPE, CheckedMallocDeleter< TARGET_TYPE >> ColumnDataPtr
const int8_t const int64_t * num_rows
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:44
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the caller graph for this function:

template<typename SOURCE_TYPE, typename TARGET_TYPE>
bool NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::allowFixedNullArray ( )
inline

Definition at line 88 of file TargetValueConvertersImpl.h.

88 { return true; }
template<typename SOURCE_TYPE, typename TARGET_TYPE>
void NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::convertElementToColumnarFormat ( size_t  row,
typename ElementsBufferColumnPtr::pointer  columnData,
const ScalarTargetValue scalarValue 
)
inline

Definition at line 108 of file TargetValueConvertersImpl.h.

Referenced by NumericValueConverter< int64_t, TARGET_TYPE >::convertToColumnarFormat().

111  {
112  auto db_p = checked_get<SOURCE_TYPE>(row, scalarValue, SOURCE_TYPE_ACCESSOR);
113  auto val = *db_p;
114 
115  if (do_null_check_ && null_check_value_ == val) {
116  columnData[row] = null_value_;
117  } else {
118  if (checked_caster_) {
119  columnData[row] = checked_caster_(val, do_null_check_, null_value_);
120  } else {
121  columnData[row] = static_cast<TARGET_TYPE>(val);
122  }
123  }
124  }
boost_variant_accessor< SOURCE_TYPE > SOURCE_TYPE_ACCESSOR

+ Here is the caller graph for this function:

template<typename SOURCE_TYPE, typename TARGET_TYPE>
void NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::convertToColumnarFormat ( size_t  row,
const ScalarTargetValue scalarValue 
)
inline

Definition at line 126 of file TargetValueConvertersImpl.h.

Referenced by NumericValueConverter< int64_t, TARGET_TYPE >::convertToColumnarFormat().

126  {
127  convertElementToColumnarFormat(row, column_data_.get(), scalarValue);
128  }
void convertElementToColumnarFormat(size_t row, typename ElementsBufferColumnPtr::pointer columnData, const ScalarTargetValue *scalarValue)

+ Here is the caller graph for this function:

template<typename SOURCE_TYPE, typename TARGET_TYPE>
void NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::convertToColumnarFormat ( size_t  row,
const TargetValue value 
)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 130 of file TargetValueConvertersImpl.h.

130  {
131  auto scalarValue =
132  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
133  convertToColumnarFormat(row, scalarValue);
134  }
void convertToColumnarFormat(size_t row, const ScalarTargetValue *scalarValue)
boost_variant_accessor< ScalarTargetValue > SCALAR_TARGET_VALUE_ACCESSOR
template<typename SOURCE_TYPE, typename TARGET_TYPE>
void NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::populateFixedArrayNullSentinel ( size_t  num_rows)
inline

Definition at line 90 of file TargetValueConvertersImpl.h.

90  {
94  }
const int8_t const int64_t * num_rows
void allocateColumnarData(size_t num_rows) override
#define CHECK(condition)
Definition: Logger.h:197
template<typename SOURCE_TYPE, typename TARGET_TYPE>
void NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::processArrayBuffer ( std::unique_ptr< std::vector< std::pair< size_t, ElementsBufferColumnPtr >>> &  array_buffer,
std::unique_ptr< std::vector< ArrayDatum >>::pointer  arrayData 
)
inline

Definition at line 136 of file TargetValueConvertersImpl.h.

139  {
140  for (size_t row = 0; row < array_buffer->size(); row++) {
141  auto& element = (array_buffer->at(row));
142  bool is_null = false;
143  if (element.second) {
144  ColumnDataPtr& data = element.second;
145  int8_t* arrayDataPtr = reinterpret_cast<int8_t*>(data.release());
146  (*arrayData)[row] =
147  ArrayDatum(element.first * sizeof(TARGET_TYPE), arrayDataPtr, is_null);
148  }
149  }
150  }
std::unique_ptr< TARGET_TYPE, CheckedMallocDeleter< TARGET_TYPE >> ColumnDataPtr
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:131
bool is_null(const T &v, const SQLTypeInfo &t)
template<typename SOURCE_TYPE, typename TARGET_TYPE>
void NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::setValueCaster ( CasterFunc  caster)
inline

Definition at line 86 of file TargetValueConvertersImpl.h.

86 { checked_caster_ = caster; }

Member Data Documentation

template<typename SOURCE_TYPE, typename TARGET_TYPE>
CasterFunc NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::checked_caster_ = nullptr
template<typename SOURCE_TYPE, typename TARGET_TYPE>
bool NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::do_null_check_
template<typename SOURCE_TYPE, typename TARGET_TYPE>
TARGET_TYPE NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::fixed_array_null_value_
template<typename SOURCE_TYPE, typename TARGET_TYPE>
SOURCE_TYPE NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::null_check_value_
template<typename SOURCE_TYPE, typename TARGET_TYPE>
TARGET_TYPE NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::null_value_
template<typename SOURCE_TYPE, typename TARGET_TYPE>
boost_variant_accessor<SOURCE_TYPE> NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::SOURCE_TYPE_ACCESSOR

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