OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ForeignStorageInterface Class Reference

#include <ForeignStorageInterface.h>

Public Member Functions

 ForeignStorageInterface ()
 
 ~ForeignStorageInterface ()
 
 ForeignStorageInterface (const ForeignStorageInterface &other)=delete
 
 ForeignStorageInterface (ForeignStorageInterface &&other)=delete
 
ForeignStorageInterfaceoperator= (const ForeignStorageInterface &other)=delete
 
ForeignStorageInterfaceoperator= (ForeignStorageInterface &&other)=delete
 
Data_Namespace::AbstractBufferMgr * lookupBufferManager (const int db_id, const int table_id)
 
void registerPersistentStorageInterface (std::unique_ptr< PersistentForeignStorageInterface > persistent_foreign_storage)
 
void prepareTable (const int db_id, TableDescriptor &td, std::list< ColumnDescriptor > &cols)
 prepare table options and modify columns More...
 
void registerTable (Catalog_Namespace::Catalog *catalog, const TableDescriptor &td, const std::list< ColumnDescriptor > &cols)
 ids are created More...
 

Private Attributes

std::unordered_map
< std::string, std::unique_ptr
< PersistentForeignStorageInterface > > 
persistent_storage_interfaces_
 
std::map< std::pair< int, int >
, PersistentForeignStorageInterface * > 
table_persistent_storage_interface_map_
 
std::map< std::pair< int, int >
, std::unique_ptr
< ForeignStorageBufferMgr > > 
managers_map_
 
std::mutex persistent_storage_interfaces_mutex_
 

Detailed Description

Definition at line 219 of file ForeignStorageInterface.h.

Constructor & Destructor Documentation

ForeignStorageInterface::ForeignStorageInterface ( )
inline

Definition at line 221 of file ForeignStorageInterface.h.

221 {}
ForeignStorageInterface::~ForeignStorageInterface ( )
inline

Definition at line 222 of file ForeignStorageInterface.h.

222 {}
ForeignStorageInterface::ForeignStorageInterface ( const ForeignStorageInterface other)
delete
ForeignStorageInterface::ForeignStorageInterface ( ForeignStorageInterface &&  other)
delete

Member Function Documentation

Data_Namespace::AbstractBufferMgr * ForeignStorageInterface::lookupBufferManager ( const int  db_id,
const int  table_id 
)

Definition at line 148 of file ForeignStorageInterface.cpp.

References CHECK, managers_map_, persistent_storage_interfaces_mutex_, and table_persistent_storage_interface_map_.

Referenced by registerTable().

