OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::ParquetImportBatchResult Class Reference
+ Inheritance diagram for foreign_storage::ParquetImportBatchResult:
+ Collaboration diagram for foreign_storage::ParquetImportBatchResult:

Public Member Functions

 ParquetImportBatchResult ()=default
 
 ParquetImportBatchResult (const ForeignTable *foreign_table, const int db_id, const ForeignTableSchema *schema)
 
 ParquetImportBatchResult (ParquetImportBatchResult &&other)=default
 
std::optional
< Fragmenter_Namespace::InsertData
getInsertData () const override
 
import_export::ImportStatus getImportStatus () const override
 
std::pair< std::map< int,
Chunk_NS::Chunk >, std::map
< int, StringDictionary * > > 
getChunksAndDictionaries () const
 
void populateInsertData (const std::map< int, Chunk_NS::Chunk > &chunks)
 
void populateImportStatus (const size_t num_rows_completed, const size_t num_rows_rejected)
 
- Public Member Functions inherited from import_export::ImportBatchResult
virtual ~ImportBatchResult ()=default
 

Private Attributes

std::optional
< Fragmenter_Namespace::InsertData
insert_data_
 
std::map< int, std::unique_ptr
< AbstractBuffer > > 
import_buffers_
 
const ForeignTableforeign_table_
 
int db_id_
 
const ForeignTableSchemaschema_
 
import_export::ImportStatus import_status_
 

Detailed Description

Definition at line 95 of file ParquetImporter.cpp.

Constructor & Destructor Documentation

foreign_storage::ParquetImportBatchResult::ParquetImportBatchResult ( )
default
foreign_storage::ParquetImportBatchResult::ParquetImportBatchResult ( const ForeignTable foreign_table,
const int  db_id,
const ForeignTableSchema schema 
)

Definition at line 189 of file ParquetImporter.cpp.

References foreign_storage::ForeignTableSchema::getLogicalAndPhysicalColumns(), import_buffers_, and schema_.

192  : foreign_table_(foreign_table), db_id_(db_id), schema_(schema) {
193  for (const auto column_descriptor : schema_->getLogicalAndPhysicalColumns()) {
194  if (column_descriptor->columnType.is_array()) {
195  import_buffers_[column_descriptor->columnId] =
196  std::make_unique<TypedParquetStorageBuffer<ArrayDatum>>();
197  } else if ((column_descriptor->columnType.is_string() &&
198  !column_descriptor->columnType.is_dict_encoded_string()) ||
199  column_descriptor->columnType.is_geometry()) {
200  import_buffers_[column_descriptor->columnId] =
201  std::make_unique<TypedParquetStorageBuffer<std::string>>();
202  } else {
203  import_buffers_[column_descriptor->columnId] =
204  std::make_unique<ForeignStorageBuffer>();
205  }
206  }
207 }
const std::list< const ColumnDescriptor * > & getLogicalAndPhysicalColumns() const
std::map< int, std::unique_ptr< AbstractBuffer > > import_buffers_

+ Here is the call graph for this function:

foreign_storage::ParquetImportBatchResult::ParquetImportBatchResult ( ParquetImportBatchResult &&  other)
default

Member Function Documentation

std::pair< std::map< int, Chunk_NS::Chunk >, std::map< int, StringDictionary * > > foreign_storage::ParquetImportBatchResult::getChunksAndDictionaries ( ) const

Definition at line 159 of file ParquetImporter.cpp.

References CHECK, db_id_, Catalog_Namespace::SysCatalog::getCatalog(), foreign_storage::ForeignTableSchema::getLogicalAndPhysicalColumns(), import_buffers_, Catalog_Namespace::SysCatalog::instance(), schema_, and Chunk_NS::Chunk::setBuffer().

159  {
160  std::map<int, Chunk_NS::Chunk> chunks;
161  std::map<int, StringDictionary*> string_dictionaries;
163 
164  for (const auto column_descriptor : schema_->getLogicalAndPhysicalColumns()) {
165  const bool is_dictionary_encoded_string_column =
166  column_descriptor->columnType.is_dict_encoded_string() ||
167  (column_descriptor->columnType.is_array() &&
168  column_descriptor->columnType.get_elem_type().is_dict_encoded_string());
169 
170  if (is_dictionary_encoded_string_column) {
171  auto dict_descriptor = catalog->getMetadataForDict(
172  column_descriptor->columnType.get_comp_param(), true);
173  CHECK(dict_descriptor);
174  auto string_dictionary = dict_descriptor->stringDict.get();
175  string_dictionaries[column_descriptor->columnId] = string_dictionary;
176  }
177 
178  Chunk_NS::Chunk chunk{column_descriptor};
179  chunk.setBuffer(import_buffers_.at(column_descriptor->columnId).get());
180  if (column_descriptor->columnType.is_varlen_indeed()) {
181  chunk.setIndexBuffer(nullptr); // index buffers are unused
182  }
183  chunk.initEncoder();
184  chunks[column_descriptor->columnId] = chunk;
185  }
186  return {chunks, string_dictionaries};
187 }
void setBuffer(AbstractBuffer *b)
Definition: Chunk.h:150
static SysCatalog & instance()
Definition: SysCatalog.h:343
const std::list< const ColumnDescriptor * > & getLogicalAndPhysicalColumns() const
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
std::map< int, std::unique_ptr< AbstractBuffer > > import_buffers_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

