OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 513 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 528 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().

533  , element_converter_(std::move(element_converter))
535  , do_check_null_(do_check_null) {
536  if (num_rows) {
537  allocateColumnarData(num_rows);
538  }
539 
540  if (cd->columnType.get_size() > 0) {
543  fixed_array_size_ / sizeof(ELEMENT_CONVERTER::fixed_array_null_value_);
544  element_converter_->populateFixedArrayNullSentinel(fixed_array_elements_count_);
546  reinterpret_cast<int8_t*>(element_converter_->column_data_.get());
547  } else {
548  fixed_array_size_ = 0;
550  fixed_array_null_sentinel_ = nullptr;
551  }
552  }
HOST DEVICE int get_size() const
Definition: sqltypes.h:403
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:977

+ Here is the call graph for this function:

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

Definition at line 554 of file TargetValueConvertersImpl.h.

554 {}

Member Function Documentation

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

Implements TargetValueConverter.

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

614  {
616  DataBlockPtr dataBlock;
617  dataBlock.arraysPtr = column_data_.get();
618  insertData.data.push_back(dataBlock);
619  insertData.columnIds.push_back(column_descriptor_->columnId);
620  }
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:235
const ColumnDescriptor * column_descriptor_
void finalizeDataBlocksForInsertData() override
std::vector< DataBlockPtr > data
the number of rows being inserted
Definition: Fragmenter.h:73
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:71

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

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

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

556  {
557  CHECK(num_rows > 0);
558  column_data_ = std::make_unique<std::vector<ArrayDatum>>(num_rows);
559  column_buffer_ = std::make_unique<std::vector<
560  std::pair<size_t, typename ELEMENT_CONVERTER::ElementsBufferColumnPtr>>>(
561  num_rows);
562  }
#define CHECK(condition)
Definition: Logger.h:291
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:

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

Implements TargetValueConverter.

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

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

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

Reimplemented from TargetValueConverter.

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

607  {
608  if (!data_finalized_) {
609  element_converter_->processArrayBuffer(column_buffer_, column_data_.get());
610  data_finalized_ = true;
611  }
612  }
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 519 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: