OmniSciDB  addbbd5075
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
< ArrayTargetValue
ARRAY_VALUE_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 ELEMENT_CONVERTER>
struct ArrayValueConverter< ELEMENT_CONVERTER >

Definition at line 471 of file TargetValueConvertersImpl.h.

Constructor & Destructor Documentation

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

References ArrayValueConverter< ELEMENT_CONVERTER >::allocateColumnarData(), ColumnDescriptor::columnType, ArrayValueConverter< ELEMENT_CONVERTER >::element_converter_, ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_elements_count_, ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_null_sentinel_, ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_size_, and SQLTypeInfoCore< TYPE_FACET_PACK >::get_size().

491  , element_converter_(std::move(element_converter))
493  , do_check_null_(do_check_null) {
494  if (num_rows) {
496  }
497 
498  if (cd->columnType.get_size() > 0) {
501  fixed_array_size_ / sizeof(ELEMENT_CONVERTER::fixed_array_null_value_);
502  element_converter_->populateFixedArrayNullSentinel(fixed_array_elements_count_);
504  reinterpret_cast<int8_t*>(element_converter_->column_data_.get());
505  } else {
506  fixed_array_size_ = 0;
508  fixed_array_null_sentinel_ = nullptr;
509  }
510  }
const int8_t const int64_t * num_rows
TargetValueConverter(const ColumnDescriptor *cd)
HOST DEVICE int get_size() const
Definition: sqltypes.h:336
std::unique_ptr< ELEMENT_CONVERTER > element_converter_
void allocateColumnarData(size_t num_rows) override
SQLTypeInfoCore get_elem_type() const
Definition: sqltypes.h:659
SQLTypeInfo columnType

+ Here is the call graph for this function:

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

Definition at line 512 of file TargetValueConvertersImpl.h.

512 {}

Member Function Documentation

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

Implements TargetValueConverter.

Definition at line 576 of file TargetValueConvertersImpl.h.

References DataBlockPtr::arraysPtr, ArrayValueConverter< ELEMENT_CONVERTER >::column_data_, TargetValueConverter::column_descriptor_, ColumnDescriptor::columnId, Fragmenter_Namespace::InsertData::columnIds, Fragmenter_Namespace::InsertData::data, and ArrayValueConverter< ELEMENT_CONVERTER >::finalizeDataBlocksForInsertData().

576  {
578  DataBlockPtr dataBlock;
579  dataBlock.arraysPtr = column_data_.get();
580  insertData.data.push_back(dataBlock);
581  insertData.columnIds.push_back(column_descriptor_->columnId);
582  }
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:142
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:

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

Implements TargetValueConverter.

Definition at line 514 of file TargetValueConvertersImpl.h.

References CHECK(), ArrayValueConverter< ELEMENT_CONVERTER >::column_buffer_, ArrayValueConverter< ELEMENT_CONVERTER >::column_data_, and num_rows.

Referenced by ArrayValueConverter< ELEMENT_CONVERTER >::ArrayValueConverter().

514  {
515  CHECK(num_rows > 0);
516  column_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
517  column_buffer_ = std::make_unique<std::vector<
518  std::pair<size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr>>>(
519  num_rows);
520  }
const int8_t const int64_t * num_rows
CHECK(cgen_state)
std::unique_ptr< std::vector< std::pair< size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr > > > column_buffer_
std::unique_ptr< std::vector< ArrayDatum > > column_data_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Implements TargetValueConverter.

Definition at line 522 of file TargetValueConvertersImpl.h.

References ArrayValueConverter< ELEMENT_CONVERTER >::ARRAY_VALUE_ACCESSOR, CHECK(), ArrayValueConverter< ELEMENT_CONVERTER >::column_buffer_, ArrayValueConverter< ELEMENT_CONVERTER >::do_check_null_, ArrayValueConverter< ELEMENT_CONVERTER >::element_converter_, ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_elements_count_, ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_null_sentinel_, ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_size_, and anonymous_namespace{TypedDataAccessors.h}::is_null().

