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

#include <BaseConvertEncoder.h>

+ Inheritance diagram for data_conversion::BaseConvertEncoder:

Public Member Functions

virtual ~BaseConvertEncoder ()
 
 BaseConvertEncoder (const bool error_tracking_enabled)
 
void initializeDeleteBuffer (const size_t size_hint)
 
virtual void finalize (const size_t rows_appended)
 
virtual void encodeAndAppendData (const int8_t *data, const size_t num_elements)=0
 
virtual std::shared_ptr
< ChunkMetadata
getMetadata (const Chunk_NS::Chunk &chunk) const
 

Protected Member Functions

virtual void clear ()
 
template<typename DataType >
bool isNull (const DataType &typed_value)
 

Protected Attributes

std::optional< std::vector
< bool > > 
delete_buffer_
 
const bool error_tracking_enabled_
 
bool has_nulls_
 
size_t num_elements_
 

Detailed Description

Definition at line 32 of file BaseConvertEncoder.h.

Constructor & Destructor Documentation

virtual data_conversion::BaseConvertEncoder::~BaseConvertEncoder ( )
inlinevirtual

Definition at line 34 of file BaseConvertEncoder.h.

34 {};
data_conversion::BaseConvertEncoder::BaseConvertEncoder ( const bool  error_tracking_enabled)
inline

Definition at line 36 of file BaseConvertEncoder.h.

37  : delete_buffer_(std::nullopt)
38  , error_tracking_enabled_(error_tracking_enabled)
39  , has_nulls_(false)
40  , num_elements_(0) {}
std::optional< std::vector< bool > > delete_buffer_

Member Function Documentation

virtual void data_conversion::BaseConvertEncoder::clear ( )
inlineprotectedvirtual

Reimplemented in data_conversion::StringViewToStringDictEncoder< IdType >, and data_conversion::StringViewToScalarEncoder< DataType, MetadataType >.

Definition at line 65 of file BaseConvertEncoder.h.

References delete_buffer_, error_tracking_enabled_, and num_elements_.

Referenced by data_conversion::StringViewToScalarEncoder< DataType, MetadataType >::clear(), and data_conversion::StringViewToStringDictEncoder< IdType >::clear().

65  {
66  num_elements_ = 0;
68  delete_buffer_->clear();
69  }
70  }
std::optional< std::vector< bool > > delete_buffer_

+ Here is the caller graph for this function:

virtual void data_conversion::BaseConvertEncoder::finalize ( const size_t  rows_appended)
inlinevirtual

Definition at line 50 of file BaseConvertEncoder.h.

References num_elements_.

50 { num_elements_ = rows_appended; }
virtual std::shared_ptr<ChunkMetadata> data_conversion::BaseConvertEncoder::getMetadata ( const Chunk_NS::Chunk chunk) const
inlinevirtual

Reimplemented in data_conversion::TypedBaseConvertEncoder< DataType_, MetadataType_ >, data_conversion::TypedBaseConvertEncoder< ScalarEncoderType::DataType, ScalarEncoderType::MetadataType >, data_conversion::TypedBaseConvertEncoder< IdType >, and data_conversion::TypedBaseConvertEncoder< DataType, MetadataType >.

Definition at line 54 of file BaseConvertEncoder.h.

References ColumnDescriptor::columnType, Chunk_NS::Chunk::getBuffer(), Chunk_NS::Chunk::getColumnDesc(), has_nulls_, num_elements_, and Data_Namespace::AbstractBuffer::size().

Referenced by data_conversion::TypedBaseConvertEncoder< DataType, MetadataType >::getMetadata().

54  {
55  auto chunk_metadata = std::make_shared<ChunkMetadata>();
56  auto dst_type_info = chunk.getColumnDesc()->columnType;
57  chunk_metadata->sqlType = dst_type_info;
58  chunk_metadata->chunkStats.has_nulls = has_nulls_;
59  chunk_metadata->numElements = num_elements_;
60  chunk_metadata->numBytes = chunk.getBuffer()->size();
61  return chunk_metadata;
62  }
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:

void data_conversion::BaseConvertEncoder::initializeDeleteBuffer ( const size_t  size_hint)
inline

Definition at line 42 of file BaseConvertEncoder.h.

References delete_buffer_.

42  {
43  if (!delete_buffer_.has_value()) {
44  delete_buffer_ = std::vector<bool>{};
45  }
46  delete_buffer_->clear();
47  delete_buffer_->reserve(size_hint);
48  }
std::optional< std::vector< bool > > delete_buffer_
template<typename DataType >
bool data_conversion::BaseConvertEncoder::isNull ( const DataType &  typed_value)
inlineprotected

Definition at line 73 of file BaseConvertEncoder.h.

Referenced by data_conversion::StringViewToScalarEncoder< DataType, MetadataType >::convertAndUpdateMetadata(), and data_conversion::StringViewToStringDictEncoder< IdType >::encodeAndAppendData().

73  {
74  if constexpr (std::is_arithmetic<DataType>::value) {
75  auto null = foreign_storage::get_null_value<DataType>();
76  if (typed_value == null) {
77  return true;
78  }
79  } else if constexpr (std::is_same<DataType, std::string>::value ||
80  std::is_same<DataType, std::string_view>::value) {
81  if (typed_value.empty()) {
82  return true;
83  }
84  }
85  return false;
86  }

+ Here is the caller graph for this function:

Member Data Documentation

size_t data_conversion::BaseConvertEncoder::num_elements_
protected

Definition at line 92 of file BaseConvertEncoder.h.

Referenced by clear(), finalize(), and getMetadata().


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