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

#include <StringViewToStringNoneEncoder.h>

+ Inheritance diagram for data_conversion::StringViewToStringNoneEncoder:
+ Collaboration diagram for data_conversion::StringViewToStringNoneEncoder:

Public Member Functions

 StringViewToStringNoneEncoder (const Chunk_NS::Chunk &dst_chunk, const bool error_tracking_enabled)
 
void encodeAndAppendData (const int8_t *data, const size_t num_elements) override
 
StringNoneEncodergetEncoder () const
 
- 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)
 
virtual std::shared_ptr
< ChunkMetadata
getMetadata (const Chunk_NS::Chunk &chunk) const
 

Private Member Functions

void initialize ()
 

Private Attributes

SQLTypeInfo dst_type_info_
 
const Chunk_NS::Chunkdst_chunk_
 
AbstractBufferbuffer_
 

Additional Inherited Members

- Protected Member Functions inherited from data_conversion::BaseConvertEncoder
virtual void clear ()
 
template<typename DataType >
bool isNull (const DataType &typed_value)
 
- 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

Definition at line 23 of file StringViewToStringNoneEncoder.h.

Constructor & Destructor Documentation

data_conversion::StringViewToStringNoneEncoder::StringViewToStringNoneEncoder ( const Chunk_NS::Chunk dst_chunk,
const bool  error_tracking_enabled 
)
inline

Definition at line 25 of file StringViewToStringNoneEncoder.h.

References initialize().

27  : BaseConvertEncoder(error_tracking_enabled), dst_chunk_(dst_chunk) {
28  initialize();
29  }
BaseConvertEncoder(const bool error_tracking_enabled)

+ Here is the call graph for this function:

Member Function Documentation

void data_conversion::StringViewToStringNoneEncoder::encodeAndAppendData ( const int8_t *  data,
const size_t  num_elements 
)
inlineoverridevirtual

Implements data_conversion::BaseConvertEncoder.

Definition at line 31 of file StringViewToStringNoneEncoder.h.

References StringNoneEncoder::appendData(), buffer_, data_conversion::BaseConvertEncoder::delete_buffer_, data_conversion::BaseConvertEncoder::error_tracking_enabled_, getEncoder(), Data_Namespace::AbstractBuffer::getEncoder(), data_conversion::BaseConvertEncoder::has_nulls_, StringDictionary::MAX_STRLEN, and to_string().

31  {
32  auto typed_data = reinterpret_cast<const std::string_view*>(data);
34  // scan for any strings that may be an error
35  bool tracking_individual_strings_required = false;
36  size_t first_error_index = 0;
37  for (size_t i = 0; i < num_elements; ++i) {
38  if (typed_data[i].size() > StringDictionary::MAX_STRLEN) {
39  tracking_individual_strings_required = true;
40  first_error_index = i;
41  break;
42  }
43  }
44 
45  if (!tracking_individual_strings_required) {
46  for (size_t i = 0; i < num_elements; ++i) {
47  delete_buffer_->push_back(false);
48  }
49  StringNoneEncoder* encoder = getEncoder();
50  auto metadata = encoder->appendData(typed_data, 0, num_elements, false);
51  has_nulls_ |= metadata->chunkStats.has_nulls;
52  } else {
53  std::vector<std::string_view> tracked_strings(num_elements);
54  for (size_t i = first_error_index; i < num_elements; ++i) {
55  if (typed_data[i].size() > StringDictionary::MAX_STRLEN) {
56  tracked_strings[i] = {};
57  delete_buffer_->push_back(true);
58  } else {
59  tracked_strings[i] = typed_data[i];
60  delete_buffer_->push_back(false);
61  }
62  auto metadata =
63  getEncoder()->appendData(tracked_strings.data(), 0, num_elements, false);
64  has_nulls_ |= metadata->chunkStats.has_nulls;
65  }
66  }
67  } else {
68  for (size_t i = 0; i < num_elements; ++i) {
69  if (typed_data[i].size() > StringDictionary::MAX_STRLEN) {
70  throw std::runtime_error("String length of " +
71  std::to_string(typed_data[i].size()) +
72  " exceeds allowed maximum string length of " +
74  }
75  }
76  auto metadata = dynamic_cast<StringNoneEncoder*>(buffer_->getEncoder())
77  ->appendData(typed_data, 0, num_elements, false);
78  has_nulls_ |= metadata->chunkStats.has_nulls;
79  }
80  }
std::shared_ptr< ChunkMetadata > appendData(int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &ti, const bool replicating=false, const int64_t offset=-1) override
std::string to_string(char const *&&v)
std::optional< std::vector< bool > > delete_buffer_
static constexpr size_t MAX_STRLEN

+ Here is the call graph for this function:

StringNoneEncoder* data_conversion::StringViewToStringNoneEncoder::getEncoder ( ) const
inline

Definition at line 81 of file StringViewToStringNoneEncoder.h.

References buffer_, CHECK, and Data_Namespace::AbstractBuffer::getEncoder().

Referenced by encodeAndAppendData().

81  {
82  auto encoder = dynamic_cast<StringNoneEncoder*>(buffer_->getEncoder());
83  CHECK(encoder);
84  return encoder;
85  }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void data_conversion::StringViewToStringNoneEncoder::initialize ( )
inlineprivate

Definition at line 88 of file StringViewToStringNoneEncoder.h.

References buffer_, ColumnDescriptor::columnType, dst_chunk_, dst_type_info_, Chunk_NS::Chunk::getBuffer(), and Chunk_NS::Chunk::getColumnDesc().

Referenced by StringViewToStringNoneEncoder().

88  {
89  auto type_info = dst_chunk_.getColumnDesc()->columnType;
90  dst_type_info_ = type_info;
92  }
const ColumnDescriptor * getColumnDesc() const
Definition: Chunk.h:65
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

AbstractBuffer* data_conversion::StringViewToStringNoneEncoder::buffer_
private

Definition at line 96 of file StringViewToStringNoneEncoder.h.

Referenced by encodeAndAppendData(), getEncoder(), and initialize().

const Chunk_NS::Chunk& data_conversion::StringViewToStringNoneEncoder::dst_chunk_
private

Definition at line 95 of file StringViewToStringNoneEncoder.h.

Referenced by initialize().

SQLTypeInfo data_conversion::StringViewToStringNoneEncoder::dst_type_info_
private

Definition at line 94 of file StringViewToStringNoneEncoder.h.

Referenced by initialize().


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