OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::ParquetStringEncoder< V > Class Template Reference

#include <ParquetStringEncoder.h>

+ Inheritance diagram for foreign_storage::ParquetStringEncoder< V >:
+ Collaboration diagram for foreign_storage::ParquetStringEncoder< V >:

Public Member Functions

 ParquetStringEncoder (Data_Namespace::AbstractBuffer *buffer, StringDictionary *string_dictionary, ChunkMetadata *chunk_metadata)
 
void validateAndAppendData (const int16_t *def_levels, const int16_t *rep_levels, const int64_t values_read, const int64_t levels_read, int8_t *values, const SQLTypeInfo &column_type, InvalidRowGroupIndices &invalid_indices) override
 
void appendDataTrackErrors (const int16_t *def_levels, const int16_t *rep_levels, const int64_t values_read, const int64_t levels_read, int8_t *values) override
 
void appendData (const int16_t *def_levels, const int16_t *rep_levels, const int64_t values_read, const int64_t levels_read, int8_t *values) override
 
void encodeAndCopyContiguous (const int8_t *parquet_data_bytes, int8_t *omnisci_data_bytes, const size_t num_elements) override
 
void encodeAndCopy (const int8_t *parquet_data_bytes, int8_t *omnisci_data_bytes) override
 
std::shared_ptr< ChunkMetadatagetRowGroupMetadata (const parquet::RowGroupMetaData *group_metadata, const int parquet_column_index, const SQLTypeInfo &column_type) override
 
- Public Member Functions inherited from foreign_storage::TypedParquetInPlaceEncoder< V, V >
 TypedParquetInPlaceEncoder (Data_Namespace::AbstractBuffer *buffer, const ColumnDescriptor *column_desciptor, const parquet::ColumnDescriptor *parquet_column_descriptor)
 
 TypedParquetInPlaceEncoder (Data_Namespace::AbstractBuffer *buffer, const size_t omnisci_data_type_byte_size, const size_t parquet_data_type_byte_size)
 
void validate (const int8_t *parquet_data, const int64_t j, const SQLTypeInfo &column_type) const override
 
std::string integralTypeToString (const V &element) const
 
bool isIntegralType (const SQLTypeInfo &type) const
 
std::string elementToString (const V &element) const
 
std::string encodedDataToString (const int8_t *bytes) const override
 
void setDetectBufferConverterType ()
 
void validateUsingEncodersColumnType (const int8_t *parquet_data, const int64_t j) const override
 
void reserve (const size_t num_append_elements) override
 
void appendDataTrackErrors (const int16_t *def_levels, const int16_t *rep_levels, const int64_t values_read, const int64_t levels_read, int8_t *values) override
 
void validateAndAppendData (const int16_t *def_levels, const int16_t *rep_levels, const int64_t values_read, const int64_t levels_read, int8_t *values, const SQLTypeInfo &column_type, InvalidRowGroupIndices &invalid_indices) override
 
void eraseInvalidIndicesInBuffer (const InvalidRowGroupIndices &invalid_indices) override
 
void appendData (const int16_t *def_levels, const int16_t *rep_levels, const int64_t values_read, const int64_t levels_read, int8_t *values) override
 
void encodeAndCopyContiguous (const int8_t *parquet_data_bytes, int8_t *omnisci_data_bytes, const size_t num_elements) override
 
void setNull (int8_t *omnisci_data_bytes) override
 
void copy (const int8_t *omnisci_data_bytes_source, int8_t *omnisci_data_bytes_destination) override
 
std::shared_ptr< ChunkMetadatagetRowGroupMetadata (const parquet::RowGroupMetaData *group_metadata, const int parquet_column_index, const SQLTypeInfo &column_type) override
 
- Public Member Functions inherited from foreign_storage::ParquetInPlaceEncoder
 ParquetInPlaceEncoder (Data_Namespace::AbstractBuffer *buffer, const size_t omnisci_data_type_byte_size, const size_t parquet_data_type_byte_size)
 
- Public Member Functions inherited from foreign_storage::ParquetScalarEncoder
 ParquetScalarEncoder (Data_Namespace::AbstractBuffer *buffer)
 
- Public Member Functions inherited from foreign_storage::ParquetEncoder
 ParquetEncoder (Data_Namespace::AbstractBuffer *buffer)
 
virtual ~ParquetEncoder ()=default
 
RejectedRowIndices getRejectedRowIndices () const
 
virtual void disableMetadataStatsValidation ()
 
virtual void initializeErrorTracking (const SQLTypeInfo &column_type)
 

Protected Member Functions

bool encodingIsIdentityForSameTypes () const override
 
