OmniSciDB  7bf56492aa
 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 468 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 483 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 SQLTypeInfo::get_size().

488  , element_converter_(std::move(element_converter))
490  , do_check_null_(do_check_null) {
491  if (num_rows) {
493  }
494 
495  if (cd->columnType.get_size() > 0) {
498  fixed_array_size_ / sizeof(ELEMENT_CONVERTER::fixed_array_null_value_);
499  element_converter_->populateFixedArrayNullSentinel(fixed_array_elements_count_);
501  reinterpret_cast<int8_t*>(element_converter_->column_data_.get());
502  } else {
503  fixed_array_size_ = 0;
505  fixed_array_null_sentinel_ = nullptr;
506  }
507  }
HOST DEVICE int get_size() const
Definition: sqltypes.h:258
const int8_t const int64_t * num_rows
TargetValueConverter(const ColumnDescriptor *cd)
std::unique_ptr< ELEMENT_CONVERTER > element_converter_
void allocateColumnarData(size_t num_rows) override
SQLTypeInfo columnType
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:603

+ Here is the call graph for this function:

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

Definition at line 509 of file TargetValueConvertersImpl.h.

509 {}

Member Function Documentation

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

Implements TargetValueConverter.

Definition at line 573 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().

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

511  {
512  CHECK(num_rows > 0);
513  column_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
514  column_buffer_ = std::make_unique<std::vector<
515  std::pair<size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr>>>(
516  num_rows);
517  }
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 519 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().

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

+ Here is the call graph for this function:

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

Reimplemented from TargetValueConverter.

Definition at line 566 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().

566  {
567  if (!data_finalized_) {
568  element_converter_->processArrayBuffer(column_buffer_, column_data_.get());
569  data_finalized_ = true;
570  }
571  }
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 474 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: