OmniSciDB  baf940c279
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
 
int8_t * fixed_array_null_sentinel_
 
size_t fixed_array_size_
 
size_t fixed_array_elements_count_
 
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 506 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 521 of file TargetValueConvertersImpl.h.

References NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::allocateColumnarData(), ColumnDescriptor::columnType, and SQLTypeInfo::get_size().

526  , element_converter_(std::move(element_converter))
528  , do_check_null_(do_check_null) {
529  if (num_rows) {
531  }
532 
533  if (cd->columnType.get_size() > 0) {
536  fixed_array_size_ / sizeof(ELEMENT_CONVERTER::fixed_array_null_value_);
537  element_converter_->populateFixedArrayNullSentinel(fixed_array_elements_count_);
539  reinterpret_cast<int8_t*>(element_converter_->column_data_.get());
540  } else {
541  fixed_array_size_ = 0;
543  fixed_array_null_sentinel_ = nullptr;
544  }
545  }
const int8_t const int64_t * num_rows
TargetValueConverter(const ColumnDescriptor *cd)
HOST DEVICE int get_size() const
Definition: sqltypes.h:269
std::unique_ptr< ELEMENT_CONVERTER > element_converter_
void allocateColumnarData(size_t num_rows) override
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:624
SQLTypeInfo columnType
+ Here is the call graph for this function:

◆ ~ArrayValueConverter()

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

Definition at line 547 of file TargetValueConvertersImpl.h.

547 {}

Member Function Documentation

◆ addDataBlocksToInsertData()

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

Implements TargetValueConverter.

Definition at line 611 of file TargetValueConvertersImpl.h.

References DataBlockPtr::arraysPtr, TargetValueConverter::column_descriptor_, ColumnDescriptor::columnId, Fragmenter_Namespace::InsertData::columnIds, Fragmenter_Namespace::InsertData::data, and TargetValueConverter::finalizeDataBlocksForInsertData().

611  {
613  DataBlockPtr dataBlock;
614  dataBlock.arraysPtr = column_data_.get();
615  insertData.data.push_back(dataBlock);
616  insertData.columnIds.push_back(column_descriptor_->columnId);
617  }
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:151
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
+ Here is the call graph for this function:

◆ allocateColumnarData()

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

Implements TargetValueConverter.

Definition at line 549 of file TargetValueConvertersImpl.h.

References CHECK, and num_rows.

549  {
550  CHECK(num_rows > 0);
551  column_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
552  column_buffer_ = std::make_unique<std::vector<
553  std::pair<size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr>>>(
554  num_rows);
555  }
const int8_t const int64_t * num_rows
#define CHECK(condition)
Definition: Logger.h:197
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 557 of file TargetValueConvertersImpl.h.

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

557  {
558  const auto arrayValue =
559  checked_get<ArrayTargetValue>(row, value, ARRAY_VALUE_ACCESSOR);
560  CHECK(arrayValue);
561  if (arrayValue->is_initialized()) {
562  const auto& vec = arrayValue->get();
563  bool is_null = false;
564 
566  if (fixed_array_elements_count_ != vec.size()) {
567  throw std::runtime_error(
568  "Incorrect number of array elements for fixed length array column");
569  }
570  }
571 
572  if (vec.size()) {
573  typename ELEMENT_CONVERTER::ElementsBufferColumnPtr elementBuffer =
574  element_converter_->allocateColumnarBuffer(vec.size());
575 
576  int elementIndex = 0;
577  for (const auto& scalarValue : vec) {
578  element_converter_->convertElementToColumnarFormat(
579  elementIndex++, elementBuffer.get(), &scalarValue);
580  }
581 
582  column_buffer_->at(row) = {vec.size(), std::move(elementBuffer)};
583 
584  } else {
585  // Empty, not NULL
586  (*column_data_)[row] = ArrayDatum(0, nullptr, is_null, DoNothingDeleter());
587  }
588  } else {
589  if (!do_check_null_) {
590  throw std::runtime_error("NULL assignment of non null column not allowed");
591  }
592 
593  if (fixed_array_elements_count_ && !element_converter_->allowFixedNullArray()) {
594  throw std::runtime_error("NULL assignment of fixed length array not allowed");
595  }
596 
597  bool is_null = true; // do_check_null_;
598  (*column_data_)[row] = ArrayDatum(
600  (*column_data_)[row].is_null = is_null;
601  }
602  }
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:131
std::unique_ptr< ELEMENT_CONVERTER > element_converter_
bool is_null(const T &v, const SQLTypeInfo &t)
#define CHECK(condition)
Definition: Logger.h:197
std::unique_ptr< std::vector< std::pair< size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr > > > column_buffer_
boost_variant_accessor< ArrayTargetValue > ARRAY_VALUE_ACCESSOR
+ 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 604 of file TargetValueConvertersImpl.h.

604  {
605  if (!data_finalized_) {
606  element_converter_->processArrayBuffer(column_buffer_, column_data_.get());
607  data_finalized_ = true;
608  }
609  }
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 519 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 509 of file TargetValueConvertersImpl.h.

◆ column_data_

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

Definition at line 510 of file TargetValueConvertersImpl.h.

◆ data_finalized_

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

Definition at line 514 of file TargetValueConvertersImpl.h.

◆ do_check_null_

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

Definition at line 513 of file TargetValueConvertersImpl.h.

◆ element_converter_

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

Definition at line 511 of file TargetValueConvertersImpl.h.

◆ element_type_info_

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

Definition at line 512 of file TargetValueConvertersImpl.h.

◆ fixed_array_elements_count_

template<typename ELEMENT_CONVERTER >
size_t ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_elements_count_

Definition at line 517 of file TargetValueConvertersImpl.h.

◆ fixed_array_null_sentinel_

template<typename ELEMENT_CONVERTER >
int8_t* ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_null_sentinel_

Definition at line 515 of file TargetValueConvertersImpl.h.

◆ fixed_array_size_

template<typename ELEMENT_CONVERTER >
size_t ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_size_

Definition at line 516 of file TargetValueConvertersImpl.h.


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