- Protected Member Functions inherited from foreign_storage::TypedParquetInPlaceEncoder< V, V >
std::pair< V, V > getUnencodedStats (std::shared_ptr< parquet::Statistics > stats) const
 

Private Member Functions

void updateMetadataStats (int64_t values_read, int8_t *values)
 

Private Attributes

StringDictionarystring_dictionary_
 
ChunkMetadatachunk_metadata_
 
std::vector< int8_t > encode_buffer_
 
min_
 
max_
 
int64_t current_batch_offset_
 
InvalidRowGroupIndicesinvalid_indices_
 

Additional Inherited Members

- Static Protected Member Functions inherited from foreign_storage::ParquetEncoder
static std::shared_ptr
< ChunkMetadata
createMetadata (const SQLTypeInfo &column_type)
 
static void throwNotNullViolation (const std::string &parquet_column_name)
 
static void validateNullCount (const std::string &parquet_column_name, int64_t null_count, const SQLTypeInfo &column_type)
 
- Protected Attributes inherited from foreign_storage::ParquetInPlaceEncoder
const size_t omnisci_data_type_byte_size_
 
const size_t parquet_data_type_byte_size_
 
- Protected Attributes inherited from foreign_storage::ParquetEncoder
Data_Namespace::AbstractBufferbuffer_
 
bool is_error_tracking_enabled_
 
RejectedRowIndices invalid_indices_
 
size_t current_chunk_offset_
 
SQLTypeInfo column_type_
 
bool validate_metadata_stats_
 

Detailed Description

template<typename V>
class foreign_storage::ParquetStringEncoder< V >

Definition at line 29 of file ParquetStringEncoder.h.

Constructor & Destructor Documentation

template<typename V >
foreign_storage::ParquetStringEncoder< V >::ParquetStringEncoder ( Data_Namespace::AbstractBuffer buffer,
StringDictionary string_dictionary,
ChunkMetadata chunk_metadata 
)
inline

Definition at line 31 of file ParquetStringEncoder.h.

34  : TypedParquetInPlaceEncoder<V, V>(buffer, sizeof(V), sizeof(V))
35  , string_dictionary_(string_dictionary)
36  , chunk_metadata_(chunk_metadata)
38  , min_(std::numeric_limits<V>::max())
39  , max_(std::numeric_limits<V>::lowest())
41  , invalid_indices_(nullptr) {}

Member Function Documentation

template<typename V >
void foreign_storage::ParquetStringEncoder< V >::appendData ( const int16_t *  def_levels,
const int16_t *  rep_levels,
const int64_t  values_read,
const int64_t  levels_read,
int8_t *  values 
)
inlineoverridevirtual

Appends Parquet data to the buffer using an in-place algorithm. Any necessary transformation or validation of the data and decoding of nulls is part of appending the data. Each class inheriting from this abstract class must implement the functionality to copy, nullify and encode the data.

Parameters
def_levels- an array containing the Dremel encoding definition levels
rep_levels- an array containing the Dremel encoding repetition levels
values_read- the number of non-null values read
levels_read- the total number of values (non-null & null) that are read
values- values that are read

Note that the Parquet format encodes nulls using Dremel encoding.

Reimplemented from foreign_storage::ParquetInPlaceEncoder.

Definition at line 92 of file ParquetStringEncoder.h.

References foreign_storage::TypedParquetInPlaceEncoder< V, T, NullType >::appendData(), foreign_storage::ParquetStringEncoder< V >::chunk_metadata_, ChunkMetadata::chunkStats, foreign_storage::ParquetStringEncoder< V >::encode_buffer_, foreign_storage::ParquetStringEncoder< V >::encodeAndCopyContiguous(), and ChunkStats::has_nulls.

Referenced by foreign_storage::ParquetStringEncoder< V >::appendDataTrackErrors(), and foreign_storage::ParquetStringEncoder< V >::validateAndAppendData().

96  {
97  encodeAndCopyContiguous(values, encode_buffer_.data(), values_read);
99  def_levels, rep_levels, values_read, levels_read, encode_buffer_.data());
101  chunk_metadata_->chunkStats.has_nulls || (values_read < levels_read);
102  }
bool has_nulls
Definition: ChunkMetadata.h:30
ChunkStats chunkStats
Definition: ChunkMetadata.h:37
void appendData(const int16_t *def_levels, const int16_t *rep_levels, const int64_t values_read, const int64_t levels_read, int8_t *values) override
void encodeAndCopyContiguous(const int8_t *parquet_data_bytes, int8_t *omnisci_data_bytes, const size_t num_elements) override

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename V >
void foreign_storage::ParquetStringEncoder< V >::appendDataTrackErrors ( const int16_t *  def_levels,
const int16_t *  rep_levels,
const int64_t  values_read,
const int64_t  levels_read,
int8_t *  values 
)
inlineoverridevirtual

Implements foreign_storage::ParquetEncoder.

Definition at line 67 of file ParquetStringEncoder.h.

References foreign_storage::ParquetStringEncoder< V >::appendData(), CHECK, CHECK_LT, foreign_storage::ParquetEncoder::column_type_, foreign_storage::ParquetEncoder::current_chunk_offset_, foreign_storage::ParquetEncoder::invalid_indices_, foreign_storage::ParquetEncoder::is_error_tracking_enabled_, and StringDictionary::MAX_STRLEN.

71  {
73  auto parquet_data_ptr = reinterpret_cast<const parquet::ByteArray*>(values);
74  for (int64_t i = 0, j = 0; i < levels_read; ++i) {
75  if (def_levels[i]) {
76  CHECK_LT(j, values_read);
77  auto& byte_array = parquet_data_ptr[j++];
78  if (byte_array.len > StringDictionary::MAX_STRLEN) {
80  i);
81  }
83  .get_notnull()) { // item is null for NOT NULL column
85  i);
86  }
87  }
89  appendData(def_levels, rep_levels, values_read, levels_read, values);
90  }
void appendData(const int16_t *def_levels, const int16_t *rep_levels, const int64_t values_read, const int64_t levels_read, int8_t *values) override
RejectedRowIndices invalid_indices_
#define CHECK_LT(x, y)
Definition: Logger.h:232
#define CHECK(condition)
Definition: Logger.h:222
static constexpr size_t MAX_STRLEN

+ Here is the call graph for this function:

template<typename V >
void foreign_storage::ParquetStringEncoder< V >::encodeAndCopy ( const int8_t *  parquet_data_bytes,
int8_t *  omnisci_data_bytes 
)
inlineoverridevirtual

Implements foreign_storage::ParquetScalarEncoder.

Definition at line 126 of file ParquetStringEncoder.h.

References foreign_storage::TypedParquetInPlaceEncoder< V, T, NullType >::copy().

127  {
128  TypedParquetInPlaceEncoder<V, V>::copy(parquet_data_bytes, omnisci_data_bytes);
129  }
void copy(const int8_t *omnisci_data_bytes_source, int8_t *omnisci_data_bytes_destination) override

+ Here is the call graph for this function:

template<typename V >
void foreign_storage::ParquetStringEncoder< V >::encodeAndCopyContiguous ( const int8_t *  parquet_data_bytes,
int8_t *  omnisci_data_bytes,
const size_t  num_elements 
)
inlineoverridevirtual

Implements foreign_storage::ParquetScalarEncoder.

Definition at line 104 of file ParquetStringEncoder.h.

References CHECK, StringDictionary::getOrAddBulk(), StringDictionary::MAX_STRLEN, foreign_storage::ParquetStringEncoder< V >::string_dictionary_, and foreign_storage::ParquetStringEncoder< V >::updateMetadataStats().

Referenced by foreign_storage::ParquetStringEncoder< V >::appendData().

106  {
108  auto parquet_data_ptr =
109  reinterpret_cast<const parquet::ByteArray*>(parquet_data_bytes);
110  auto omnisci_data_ptr = reinterpret_cast<V*>(omnisci_data_bytes);
111  std::vector<std::string_view> string_views;
112  string_views.reserve(num_elements);
113  for (size_t i = 0; i < num_elements; ++i) {
114  auto& byte_array = parquet_data_ptr[i];
115  if (byte_array.len <= StringDictionary::MAX_STRLEN) {
116  string_views.emplace_back(reinterpret_cast<const char*>(byte_array.ptr),
117  byte_array.len);
118  } else {
119  string_views.emplace_back(nullptr, 0);
120  }
121  }
122  string_dictionary_->getOrAddBulk(string_views, omnisci_data_ptr);
123  updateMetadataStats(num_elements, omnisci_data_bytes);
124  }
void updateMetadataStats(int64_t values_read, int8_t *values)
void getOrAddBulk(const std::vector< String > &string_vec, T *encoded_vec)
#define CHECK(condition)
Definition: Logger.h:222
static constexpr size_t MAX_STRLEN

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename V >
bool foreign_storage::ParquetStringEncoder< V >::encodingIsIdentityForSameTypes ( ) const
inlineoverrideprotectedvirtual

Reimplemented from foreign_storage::TypedParquetInPlaceEncoder< V, V >.

Definition at line 147 of file ParquetStringEncoder.h.

147 { return true; }
template<typename V >
std::shared_ptr<ChunkMetadata> foreign_storage::ParquetStringEncoder< V >::getRowGroupMetadata ( const parquet::RowGroupMetaData *  group_metadata,
const int  parquet_column_index,
const SQLTypeInfo column_type 
)
inlineoverridevirtual

Reimplemented from foreign_storage::ParquetEncoder.

Definition at line 131 of file ParquetStringEncoder.h.

References foreign_storage::ParquetEncoder::getRowGroupMetadata(), and foreign_storage::ParquetInPlaceEncoder::omnisci_data_type_byte_size_.

134  {
135  auto metadata = ParquetEncoder::getRowGroupMetadata(
136  group_metadata, parquet_column_index, column_type);
137  auto column_metadata = group_metadata->ColumnChunk(parquet_column_index);
139  column_metadata->num_values();
140 
141  // Placeholder metadata is defined with has_nulls = false.
142  metadata->chunkStats.has_nulls = false;
143  return metadata;
144  }
virtual std::shared_ptr< ChunkMetadata > getRowGroupMetadata(const parquet::RowGroupMetaData *group_metadata, const int parquet_column_index, const SQLTypeInfo &column_type)

+ Here is the call graph for this function:

template<typename V >
void foreign_storage::ParquetStringEncoder< V >::updateMetadataStats ( int64_t  values_read,
int8_t *  values 
)
inlineprivate

Definition at line 150 of file ParquetStringEncoder.h.

References foreign_storage::ParquetStringEncoder< V >::chunk_metadata_, ChunkMetadata::fillChunkStats(), foreign_storage::ParquetStringEncoder< V >::max_, and foreign_storage::ParquetStringEncoder< V >::min_.

Referenced by foreign_storage::ParquetStringEncoder< V >::encodeAndCopyContiguous().

150  {
151  if (!chunk_metadata_) {
152  return;
153  }
154  V* data_ptr = reinterpret_cast<V*>(values);
155  for (int64_t i = 0; i < values_read; ++i) {
156  min_ = std::min<V>(data_ptr[i], min_);
157  max_ = std::max<V>(data_ptr[i], max_);
158  }
160  }
void fillChunkStats(const T min, const T max, const bool has_nulls)
Definition: ChunkMetadata.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename V >
void foreign_storage::ParquetStringEncoder< V >::validateAndAppendData ( const int16_t *  def_levels,
const int16_t *  rep_levels,
const int64_t  values_read,
const int64_t  levels_read,
int8_t *  values,
const SQLTypeInfo column_type,
InvalidRowGroupIndices invalid_indices 
)
inlineoverridevirtual

Implements foreign_storage::ParquetImportEncoder.

Definition at line 46 of file ParquetStringEncoder.h.

References foreign_storage::ParquetStringEncoder< V >::appendData(), CHECK_LT, foreign_storage::ParquetStringEncoder< V >::current_batch_offset_, and StringDictionary::MAX_STRLEN.

52  {
53  auto parquet_data_ptr = reinterpret_cast<const parquet::ByteArray*>(values);
54  for (int64_t i = 0, j = 0; i < levels_read; ++i) {
55  if (def_levels[i]) {
56  CHECK_LT(j, values_read);
57  auto& byte_array = parquet_data_ptr[j++];
58  if (byte_array.len > StringDictionary::MAX_STRLEN) {
59  invalid_indices.insert(current_batch_offset_ + i);
60  }
61  }
62  }
63  current_batch_offset_ += levels_read;
64  appendData(def_levels, rep_levels, values_read, levels_read, values);
65  }
void appendData(const int16_t *def_levels, const int16_t *rep_levels, const int64_t values_read, const int64_t levels_read, int8_t *values) override
#define CHECK_LT(x, y)
Definition: Logger.h:232
static constexpr size_t MAX_STRLEN

+ Here is the call graph for this function:

Member Data Documentation

template<typename V >
int64_t foreign_storage::ParquetStringEncoder< V >::current_batch_offset_
private
template<typename V >
std::vector<int8_t> foreign_storage::ParquetStringEncoder< V >::encode_buffer_
private
template<typename V >
InvalidRowGroupIndices* foreign_storage::ParquetStringEncoder< V >::invalid_indices_
private

Definition at line 169 of file ParquetStringEncoder.h.

template<typename V >
V foreign_storage::ParquetStringEncoder< V >::max_
private
template<typename V >
V foreign_storage::ParquetStringEncoder< V >::min_
private
template<typename V >
StringDictionary* foreign_storage::ParquetStringEncoder< V >::string_dictionary_
private

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