OmniSciDB  04ee39c94c
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
 

Public Member Functions

 NumericValueConverter (const ColumnDescriptor *cd, size_t num_rows, TARGET_TYPE nullValue, SOURCE_TYPE nullCheckValue, bool doNullCheck)
 
 ~NumericValueConverter () override
 
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_
 
boost_variant_accessor< SOURCE_TYPE > SOURCE_TYPE_ACCESSOR
 
- Public Attributes inherited from TargetValueConverter
const ColumnDescriptorcolumn_descriptor_
 
boost_variant_accessor< ScalarTargetValueSCALAR_TARGET_VALUE_ACCESSOR
 
boost_variant_accessor< ArrayTargetValueARRAY_TARGET_VALUE_ACCESSOR
 
boost_variant_accessor< GeoTargetValueGEO_TARGET_VALUE_ACCESSOR
 
boost_variant_accessor< NullableStringNULLABLE_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 32 of file TargetValueConvertersImpl.h.

Member Typedef Documentation

◆ ColumnDataPtr

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

◆ ElementsBufferColumnPtr

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

Definition at line 34 of file TargetValueConvertersImpl.h.

Constructor & Destructor Documentation

◆ NumericValueConverter()

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

49  , null_value_(nullValue)
50  , null_check_value_(nullCheckValue)
51  , do_null_check_(doNullCheck) {
52  if (num_rows) {
54  }
55  }
const int8_t const int64_t * num_rows
TargetValueConverter(const ColumnDescriptor *cd)
void allocateColumnarData(size_t num_rows) override

◆ ~NumericValueConverter()

template<typename SOURCE_TYPE, typename TARGET_TYPE>
NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::~NumericValueConverter ( )
inlineoverride

Definition at line 57 of file TargetValueConvertersImpl.h.

57 {}

Member Function Documentation

◆ addDataBlocksToInsertData()

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

Implements TargetValueConverter.

Definition at line 111 of file TargetValueConvertersImpl.h.

111  {
112  DataBlockPtr dataBlock;
113  dataBlock.numbersPtr = reinterpret_cast<int8_t*>(column_data_.get());
114  insertData.data.push_back(dataBlock);
115  insertData.columnIds.push_back(column_descriptor_->columnId);
116  }
const ColumnDescriptor * column_descriptor_
std::vector< DataBlockPtr > data
the number of rows being inserted
Definition: Fragmenter.h:64
int8_t * numbersPtr
Definition: sqltypes.h:137
std::vector< int > columnIds
identifies the table into which the data is being inserted
Definition: Fragmenter.h:62

◆ allocateColumnarBuffer()

template<typename SOURCE_TYPE, typename TARGET_TYPE>
ElementsBufferColumnPtr NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::allocateColumnarBuffer ( size_t  num_rows)
inline

Definition at line 65 of file TargetValueConvertersImpl.h.

65  {
66  CHECK(num_rows > 0);
68  reinterpret_cast<TARGET_TYPE*>(checked_malloc(num_rows * sizeof(TARGET_TYPE))));
69  }
const int8_t const int64_t * num_rows
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:40
#define CHECK(condition)
Definition: Logger.h:187

◆ allocateColumnarData()

template<typename SOURCE_TYPE, typename TARGET_TYPE>
void NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::allocateColumnarData ( size_t  num_rows)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 59 of file TargetValueConvertersImpl.h.

59  {
60  CHECK(num_rows > 0);
62  reinterpret_cast<TARGET_TYPE*>(checked_malloc(num_rows * sizeof(TARGET_TYPE))));
63  }
const int8_t const int64_t * num_rows
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:40
#define CHECK(condition)
Definition: Logger.h:187
std::unique_ptr< TARGET_TYPE, CheckedMallocDeleter< TARGET_TYPE > > ColumnDataPtr

◆ convertElementToColumnarFormat()

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

74  {
75  auto mapd_p = checked_get<SOURCE_TYPE>(row, scalarValue, SOURCE_TYPE_ACCESSOR);
76  auto val = *mapd_p;
77 
78  if (do_null_check_ && null_check_value_ == val) {
79  columnData[row] = null_value_;
80  } else {
81  columnData[row] = static_cast<TARGET_TYPE>(val);
82  }
83  }
boost_variant_accessor< SOURCE_TYPE > SOURCE_TYPE_ACCESSOR

◆ convertToColumnarFormat() [1/2]

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

Definition at line 85 of file TargetValueConvertersImpl.h.

85  {
86  convertElementToColumnarFormat(row, column_data_.get(), scalarValue);
87  }
void convertElementToColumnarFormat(size_t row, typename ElementsBufferColumnPtr::pointer columnData, const ScalarTargetValue *scalarValue)

◆ convertToColumnarFormat() [2/2]

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

89  {
90  auto scalarValue =
91  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
92  convertToColumnarFormat(row, scalarValue);
93  }
void convertToColumnarFormat(size_t row, const ScalarTargetValue *scalarValue)
boost_variant_accessor< ScalarTargetValue > SCALAR_TARGET_VALUE_ACCESSOR

◆ processArrayBuffer()

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

98  {
99  for (size_t row = 0; row < array_buffer->size(); row++) {
100  auto& element = (array_buffer->at(row));
101  bool is_null = false;
102  if (element.second) {
103  ColumnDataPtr& data = element.second;
104  int8_t* arrayDataPtr = reinterpret_cast<int8_t*>(data.release());
105  (*arrayData)[row] =
106  ArrayDatum(element.first * sizeof(TARGET_TYPE), arrayDataPtr, is_null);
107  }
108  }
109  }
bool is_null(const T &v, const SQLTypeInfo &t)
std::unique_ptr< TARGET_TYPE, CheckedMallocDeleter< TARGET_TYPE > > ColumnDataPtr
std::conditional_t< isCudaCC(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:119

Member Data Documentation

◆ column_data_

template<typename SOURCE_TYPE, typename TARGET_TYPE>
ColumnDataPtr NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::column_data_

Definition at line 36 of file TargetValueConvertersImpl.h.

◆ do_null_check_

template<typename SOURCE_TYPE, typename TARGET_TYPE>
bool NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::do_null_check_

Definition at line 39 of file TargetValueConvertersImpl.h.

◆ null_check_value_

template<typename SOURCE_TYPE, typename TARGET_TYPE>
SOURCE_TYPE NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::null_check_value_

Definition at line 38 of file TargetValueConvertersImpl.h.

◆ null_value_

template<typename SOURCE_TYPE, typename TARGET_TYPE>
TARGET_TYPE NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::null_value_

Definition at line 37 of file TargetValueConvertersImpl.h.

◆ SOURCE_TYPE_ACCESSOR

template<typename SOURCE_TYPE, typename TARGET_TYPE>
boost_variant_accessor<SOURCE_TYPE> NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::SOURCE_TYPE_ACCESSOR

Definition at line 41 of file TargetValueConvertersImpl.h.


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