import_export::ImportStatus foreign_storage::ParquetImportBatchResult::getImportStatus ( ) const
overridevirtual

Implements import_export::ImportBatchResult.

Definition at line 214 of file ParquetImporter.cpp.

References import_status_.

214  {
215  return import_status_;
216 }
import_export::ImportStatus import_status_
std::optional< Fragmenter_Namespace::InsertData > foreign_storage::ParquetImportBatchResult::getInsertData ( ) const
overridevirtual

Implements import_export::ImportBatchResult.

Definition at line 209 of file ParquetImporter.cpp.

References insert_data_.

210  {
211  return insert_data_;
212 }
std::optional< Fragmenter_Namespace::InsertData > insert_data_
void foreign_storage::ParquetImportBatchResult::populateImportStatus ( const size_t  num_rows_completed,
const size_t  num_rows_rejected 
)

Definition at line 123 of file ParquetImporter.cpp.

References import_status_, import_export::ImportStatus::rows_completed, and import_export::ImportStatus::rows_rejected.

124  {
125  import_status_.rows_completed = num_rows_completed;
126  import_status_.rows_rejected = num_rows_rejected;
127 }
import_export::ImportStatus import_status_
void foreign_storage::ParquetImportBatchResult::populateInsertData ( const std::map< int, Chunk_NS::Chunk > &  chunks)

Definition at line 129 of file ParquetImporter.cpp.

References DataBlockPtr::arraysPtr, CHECK, db_id_, foreign_table_, insert_data_, DataBlockPtr::numbersPtr, DataBlockPtr::stringsPtr, and TableDescriptor::tableId.

130  {
132  size_t num_rows = chunks.begin()->second.getBuffer()->getEncoder()->getNumElems();
133  for (const auto& [column_id, chunk] : chunks) {
134  auto column_descriptor = chunk.getColumnDesc();
135  CHECK(chunk.getBuffer()->getEncoder()->getNumElems() == num_rows);
136  insert_data_->columnIds.emplace_back(column_id);
137  auto buffer = chunk.getBuffer();
138  DataBlockPtr block_ptr;
139  if (column_descriptor->columnType.is_array()) {
140  auto array_buffer = dynamic_cast<TypedParquetStorageBuffer<ArrayDatum>*>(buffer);
141  block_ptr.arraysPtr = array_buffer->getBufferPtr();
142  } else if ((column_descriptor->columnType.is_string() &&
143  !column_descriptor->columnType.is_dict_encoded_string()) ||
144  column_descriptor->columnType.is_geometry()) {
145  auto string_buffer = dynamic_cast<TypedParquetStorageBuffer<std::string>*>(buffer);
146  block_ptr.stringsPtr = string_buffer->getBufferPtr();
147  } else {
148  block_ptr.numbersPtr = buffer->getMemoryPtr();
149  }
150  insert_data_->data.emplace_back(block_ptr);
151  }
152  insert_data_->databaseId = db_id_;
153  insert_data_->tableId = foreign_table_->tableId;
154  insert_data_->is_default.assign(insert_data_->columnIds.size(), false);
155  insert_data_->numRows = num_rows;
156 }
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:234
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:235
std::optional< Fragmenter_Namespace::InsertData > insert_data_
#define CHECK(condition)
Definition: Logger.h:291
The data to be inserted using the fragment manager.
Definition: Fragmenter.h:68
int8_t * numbersPtr
Definition: sqltypes.h:233

Member Data Documentation

int foreign_storage::ParquetImportBatchResult::db_id_
private

Definition at line 118 of file ParquetImporter.cpp.

Referenced by getChunksAndDictionaries(), and populateInsertData().

const ForeignTable* foreign_storage::ParquetImportBatchResult::foreign_table_
private

Definition at line 117 of file ParquetImporter.cpp.

Referenced by populateInsertData().

std::map<int, std::unique_ptr<AbstractBuffer> > foreign_storage::ParquetImportBatchResult::import_buffers_
private

Definition at line 115 of file ParquetImporter.cpp.

Referenced by getChunksAndDictionaries(), and ParquetImportBatchResult().

import_export::ImportStatus foreign_storage::ParquetImportBatchResult::import_status_
private

Definition at line 120 of file ParquetImporter.cpp.

Referenced by getImportStatus(), and populateImportStatus().

std::optional<Fragmenter_Namespace::InsertData> foreign_storage::ParquetImportBatchResult::insert_data_
private

Definition at line 114 of file ParquetImporter.cpp.

Referenced by getInsertData(), and populateInsertData().

const ForeignTableSchema* foreign_storage::ParquetImportBatchResult::schema_
private

Definition at line 119 of file ParquetImporter.cpp.

Referenced by getChunksAndDictionaries(), and ParquetImportBatchResult().


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