OmniSciDB  5ade3759e0
ArrayValueConverter< ELEMENT_CONVERTER > Struct Template Reference

#include <TargetValueConvertersImpl.h>

+ Inheritance diagram for ArrayValueConverter< ELEMENT_CONVERTER >:
+ Collaboration diagram for ArrayValueConverter< ELEMENT_CONVERTER >:

Public Member Functions

 ArrayValueConverter (const ColumnDescriptor *cd, size_t num_rows, std::unique_ptr< ELEMENT_CONVERTER > element_converter, bool do_check_null)
 
 ~ArrayValueConverter () override
 
void allocateColumnarData (size_t num_rows) override
 
void convertToColumnarFormat (size_t row, const TargetValue *value) override
 
void finalizeDataBlocksForInsertData () override
 
void addDataBlocksToInsertData (Fragmenter_Namespace::InsertData &insertData) override
 
- Public Member Functions inherited from TargetValueConverter
 TargetValueConverter (const ColumnDescriptor *cd)
 
virtual ~TargetValueConverter ()
 

Public Attributes

std::unique_ptr< std::vector< std::pair< size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr > > > column_buffer_
 
std::unique_ptr< std::vector< ArrayDatum > > column_data_
 
std::unique_ptr< ELEMENT_CONVERTER > element_converter_
 
SQLTypeInfo element_type_info_
 
bool do_check_null_
 
bool data_finalized_ = false
 
boost_variant_accessor< ArrayTargetValueARRAY_VALUE_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 ELEMENT_CONVERTER>
struct ArrayValueConverter< ELEMENT_CONVERTER >

Definition at line 421 of file TargetValueConvertersImpl.h.

Constructor & Destructor Documentation

◆ ArrayValueConverter()

template<typename ELEMENT_CONVERTER >
ArrayValueConverter< ELEMENT_CONVERTER >::ArrayValueConverter ( const ColumnDescriptor cd,
size_t  num_rows,
std::unique_ptr< ELEMENT_CONVERTER >  element_converter,
bool  do_check_null 
)
inline

Definition at line 433 of file TargetValueConvertersImpl.h.

438  , element_converter_(std::move(element_converter))
440  , do_check_null_(do_check_null) {
441  if (num_rows) {
443  }
444  }
const int8_t const int64_t * num_rows
TargetValueConverter(const ColumnDescriptor *cd)
SQLTypeInfoCore get_elem_type() const
Definition: sqltypes.h:632
std::unique_ptr< ELEMENT_CONVERTER > element_converter_
void allocateColumnarData(size_t num_rows) override
SQLTypeInfo columnType

◆ ~ArrayValueConverter()

template<typename ELEMENT_CONVERTER >
ArrayValueConverter< ELEMENT_CONVERTER >::~ArrayValueConverter ( )
inlineoverride

Definition at line 446 of file TargetValueConvertersImpl.h.

446 {}

Member Function Documentation

◆ addDataBlocksToInsertData()

template<typename ELEMENT_CONVERTER >
void ArrayValueConverter< ELEMENT_CONVERTER >::addDataBlocksToInsertData ( Fragmenter_Namespace::InsertData insertData)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 495 of file TargetValueConvertersImpl.h.

References DataBlockPtr::arraysPtr, Fragmenter_Namespace::InsertData::columnIds, and Fragmenter_Namespace::InsertData::data.

495  {
497  DataBlockPtr dataBlock;
498  dataBlock.arraysPtr = column_data_.get();
499  insertData.data.push_back(dataBlock);
500  insertData.columnIds.push_back(column_descriptor_->columnId);
501  }
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:139
const ColumnDescriptor * column_descriptor_
void finalizeDataBlocksForInsertData() override
std::vector< DataBlockPtr > data
the number of rows being inserted
Definition: Fragmenter.h:64
std::unique_ptr< std::vector< ArrayDatum > > column_data_
std::vector< int > columnIds
identifies the table into which the data is being inserted
Definition: Fragmenter.h:62

◆ allocateColumnarData()

template<typename ELEMENT_CONVERTER >
void ArrayValueConverter< ELEMENT_CONVERTER >::allocateColumnarData ( size_t  num_rows)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 448 of file TargetValueConvertersImpl.h.

References CHECK, and num_rows.

448  {
449  CHECK(num_rows > 0);
450  column_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
451  column_buffer_ = std::make_unique<std::vector<
452  std::pair<size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr>>>(
453  num_rows);
454  }
const int8_t const int64_t * num_rows
#define CHECK(condition)
Definition: Logger.h:187
std::unique_ptr< std::vector< std::pair< size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr > > > column_buffer_
std::unique_ptr< std::vector< ArrayDatum > > column_data_

◆ convertToColumnarFormat()

