OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
data_conversion::StringViewToStringDictEncoder< IdType > Class Template Reference

#include <StringViewToStringDictEncoder.h>

+ Inheritance diagram for data_conversion::StringViewToStringDictEncoder< IdType >:
+ Collaboration diagram for data_conversion::StringViewToStringDictEncoder< IdType >:

Public Member Functions

 StringViewToStringDictEncoder (const Chunk_NS::Chunk &dst_chunk, const bool error_tracking_enabled)
 
void encodeAndAppendData (const int8_t *data, const size_t num_elements) override
 
void clear () override
 
const Chunk_NS::ChunkgetDstChunk () const
 
std::optional< std::vector
< bool > > & 
getDeleteBuffer ()
 
- Public Member Functions inherited from data_conversion::TypedBaseConvertEncoder< IdType >
 TypedBaseConvertEncoder (const bool error_tracking_enabled)
 
std::shared_ptr< ChunkMetadatagetMetadata (const Chunk_NS::Chunk &chunk) const override
 
- Public Member Functions inherited from data_conversion::BaseConvertEncoder
virtual ~BaseConvertEncoder ()
 
 BaseConvertEncoder (const bool error_tracking_enabled)
 
void initializeDeleteBuffer (const size_t size_hint)
 
virtual void finalize (const size_t rows_appended)
 

Private Member Functions

void initialize ()
 

Private Attributes

SQLTypeInfo dst_type_info_
 
const Chunk_NS::Chunkdst_chunk_
 
StringDictionarystring_dict_
 
std::vector< IdType > dict_encoding_output_buffer_
 
AbstractBufferbuffer_
 

Additional Inherited Members

- Public Types inherited from data_conversion::TypedBaseConvertEncoder< IdType >
using DataType = IdType
 
using MetadataType = IdType
 
- Protected Member Functions inherited from data_conversion::TypedBaseConvertEncoder< IdType >
DataType getNull () const
 
void updateMetadataStats (const DataType &typed_value, const bool is_date_in_days=false)
 
- Protected Member Functions inherited from data_conversion::BaseConvertEncoder
template<typename DataType >
bool isNull (const DataType &typed_value)
 
- Protected Attributes inherited from data_conversion::TypedBaseConvertEncoder< IdType >
MetadataType min_
 
MetadataType max_
 
- Protected Attributes inherited from data_conversion::BaseConvertEncoder
std::optional< std::vector
< bool > > 
delete_buffer_
 
const bool error_tracking_enabled_
 
bool has_nulls_
 
size_t num_elements_
 

Detailed Description

template<typename IdType>
class data_conversion::StringViewToStringDictEncoder< IdType >

Definition at line 25 of file StringViewToStringDictEncoder.h.

Constructor & Destructor Documentation

template<typename IdType >
data_conversion::StringViewToStringDictEncoder< IdType >::StringViewToStringDictEncoder ( const Chunk_NS::Chunk dst_chunk,
const bool  error_tracking_enabled 
)
inline

Definition at line 27 of file StringViewToStringDictEncoder.h.

References data_conversion::StringViewToStringDictEncoder< IdType >::initialize().

29  : TypedBaseConvertEncoder<IdType>(error_tracking_enabled), dst_chunk_(dst_chunk) {
30  initialize();
31  }

+ Here is the call graph for this function:

Member Function Documentation

template<typename IdType >
void data_conversion::StringViewToStringDictEncoder< IdType >::clear ( )
inlineoverridevirtual

Reimplemented from data_conversion::BaseConvertEncoder.

Definition at line 85 of file StringViewToStringDictEncoder.h.

References data_conversion::StringViewToStringDictEncoder< IdType >::buffer_, data_conversion::BaseConvertEncoder::clear(), and Data_Namespace::AbstractBuffer::resetToEmpty().

+ Here is the call graph for this function:

template<typename IdType >
void data_conversion::StringViewToStringDictEncoder< IdType >::encodeAndAppendData ( const int8_t *  data,
const size_t  num_elements 
)
inlineoverridevirtual

Implements data_conversion::BaseConvertEncoder.

Definition at line 33 of file StringViewToStringDictEncoder.h.

References Data_Namespace::AbstractBuffer::append(), data_conversion::StringViewToStringDictEncoder< IdType >::buffer_, CHECK, data_conversion::BaseConvertEncoder::delete_buffer_, data_conversion::StringViewToStringDictEncoder< IdType >::dict_encoding_output_buffer_, data_conversion::StringViewToStringDictEncoder< IdType >::dst_type_info_, data_conversion::BaseConvertEncoder::error_tracking_enabled_, SQLTypeInfo::get_notnull(), StringDictionary::getOrAddBulk(), data_conversion::BaseConvertEncoder::has_nulls_, data_conversion::BaseConvertEncoder::isNull(), StringDictionary::MAX_STRLEN, data_conversion::StringViewToStringDictEncoder< IdType >::string_dict_, to_string(), and data_conversion::TypedBaseConvertEncoder< DataType_, MetadataType_ >::updateMetadataStats().

