OmniSciDB  c07336695a
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_
 
- 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 331 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 339 of file TargetValueConvertersImpl.h.

References CHECK, and Catalog_Namespace::Catalog::getMetadataForDict().

345  : TargetValueConverter(cd) {
346  source_dict_ = nullptr;
347  literals_source_dict_ = nullptr;
348  if (dictEncoded) {
349  if (0 != sourceDictId) {
350  auto source_dict_desc = cat.getMetadataForDict(std::abs(sourceDictId), true);
351  CHECK(source_dict_desc);
352  source_dict_ = source_dict_desc->stringDict.get();
354  } else {
355  literals_source_dict_ = literals_dict;
357  }
358  }
359  if (num_rows) {
361  }
362  }
StringDictionaryProxy * literals_source_dict_
void allocateColumnarData(size_t num_rows) override
const int8_t const int64_t * num_rows
TargetValueConverter(const ColumnDescriptor *cd)
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1348
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ ~StringValueConverter()

StringValueConverter::~StringValueConverter ( )
inlineoverride

Definition at line 364 of file TargetValueConvertersImpl.h.

364 {}

Member Function Documentation

◆ addDataBlocksToInsertData()

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

Implements TargetValueConverter.

Definition at line 412 of file TargetValueConvertersImpl.h.

References Fragmenter_Namespace::InsertData::columnIds, Fragmenter_Namespace::InsertData::data, and DataBlockPtr::stringsPtr.

412  {
413  DataBlockPtr dataBlock;
414  dataBlock.stringsPtr = column_data_.get();
415  insertData.data.push_back(dataBlock);
416  insertData.columnIds.push_back(column_descriptor_->columnId);
417  }
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:138
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 366 of file TargetValueConvertersImpl.h.

References CHECK, and num_rows.

366  {
367  CHECK(num_rows > 0);
368  column_data_ = std::make_unique<std::vector<std::string>>(num_rows);
369  }
const int8_t const int64_t * num_rows
std::unique_ptr< std::vector< std::string > > column_data_
#define CHECK(condition)
Definition: Logger.h:187

◆ convertToColumnarFormat()

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

Implements TargetValueConverter.

Definition at line 404 of file TargetValueConvertersImpl.h.

404  {
407  } else {
409  }
410  }
StringDictionaryProxy * literals_source_dict_
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 371 of file TargetValueConvertersImpl.h.

References StringDictionaryProxy::getString(), and StringDictionary::getString().

371  {
372  auto scalarValue =
373  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
374  auto mapd_p = checked_get<int64_t>(row, scalarValue, this->SOURCE_TYPE_ACCESSOR);
375  auto val = *mapd_p;
376 
377  if (std::numeric_limits<int32_t>::min() == val) {
378  (*column_data_)[row] = std::string("");
379  } else {
380  if (source_dict_) {
381  std::string strVal = source_dict_->getString(val);
382  (*column_data_)[row] = strVal;
383  } else {
384  std::string strVal = literals_source_dict_->getString(val);
385  (*column_data_)[row] = strVal;
386  }
387  }
388  }
StringDictionaryProxy * literals_source_dict_
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 390 of file TargetValueConvertersImpl.h.

390  {
391  auto scalarValue =
392  checked_get<ScalarTargetValue>(row, value, SCALAR_TARGET_VALUE_ACCESSOR);
393  auto mapd_p = checked_get<NullableString>(row, scalarValue, NULLABLE_STRING_ACCESSOR);
394 
395  const auto mapd_str_p = checked_get<std::string>(row, mapd_p, STRING_ACCESSOR);
396 
397  if (nullptr != mapd_str_p) {
398  (*column_data_)[row] = *mapd_str_p;
399  } else {
400  (*column_data_)[row] = std::string("");
401  }
402  }
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 332 of file TargetValueConvertersImpl.h.

◆ literals_source_dict_

StringDictionaryProxy* StringValueConverter::literals_source_dict_

Definition at line 337 of file TargetValueConvertersImpl.h.

◆ source_dict_

StringDictionary* StringValueConverter::source_dict_

Definition at line 336 of file TargetValueConvertersImpl.h.

◆ SOURCE_TYPE_ACCESSOR

boost_variant_accessor<int64_t> StringValueConverter::SOURCE_TYPE_ACCESSOR

Definition at line 334 of file TargetValueConvertersImpl.h.


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