OmniSciDB  0fdbebe030
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
< 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

Definition at line 373 of file TargetValueConvertersImpl.h.

Constructor & Destructor Documentation

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

References allocateColumnarData(), CHECK(), dict_encoded_, Catalog_Namespace::Catalog::getMetadataForDict(), literals_source_dict_, and source_dict_.

388  : TargetValueConverter(cd) {
389  source_dict_ = nullptr;
390  literals_source_dict_ = nullptr;
391  dict_encoded_ = dictEncoded;
392  if (dictEncoded) {
393  if (0 != sourceDictId) {
394  auto source_dict_desc = cat.getMetadataForDict(std::abs(sourceDictId), true);
395  CHECK(source_dict_desc);
396  source_dict_ = source_dict_desc->stringDict.get();
398  } else {
399  literals_source_dict_ = literals_dict;
400  }
401  }
402  if (num_rows) {
404  }
405  }
StringDictionaryProxy * literals_source_dict_
void allocateColumnarData(size_t num_rows) override
const int8_t const int64_t * num_rows
TargetValueConverter(const ColumnDescriptor *cd)
CHECK(cgen_state)
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1444

+ Here is the call graph for this function:

StringValueConverter::~StringValueConverter ( )
inlineoverride

Definition at line 407 of file TargetValueConvertersImpl.h.

407 {}

Member Function Documentation

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

Implements TargetValueConverter.

Definition at line 459 of file TargetValueConvertersImpl.h.

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

459  {
460  DataBlockPtr dataBlock;
461  dataBlock.stringsPtr = column_data_.get();
462  insertData.data.push_back(dataBlock);
463  insertData.columnIds.push_back(column_descriptor_->columnId);
464  }
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:139
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
void StringValueConverter::allocateColumnarData ( size_t  num_rows)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 409 of file TargetValueConvertersImpl.h.

References CHECK(), column_data_, and num_rows.

Referenced by StringValueConverter().

409  {
410  CHECK(num_rows > 0);
411  column_data_ = std::make_unique<std::vector<std::string>>(num_rows);
412  }
const int8_t const int64_t * num_rows
CHECK(cgen_state)
std::unique_ptr< std::vector< std::string > > column_data_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Implements TargetValueConverter.

Definition at line 451 of file TargetValueConvertersImpl.h.

References convertToColumnarFormatFromDict(), convertToColumnarFormatFromString(), and dict_encoded_.

451  {
452  if (dict_encoded_) {
454  } else {
456  }
457  }
void convertToColumnarFormatFromDict(size_t row, const TargetValue *value)
void convertToColumnarFormatFromString(size_t row, const TargetValue *value)

+ Here is the call graph for this function:

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

Definition at line 414 of file TargetValueConvertersImpl.h.

References CHECK_EQ, StringDictionaryProxy::getString(), StringDictionary::getString(), literals_source_dict_, TargetValueConverter::SCALAR_TARGET_VALUE_ACCESSOR, source_dict_, and SOURCE_TYPE_ACCESSOR.

Referenced by convertToColumnarFormat().

414  {
415  auto scalarValue =
416  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
417  auto mapd_p = checked_get<int64_t>(row, scalarValue, this->SOURCE_TYPE_ACCESSOR);
418  auto val = *mapd_p;
419 
420  if (std::numeric_limits<int32_t>::min() == val) {
421  (*column_data_)[row] = std::string("");
422  } else {
423  if (source_dict_) {
424  std::string strVal = source_dict_->getString(val);
425  (*column_data_)[row] = strVal;
426  } else if (literals_source_dict_) {
427  std::string strVal = literals_source_dict_->getString(val);
428  (*column_data_)[row] = strVal;
429  } else {
430  CHECK_EQ(val, inline_int_null_value<int32_t>());
431  std::string nullStr = "";
432  (*column_data_)[row] = nullStr;
433  }
434  }
435  }
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:

+ Here is the caller graph for this function:

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

Definition at line 437 of file TargetValueConvertersImpl.h.

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

Referenced by convertToColumnarFormat().

437  {
438  auto scalarValue =
439  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
440  auto mapd_p = checked_get<NullableString>(row, scalarValue, NULLABLE_STRING_ACCESSOR);
441 
442  const auto mapd_str_p = checked_get<std::string>(row, mapd_p, STRING_ACCESSOR);
443 
444  if (nullptr != mapd_str_p) {
445  (*column_data_)[row] = *mapd_str_p;
446  } else {
447  (*column_data_)[row] = std::string("");
448  }
449  }
boost_variant_accessor< ScalarTargetValue > SCALAR_TARGET_VALUE_ACCESSOR
boost_variant_accessor< NullableString > NULLABLE_STRING_ACCESSOR
boost_variant_accessor< std::string > STRING_ACCESSOR

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 374 of file TargetValueConvertersImpl.h.

Referenced by addDataBlocksToInsertData(), and allocateColumnarData().

bool StringValueConverter::dict_encoded_

Definition at line 380 of file TargetValueConvertersImpl.h.

Referenced by convertToColumnarFormat(), and StringValueConverter().

StringDictionaryProxy* StringValueConverter::literals_source_dict_
StringDictionary* StringValueConverter::source_dict_
boost_variant_accessor<int64_t> StringValueConverter::SOURCE_TYPE_ACCESSOR

Definition at line 376 of file TargetValueConvertersImpl.h.

Referenced by convertToColumnarFormatFromDict().


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