OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StringValueConverter Struct Reference

#include <TargetValueConvertersImpl.h>

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

Public Member Functions

 StringValueConverter (const ColumnDescriptor *cd, size_t num_rows, bool dictEncoded, const shared::StringDictKey &source_dict_key, 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 416 of file TargetValueConvertersImpl.h.

Constructor & Destructor Documentation

StringValueConverter::StringValueConverter ( const ColumnDescriptor cd,
size_t  num_rows,
bool  dictEncoded,
const shared::StringDictKey source_dict_key,
StringDictionaryProxy literals_dict 
)
inline

Definition at line 425 of file TargetValueConvertersImpl.h.

References allocateColumnarData(), CHECK, shared::StringDictKey::db_id, dict_encoded_, shared::StringDictKey::dict_id, Catalog_Namespace::SysCatalog::getCatalog(), Catalog_Namespace::SysCatalog::instance(), literals_source_dict_, and source_dict_.

430  : TargetValueConverter(cd) {
431  source_dict_ = nullptr;
432  literals_source_dict_ = nullptr;
433  dict_encoded_ = dictEncoded;
434  if (dictEncoded) {
435  if (0 != source_dict_key.dict_id) {
436  const auto source_cat =
438  CHECK(source_cat);
439  const auto source_dict_desc =
440  source_cat->getMetadataForDict(std::abs(source_dict_key.dict_id), true);
441  CHECK(source_dict_desc);
442  source_dict_ = source_dict_desc->stringDict.get();
444  } else {
445  literals_source_dict_ = literals_dict;
446  }
447  }
448  if (num_rows) {
449  allocateColumnarData(num_rows);
450  }
451  }
StringDictionaryProxy * literals_source_dict_
void allocateColumnarData(size_t num_rows) override
TargetValueConverter(const ColumnDescriptor *cd)
static SysCatalog & instance()
Definition: SysCatalog.h:343
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

StringValueConverter::~StringValueConverter ( )
inlineoverride

Definition at line 453 of file TargetValueConvertersImpl.h.

453 {}

Member Function Documentation

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

Implements TargetValueConverter.

Definition at line 504 of file TargetValueConvertersImpl.h.

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

504  {
505  DataBlockPtr dataBlock;
506  dataBlock.stringsPtr = column_data_.get();
507  insertData.data.push_back(dataBlock);
508  insertData.columnIds.push_back(column_descriptor_->columnId);
509  }
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:234
const ColumnDescriptor * column_descriptor_
std::vector< DataBlockPtr > data
the number of rows being inserted
Definition: Fragmenter.h:73
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:71
void StringValueConverter::allocateColumnarData ( size_t  num_rows)
inlineoverridevirtual

Implements TargetValueConverter.

Definition at line 455 of file TargetValueConvertersImpl.h.

References CHECK, and column_data_.

Referenced by StringValueConverter().

455  {
456  CHECK(num_rows > 0);
457  column_data_ = std::make_unique<std::vector<std::string>>(num_rows);
458  }
std::unique_ptr< std::vector< std::string > > column_data_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

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

Implements TargetValueConverter.

Definition at line 496 of file TargetValueConvertersImpl.h.

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

496  {
497  if (dict_encoded_) {
499  } else {
501  }
502  }
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 460 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().

460  {
461  auto scalarValue =
462  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
463  auto db_p = checked_get<int64_t>(row, scalarValue, this->SOURCE_TYPE_ACCESSOR);
464  auto val = *db_p;
465 
466  if (std::numeric_limits<int32_t>::min() == val) {
467  (*column_data_)[row] = std::string("");
468  } else {
469  if (source_dict_) {
470  std::string strVal = source_dict_->getString(val);
471  (*column_data_)[row] = strVal;
472  } else if (literals_source_dict_) {
473  std::string strVal = literals_source_dict_->getString(val);
474  (*column_data_)[row] = strVal;
475  } else {
476  CHECK_EQ(val, inline_int_null_value<int32_t>());
477  std::string nullStr = "";
478  (*column_data_)[row] = nullStr;
479  }
480  }
481  }
StringDictionaryProxy * literals_source_dict_
#define CHECK_EQ(x, y)
Definition: Logger.h:301
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 483 of file TargetValueConvertersImpl.h.

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

Referenced by convertToColumnarFormat().

483  {
484  auto scalarValue =
485  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
486  auto db_p = checked_get<NullableString>(row, scalarValue, NULLABLE_STRING_ACCESSOR);
487  const auto db_str_p = checked_get<std::string>(row, db_p, STRING_ACCESSOR);
488 
489  if (nullptr != db_str_p) {
490  (*column_data_)[row] = *db_str_p;
491  } else {
492  (*column_data_)[row] = std::string("");
493  }
494  }
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 417 of file TargetValueConvertersImpl.h.

Referenced by addDataBlocksToInsertData(), and allocateColumnarData().

bool StringValueConverter::dict_encoded_

Definition at line 423 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 419 of file TargetValueConvertersImpl.h.

Referenced by convertToColumnarFormatFromDict().


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