OmniSciDB  0264ff685a
StringValueConverter Struct Reference

#include <TargetValueConvertersImpl.h>

+ Inheritance diagram for StringValueConverter:
+ Collaboration diagram for StringValueConverter:

Public Member Functions

 StringValueConverter (const Catalog_Namespace::Catalog &cat, const ColumnDescriptor *cd, size_t num_rows, bool dictEncoded, int32_t sourceDictId, StringDictionaryProxy *literals_dict)
 
 ~StringValueConverter () override
 
void allocateColumnarData (size_t num_rows) override
 
void convertToColumnarFormatFromDict (size_t row, const TargetValue *value)
 
void convertToColumnarFormatFromString (size_t row, const TargetValue *value)
 
void convertToColumnarFormat (size_t row, const TargetValue *value) override
 
void addDataBlocksToInsertData (Fragmenter_Namespace::InsertData &insertData) override
 
- Public Member Functions inherited from TargetValueConverter
 TargetValueConverter (const ColumnDescriptor *cd)
 
virtual ~TargetValueConverter ()
 
virtual void finalizeDataBlocksForInsertData ()
 

Public Attributes

std::unique_ptr< std::vector< std::string > > column_data_
 
boost_variant_accessor< int64_t > SOURCE_TYPE_ACCESSOR
 
StringDictionarysource_dict_
 
StringDictionaryProxyliterals_source_dict_
 
bool dict_encoded_
 
- 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

Definition at line 412 of file TargetValueConvertersImpl.h.

Constructor & Destructor Documentation

◆ StringValueConverter()

StringValueConverter::StringValueConverter ( const Catalog_Namespace::Catalog cat,
const ColumnDescriptor cd,
size_t  num_rows,
bool  dictEncoded,
int32_t  sourceDictId,
StringDictionaryProxy literals_dict 
)
inline

Definition at line 421 of file TargetValueConvertersImpl.h.

References NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::allocateColumnarData(), CHECK, and Catalog_Namespace::Catalog::getMetadataForDict().

427  : TargetValueConverter(cd) {
428  source_dict_ = nullptr;
429  literals_source_dict_ = nullptr;
430  dict_encoded_ = dictEncoded;
431  if (dictEncoded) {
432  if (0 != sourceDictId) {
433  auto source_dict_desc = cat.getMetadataForDict(std::abs(sourceDictId), true);
434  CHECK(source_dict_desc);
435  source_dict_ = source_dict_desc->stringDict.get();
437  } else {
438  literals_source_dict_ = literals_dict;
439  }
440  }
441  if (num_rows) {
442  allocateColumnarData(num_rows);
443  }
444  }
StringDictionaryProxy * literals_source_dict_
void allocateColumnarData(size_t num_rows) override
TargetValueConverter(const ColumnDescriptor *cd)
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1439
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:

◆ ~StringValueConverter()

StringValueConverter::~StringValueConverter ( )
inlineoverride

Definition at line 446 of file TargetValueConvertersImpl.h.

446 {}

Member Function Documentation

◆ addDataBlocksToInsertData()

void StringValueConverter::addDataBlocksToInsertData ( Fragmenter_Namespace::InsertData insertData)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 497 of file TargetValueConvertersImpl.h.

References TargetValueConverter::column_descriptor_, ColumnDescriptor::columnId, Fragmenter_Namespace::InsertData::columnIds, Fragmenter_Namespace::InsertData::data, and DataBlockPtr::stringsPtr.

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

◆ allocateColumnarData()

void StringValueConverter::allocateColumnarData ( size_t  num_rows)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 448 of file TargetValueConvertersImpl.h.

References CHECK.

448  {
449  CHECK(num_rows > 0);
450  column_data_ = std::make_unique<std::vector<std::string>>(num_rows);
451  }
std::unique_ptr< std::vector< std::string > > column_data_
#define CHECK(condition)
Definition: Logger.h:197

◆ convertToColumnarFormat()

void StringValueConverter::convertToColumnarFormat ( size_t  row,
const TargetValue value 
)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 489 of file TargetValueConvertersImpl.h.