522  {
523  const auto arrayValue =
524  checked_get<ArrayTargetValue>(row, value, ARRAY_VALUE_ACCESSOR);
525  CHECK(arrayValue);
526  if (arrayValue->is_initialized()) {
527  const auto& vec = arrayValue->get();
528  bool is_null = false;
529 
531  if (fixed_array_elements_count_ != vec.size()) {
532  throw std::runtime_error(
533  "Incorrect number of array elements for fixed length array column");
534  }
535  }
536 
537  if (vec.size()) {
538  typename ELEMENT_CONVERTER::ElementsBufferColumnPtr elementBuffer =
539  element_converter_->allocateColumnarBuffer(vec.size());
540 
541  int elementIndex = 0;
542  for (const auto& scalarValue : vec) {
543  element_converter_->convertElementToColumnarFormat(
544  elementIndex++, elementBuffer.get(), &scalarValue);
545  }
546 
547  column_buffer_->at(row) = {vec.size(), std::move(elementBuffer)};
548 
549  } else {
550  // Empty, not NULL
551  (*column_data_)[row] = ArrayDatum(0, nullptr, is_null, DoNothingDeleter());
552  }
553  } else {
554  if (!do_check_null_) {
555  throw std::runtime_error("NULL assignment of non null column not allowed");
556  }
557 
558  if (fixed_array_elements_count_ && !element_converter_->allowFixedNullArray()) {
559  throw std::runtime_error("NULL assignment of fixed length array not allowed");
560  }
561 
562  bool is_null = true; // do_check_null_;
563  (*column_data_)[row] = ArrayDatum(
565  (*column_data_)[row].is_null = is_null;
566  }
567  }
CHECK(cgen_state)
std::unique_ptr< ELEMENT_CONVERTER > element_converter_
bool is_null(const T &v, const SQLTypeInfo &t)
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:122

+ Here is the call graph for this function:

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

Reimplemented from TargetValueConverter.

Definition at line 569 of file TargetValueConvertersImpl.h.

References ArrayValueConverter< ELEMENT_CONVERTER >::column_buffer_, ArrayValueConverter< ELEMENT_CONVERTER >::column_data_, ArrayValueConverter< ELEMENT_CONVERTER >::data_finalized_, and ArrayValueConverter< ELEMENT_CONVERTER >::element_converter_.

Referenced by ArrayValueConverter< ELEMENT_CONVERTER >::addDataBlocksToInsertData().

569  {
570  if (!data_finalized_) {
571  element_converter_->processArrayBuffer(column_buffer_, column_data_.get());
572  data_finalized_ = true;
573  }
574  }
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_

+ Here is the caller graph for this function:

Member Data Documentation

template<typename ELEMENT_CONVERTER >
boost_variant_accessor<ArrayTargetValue> ArrayValueConverter< ELEMENT_CONVERTER >::ARRAY_VALUE_ACCESSOR
template<typename ELEMENT_CONVERTER >
std::unique_ptr< std::vector<std::pair<size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr> > > ArrayValueConverter< ELEMENT_CONVERTER >::column_buffer_
template<typename ELEMENT_CONVERTER >
bool ArrayValueConverter< ELEMENT_CONVERTER >::data_finalized_ = false
template<typename ELEMENT_CONVERTER >
bool ArrayValueConverter< ELEMENT_CONVERTER >::do_check_null_
template<typename ELEMENT_CONVERTER >
std::unique_ptr<ELEMENT_CONVERTER> ArrayValueConverter< ELEMENT_CONVERTER >::element_converter_
template<typename ELEMENT_CONVERTER >
SQLTypeInfo ArrayValueConverter< ELEMENT_CONVERTER >::element_type_info_

Definition at line 477 of file TargetValueConvertersImpl.h.

template<typename ELEMENT_CONVERTER >
size_t ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_elements_count_
template<typename ELEMENT_CONVERTER >
int8_t* ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_null_sentinel_
template<typename ELEMENT_CONVERTER >
size_t ArrayValueConverter< ELEMENT_CONVERTER >::fixed_array_size_

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