OmniSciDB  471d68cefb
 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 90 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 184 of file ParquetImporter.cpp.

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

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

+ 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 154 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().

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

+ Here is the call graph for this function:

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

Implements import_export::ImportBatchResult.

Definition at line 209 of file ParquetImporter.cpp.

References import_status_.

209  {
210  return import_status_;
211 }
import_export::ImportStatus import_status_
std::optional< Fragmenter_Namespace::InsertData > foreign_storage::ParquetImportBatchResult::getInsertData ( ) const
overridevirtual

Implements import_export::ImportBatchResult.

Definition at line 204 of file ParquetImporter.cpp.

References insert_data_.

205  {
206  return insert_data_;
207 }
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 118 of file ParquetImporter.cpp.

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

119  {
120  import_status_.rows_completed = num_rows_completed;
121  import_status_.rows_rejected = num_rows_rejected;
122 }
import_export::ImportStatus import_status_
void foreign_storage::ParquetImportBatchResult::populateInsertData ( const std::map< int, Chunk_NS::Chunk > &  chunks)

Definition at line 124 of file ParquetImporter.cpp.

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

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

Member Data Documentation

int foreign_storage::ParquetImportBatchResult::db_id_
private

Definition at line 113 of file ParquetImporter.cpp.

Referenced by getChunksAndDictionaries(), and populateInsertData().

const ForeignTable* foreign_storage::ParquetImportBatchResult::foreign_table_
private

Definition at line 112 of file ParquetImporter.cpp.

Referenced by populateInsertData().

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

Definition at line 110 of file ParquetImporter.cpp.

Referenced by getChunksAndDictionaries(), and ParquetImportBatchResult().

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

Definition at line 115 of file ParquetImporter.cpp.

Referenced by getImportStatus(), and populateImportStatus().

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

Definition at line 109 of file ParquetImporter.cpp.

Referenced by getInsertData(), and populateInsertData().

const ForeignTableSchema* foreign_storage::ParquetImportBatchResult::schema_
private

Definition at line 114 of file ParquetImporter.cpp.

Referenced by getChunksAndDictionaries(), and ParquetImportBatchResult().


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