489  {
490  if (dict_encoded_) {
492  } else {
494  }
495  }
void convertToColumnarFormatFromDict(size_t row, const TargetValue *value)
void convertToColumnarFormatFromString(size_t row, const TargetValue *value)

◆ convertToColumnarFormatFromDict()

void StringValueConverter::convertToColumnarFormatFromDict ( size_t  row,
const TargetValue value 
)
inline

Definition at line 453 of file TargetValueConvertersImpl.h.

References CHECK_EQ, StringDictionaryProxy::getString(), StringDictionary::getString(), TargetValueConverter::SCALAR_TARGET_VALUE_ACCESSOR, and NumericValueConverter< SOURCE_TYPE, TARGET_TYPE >::SOURCE_TYPE_ACCESSOR.

453  {
454  auto scalarValue =
455  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
456  auto db_p = checked_get<int64_t>(row, scalarValue, this->SOURCE_TYPE_ACCESSOR);
457  auto val = *db_p;
458 
459  if (std::numeric_limits<int32_t>::min() == val) {
460  (*column_data_)[row] = std::string("");
461  } else {
462  if (source_dict_) {
463  std::string strVal = source_dict_->getString(val);
464  (*column_data_)[row] = strVal;
465  } else if (literals_source_dict_) {
466  std::string strVal = literals_source_dict_->getString(val);
467  (*column_data_)[row] = strVal;
468  } else {
469  CHECK_EQ(val, inline_int_null_value<int32_t>());
470  std::string nullStr = "";
471  (*column_data_)[row] = nullStr;
472  }
473  }
474  }
StringDictionaryProxy * literals_source_dict_
#define CHECK_EQ(x, y)
Definition: Logger.h:205
boost_variant_accessor< int64_t > SOURCE_TYPE_ACCESSOR
std::string getString(int32_t string_id) const
boost_variant_accessor< ScalarTargetValue > SCALAR_TARGET_VALUE_ACCESSOR
std::string getString(int32_t string_id) const
+ Here is the call graph for this function:

◆ convertToColumnarFormatFromString()

void StringValueConverter::convertToColumnarFormatFromString ( size_t  row,
const TargetValue value 
)
inline

Definition at line 476 of file TargetValueConvertersImpl.h.

References TargetValueConverter::NULLABLE_STRING_ACCESSOR, TargetValueConverter::SCALAR_TARGET_VALUE_ACCESSOR, and TargetValueConverter::STRING_ACCESSOR.

476  {
477  auto scalarValue =
478  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
479  auto db_p = checked_get<NullableString>(row, scalarValue, NULLABLE_STRING_ACCESSOR);
480  const auto db_str_p = checked_get<std::string>(row, db_p, STRING_ACCESSOR);
481 
482  if (nullptr != db_str_p) {
483  (*column_data_)[row] = *db_str_p;
484  } else {
485  (*column_data_)[row] = std::string("");
486  }
487  }
boost_variant_accessor< ScalarTargetValue > SCALAR_TARGET_VALUE_ACCESSOR
boost_variant_accessor< NullableString > NULLABLE_STRING_ACCESSOR
boost_variant_accessor< std::string > STRING_ACCESSOR

Member Data Documentation

◆ column_data_

std::unique_ptr<std::vector<std::string> > StringValueConverter::column_data_

Definition at line 413 of file TargetValueConvertersImpl.h.

◆ dict_encoded_

bool StringValueConverter::dict_encoded_

Definition at line 419 of file TargetValueConvertersImpl.h.

◆ literals_source_dict_

StringDictionaryProxy* StringValueConverter::literals_source_dict_

Definition at line 418 of file TargetValueConvertersImpl.h.

◆ source_dict_

StringDictionary* StringValueConverter::source_dict_

Definition at line 417 of file TargetValueConvertersImpl.h.

◆ SOURCE_TYPE_ACCESSOR

boost_variant_accessor<int64_t> StringValueConverter::SOURCE_TYPE_ACCESSOR

Definition at line 415 of file TargetValueConvertersImpl.h.


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