33  {
34  auto typed_data = reinterpret_cast<const std::string_view*>(data);
35 
37  << " unimplemented case for this encoder";
38 
39  std::vector<std::string_view> input_buffer(typed_data, typed_data + num_elements);
41  dict_encoding_output_buffer_.resize(num_elements);
42  for (size_t i = 0; i < num_elements; ++i) {
43  if (input_buffer[i].size() > StringDictionary::MAX_STRLEN) {
45  throw std::runtime_error("String length of " +
46  std::to_string(input_buffer[i].size()) +
47  " exceeds allowed maximum string length of " +
49  } else {
50  BaseConvertEncoder::delete_buffer_->push_back(true);
51  input_buffer[i] = {}; // set to NULL/empty string to process
52  }
53  } else if (BaseConvertEncoder::isNull(input_buffer[i])) {
56  throw std::runtime_error("NULL value not allowed in NOT NULL column");
57  }
59  } else {
61  BaseConvertEncoder::delete_buffer_->push_back(true);
62  } else {
63  BaseConvertEncoder::delete_buffer_->push_back(false);
64  }
65  }
66  } else {
68  BaseConvertEncoder::delete_buffer_->push_back(false);
69  }
70  }
71  }
72  string_dict_->getOrAddBulk<IdType, std::string_view>(
73  input_buffer, dict_encoding_output_buffer_.data());
74  for (size_t i = 0; i < num_elements; ++i) {
75  if (!BaseConvertEncoder::isNull(input_buffer[i])) {
78  }
79  }
80 
81  buffer_->append(reinterpret_cast<int8_t*>(dict_encoding_output_buffer_.data()),
82  num_elements * sizeof(IdType));
83  }
void updateMetadataStats(const DataType &typed_value, const bool is_date_in_days=false)
std::string to_string(char const *&&v)
bool isNull(const DataType &typed_value)
std::optional< std::vector< bool > > delete_buffer_
void getOrAddBulk(const std::vector< String > &string_vec, T *encoded_vec)
virtual void append(int8_t *src, const size_t num_bytes, const MemoryLevel src_buffer_type=CPU_LEVEL, const int device_id=-1)=0
#define CHECK(condition)
Definition: Logger.h:291
static constexpr size_t MAX_STRLEN
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:398

+ Here is the call graph for this function:

template<typename IdType >
std::optional<std::vector<bool> >& data_conversion::StringViewToStringDictEncoder< IdType >::getDeleteBuffer ( )
inline

Definition at line 92 of file StringViewToStringDictEncoder.h.

References data_conversion::BaseConvertEncoder::delete_buffer_.

92  {
94  }
std::optional< std::vector< bool > > delete_buffer_
template<typename IdType >
const Chunk_NS::Chunk& data_conversion::StringViewToStringDictEncoder< IdType >::getDstChunk ( ) const
inline
template<typename IdType >
void data_conversion::StringViewToStringDictEncoder< IdType >::initialize ( )
inlineprivate

Definition at line 97 of file StringViewToStringDictEncoder.h.

References data_conversion::StringViewToStringDictEncoder< IdType >::buffer_, ColumnDescriptor::columnType, data_conversion::StringViewToStringDictEncoder< IdType >::dst_chunk_, data_conversion::StringViewToStringDictEncoder< IdType >::dst_type_info_, Chunk_NS::Chunk::getBuffer(), Catalog_Namespace::SysCatalog::getCatalog(), Chunk_NS::Chunk::getColumnDesc(), Catalog_Namespace::SysCatalog::instance(), and data_conversion::StringViewToStringDictEncoder< IdType >::string_dict_.

Referenced by data_conversion::StringViewToStringDictEncoder< IdType >::StringViewToStringDictEncoder().

97  {
98  auto type_info = dst_chunk_.getColumnDesc()->columnType;
100  type_info.getStringDictKey().db_id);
101  string_dict_ = catalog->getMetadataForDict(type_info.getStringDictKey().dict_id, true)
102  ->stringDict.get();
103  dst_type_info_ = type_info;
105  }
const ColumnDescriptor * getColumnDesc() const
Definition: Chunk.h:65
static SysCatalog & instance()
Definition: SysCatalog.h:343
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
AbstractBuffer * getBuffer() const
Definition: Chunk.h:146
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

template<typename IdType >
std::vector<IdType> data_conversion::StringViewToStringDictEncoder< IdType >::dict_encoding_output_buffer_
private

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