150  {
151  auto key = std::make_pair(db_id, table_id);
152  if (managers_map_.count(key)) {
153  return managers_map_[key].get();
154  }
155 
156  std::lock_guard<std::mutex> persistent_storage_interfaces_lock(
158  const auto it = table_persistent_storage_interface_map_.find(key);
159  if (it == table_persistent_storage_interface_map_.end()) {
160  return nullptr;
161  }
162  const auto it_ok = managers_map_.emplace(
163  key, std::make_unique<ForeignStorageBufferMgr>(db_id, table_id, it->second));
164  CHECK(it_ok.second);
165  return it_ok.first->second.get();
166 }
std::map< std::pair< int, int >, PersistentForeignStorageInterface * > table_persistent_storage_interface_map_
#define CHECK(condition)
Definition: Logger.h:206
std::map< std::pair< int, int >, std::unique_ptr< ForeignStorageBufferMgr > > managers_map_

+ Here is the caller graph for this function:

ForeignStorageInterface& ForeignStorageInterface::operator= ( const ForeignStorageInterface other)
delete
ForeignStorageInterface& ForeignStorageInterface::operator= ( ForeignStorageInterface &&  other)
delete
void ForeignStorageInterface::prepareTable ( const int  db_id,
TableDescriptor td,
std::list< ColumnDescriptor > &  cols 
)

prepare table options and modify columns

Definition at line 183 of file ForeignStorageInterface.cpp.

References parseStorageType(), persistent_storage_interfaces_, persistent_storage_interfaces_mutex_, TableDescriptor::storageType, and run_benchmark_import::type.

185  {
186  auto type = parseStorageType(td.storageType);
187  std::unique_lock<std::mutex> persistent_storage_interfaces_lock(
189  const auto it = persistent_storage_interfaces_.find(type.first);
190  if (it == persistent_storage_interfaces_.end()) {
191  throw std::runtime_error("storage type " + type.first + " not supported");
192  }
193  auto& p = it->second;
194  persistent_storage_interfaces_lock.unlock();
195  p->prepareTable(db_id, type.second, td, cols);
196 }
std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > persistent_storage_interfaces_
std::string storageType
std::pair< std::string, std::string > parseStorageType(const std::string &type)

+ Here is the call graph for this function:

void ForeignStorageInterface::registerPersistentStorageInterface ( std::unique_ptr< PersistentForeignStorageInterface persistent_foreign_storage)

Definition at line 168 of file ForeignStorageInterface.cpp.

References CHECK, persistent_storage_interfaces_, and persistent_storage_interfaces_mutex_.

169  {
170  std::lock_guard<std::mutex> persistent_storage_interfaces_lock(
172  const auto it_ok = persistent_storage_interfaces_.emplace(
173  persistent_foreign_storage->getType(), std::move(persistent_foreign_storage));
174  CHECK(it_ok.second);
175 }
std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > persistent_storage_interfaces_
#define CHECK(condition)
Definition: Logger.h:206
void ForeignStorageInterface::registerTable ( Catalog_Namespace::Catalog catalog,
const TableDescriptor td,
const std::list< ColumnDescriptor > &  cols 
)

ids are created

Definition at line 198 of file ForeignStorageInterface.cpp.

References Catalog_Namespace::DBMetadata::dbId, Catalog_Namespace::Catalog::getCurrentDB(), lookupBufferManager(), parseStorageType(), persistent_storage_interfaces_, persistent_storage_interfaces_mutex_, TableDescriptor::storageType, table_persistent_storage_interface_map_, TableDescriptor::tableId, and run_benchmark_import::type.

200  {
201  const int table_id = td.tableId;
202  auto type = parseStorageType(td.storageType);
203 
204  std::unique_lock<std::mutex> persistent_storage_interfaces_lock(
206  const auto it = persistent_storage_interfaces_.find(type.first);
207  if (it == persistent_storage_interfaces_.end()) {
208  throw std::runtime_error("storage type " + type.first + " not supported");
209  }
210 
211  auto db_id = catalog->getCurrentDB().dbId;
212  const auto it_ok = table_persistent_storage_interface_map_.emplace(
213  std::make_pair(db_id, table_id), it->second.get());
214  // this check fails if we create table, drop it and create again
215  // CHECK(it_ok.second);
216  persistent_storage_interfaces_lock.unlock();
217  it_ok.first->second->registerTable(catalog,
218  it_ok.first->first,
219  type.second,
220  td,
221  cols,
222  lookupBufferManager(db_id, table_id));
223 }
std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > persistent_storage_interfaces_
Data_Namespace::AbstractBufferMgr * lookupBufferManager(const int db_id, const int table_id)
std::string storageType
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:222
std::map< std::pair< int, int >, PersistentForeignStorageInterface * > table_persistent_storage_interface_map_
std::pair< std::string, std::string > parseStorageType(const std::string &type)

+ Here is the call graph for this function:

Member Data Documentation

std::map<std::pair<int, int>, std::unique_ptr<ForeignStorageBufferMgr> > ForeignStorageInterface::managers_map_
private

Definition at line 250 of file ForeignStorageInterface.h.

Referenced by lookupBufferManager().

std::unordered_map<std::string, std::unique_ptr<PersistentForeignStorageInterface> > ForeignStorageInterface::persistent_storage_interfaces_
private
std::mutex ForeignStorageInterface::persistent_storage_interfaces_mutex_
private
std::map<std::pair<int, int>, PersistentForeignStorageInterface*> ForeignStorageInterface::table_persistent_storage_interface_map_
private

Definition at line 249 of file ForeignStorageInterface.h.

Referenced by lookupBufferManager(), and registerTable().


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