OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
data_conversion::StringViewSource Class Reference

#include <StringViewSource.h>

+ Inheritance diagram for data_conversion::StringViewSource:
+ Collaboration diagram for data_conversion::StringViewSource:

Public Member Functions

 StringViewSource (const Chunk_NS::Chunk &input)
 
std::pair< const int8_t *, size_t > getSourceData () override
 
- Public Member Functions inherited from data_conversion::BaseSource
virtual ~BaseSource ()=default
 

Private Attributes

std::vector< std::string_view > src_string_views_
 
const Chunk_NS::Chunkinput_
 

Detailed Description

Definition at line 89 of file StringViewSource.h.

Constructor & Destructor Documentation

data_conversion::StringViewSource::StringViewSource ( const Chunk_NS::Chunk input)
inline

Definition at line 91 of file StringViewSource.h.

91 : input_(input) {}
const Chunk_NS::Chunk & input_

Member Function Documentation

std::pair<const int8_t*, size_t> data_conversion::StringViewSource::getSourceData ( )
inlineoverridevirtual

Implements data_conversion::BaseSource.

Definition at line 93 of file StringViewSource.h.

References CHECK, ColumnDescriptor::columnType, data_conversion::anonymous_namespace{StringViewSource.h}::get_materialized_string_views(), Chunk_NS::Chunk::getBuffer(), Catalog_Namespace::SysCatalog::getCatalog(), Chunk_NS::Chunk::getColumnDesc(), Chunk_NS::Chunk::getIndexBuf(), StringNoneEncoder::getStringAtIndex(), SQLTypeInfo::getStringDictKey(), input_, Catalog_Namespace::SysCatalog::instance(), src_string_views_, and UNREACHABLE.

93  {
94  auto buffer = input_.getBuffer();
95  auto src_type_info = input_.getColumnDesc()->columnType;
96  auto dict_key = src_type_info.getStringDictKey();
97  auto num_elements = buffer->getEncoder()->getNumElems();
98 
99  if (src_type_info.is_dict_encoded_string()) {
100  auto catalog = Catalog_Namespace::SysCatalog::instance().getCatalog(dict_key.db_id);
101 
102  auto src_string_dictionary =
103  catalog->getMetadataForDict(dict_key.dict_id, true)->stringDict.get();
104  CHECK(src_string_dictionary);
106  num_elements, src_string_dictionary, buffer->getMemoryPtr(), src_type_info);
107  } else if (src_type_info.is_none_encoded_string()) {
108  auto index_buffer = input_.getIndexBuf();
109  src_string_views_.resize(num_elements);
110  for (size_t i = 0; i < num_elements; ++i) {
112  index_buffer->getMemoryPtr(), buffer->getMemoryPtr(), i);
113  }
114  } else {
115  UNREACHABLE() << "unknown string type";
116  }
117 
118  return {reinterpret_cast<int8_t*>(src_string_views_.data()), num_elements};
119  }
AbstractBuffer * getIndexBuf() const
Definition: Chunk.h:148
static std::string_view getStringAtIndex(const int8_t *index_data, const int8_t *data, size_t index)
std::vector< std::string_view > get_materialized_string_views(const size_t num_elements, const StringDictionary *string_dict, const T *ids)
#define UNREACHABLE()
Definition: Logger.h:338
const ColumnDescriptor * getColumnDesc() const
Definition: Chunk.h:65
static SysCatalog & instance()
Definition: SysCatalog.h:343
const Chunk_NS::Chunk & input_
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
AbstractBuffer * getBuffer() const
Definition: Chunk.h:146
#define CHECK(condition)
Definition: Logger.h:291
std::vector< std::string_view > src_string_views_
SQLTypeInfo columnType
const shared::StringDictKey & getStringDictKey() const
Definition: sqltypes.h:1057

+ Here is the call graph for this function:

Member Data Documentation

const Chunk_NS::Chunk& data_conversion::StringViewSource::input_
private

Definition at line 124 of file StringViewSource.h.

Referenced by getSourceData().

std::vector<std::string_view> data_conversion::StringViewSource::src_string_views_
private

Definition at line 122 of file StringViewSource.h.

Referenced by getSourceData().


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