template<typename ELEMENT_CONVERTER >
void ArrayValueConverter< ELEMENT_CONVERTER >::convertToColumnarFormat ( size_t  row,
const TargetValue value 
)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 456 of file TargetValueConvertersImpl.h.

References CHECK, and anonymous_namespace{TypedDataAccessors.h}::is_null().

456  {
457  const auto arrayValue =
458  checked_get<ArrayTargetValue>(row, value, ARRAY_VALUE_ACCESSOR);
459  CHECK(arrayValue);
460  if (arrayValue->is_initialized()) {
461  const auto& vec = arrayValue->get();
462  bool is_null = false;
463  if (vec.size()) {
464  typename ELEMENT_CONVERTER::ElementsBufferColumnPtr elementBuffer =
465  element_converter_->allocateColumnarBuffer(vec.size());
466 
467  int elementIndex = 0;
468  for (const auto& scalarValue : vec) {
469  element_converter_->convertElementToColumnarFormat(
470  elementIndex++, elementBuffer.get(), &scalarValue);
471  }
472 
473  column_buffer_->at(row) = {vec.size(), std::move(elementBuffer)};
474 
475  } else {
476  // Empty, not NULL
477  (*column_data_)[row] = ArrayDatum(0, nullptr, is_null, DoNothingDeleter());
478  }
479  } else {
480  // TODO: what does it mean if do_check_null_ is set to false and we get a NULL?
481  // CHECK(do_check_null_); // May need to check
482  bool is_null = true; // do_check_null_;
483  (*column_data_)[row] = ArrayDatum(0, nullptr, is_null, DoNothingDeleter());
484  (*column_data_)[row].is_null = is_null;
485  }
486  }
std::unique_ptr< ELEMENT_CONVERTER > element_converter_
bool is_null(const T &v, const SQLTypeInfo &t)
#define CHECK(condition)
Definition: Logger.h:187
std::unique_ptr< std::vector< std::pair< size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr > > > column_buffer_
boost_variant_accessor< ArrayTargetValue > ARRAY_VALUE_ACCESSOR
std::conditional_t< isCudaCC(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:119
+ Here is the call graph for this function:

◆ finalizeDataBlocksForInsertData()

template<typename ELEMENT_CONVERTER >
void ArrayValueConverter< ELEMENT_CONVERTER >::finalizeDataBlocksForInsertData ( )
inlineoverridevirtual

Reimplemented from TargetValueConverter.

Definition at line 488 of file TargetValueConvertersImpl.h.

488  {
489  if (!data_finalized_) {
490  element_converter_->processArrayBuffer(column_buffer_, column_data_.get());
491  data_finalized_ = true;
492  }
493  }
std::unique_ptr< ELEMENT_CONVERTER > element_converter_
std::unique_ptr< std::vector< std::pair< size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr > > > column_buffer_
std::unique_ptr< std::vector< ArrayDatum > > column_data_

Member Data Documentation

◆ ARRAY_VALUE_ACCESSOR

template<typename ELEMENT_CONVERTER >
boost_variant_accessor<ArrayTargetValue> ArrayValueConverter< ELEMENT_CONVERTER >::ARRAY_VALUE_ACCESSOR

Definition at line 431 of file TargetValueConvertersImpl.h.

◆ column_buffer_

template<typename ELEMENT_CONVERTER >
std::unique_ptr< std::vector<std::pair<size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr> > > ArrayValueConverter< ELEMENT_CONVERTER >::column_buffer_

Definition at line 424 of file TargetValueConvertersImpl.h.

◆ column_data_

template<typename ELEMENT_CONVERTER >
std::unique_ptr<std::vector<ArrayDatum> > ArrayValueConverter< ELEMENT_CONVERTER >::column_data_

Definition at line 425 of file TargetValueConvertersImpl.h.

◆ data_finalized_

template<typename ELEMENT_CONVERTER >
bool ArrayValueConverter< ELEMENT_CONVERTER >::data_finalized_ = false

Definition at line 429 of file TargetValueConvertersImpl.h.

◆ do_check_null_

template<typename ELEMENT_CONVERTER >
bool ArrayValueConverter< ELEMENT_CONVERTER >::do_check_null_

Definition at line 428 of file TargetValueConvertersImpl.h.

◆ element_converter_

template<typename ELEMENT_CONVERTER >
std::unique_ptr<ELEMENT_CONVERTER> ArrayValueConverter< ELEMENT_CONVERTER >::element_converter_

Definition at line 426 of file TargetValueConvertersImpl.h.

◆ element_type_info_

template<typename ELEMENT_CONVERTER >
SQLTypeInfo ArrayValueConverter< ELEMENT_CONVERTER >::element_type_info_

Definition at line 427 of file TargetValueConvertersImpl.h.


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