OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 dropBufferManager (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 220 of file ForeignStorageInterface.h.

Constructor & Destructor Documentation

ForeignStorageInterface::ForeignStorageInterface ( )
inline

Definition at line 222 of file ForeignStorageInterface.h.

222 {}
ForeignStorageInterface::~ForeignStorageInterface ( )
inline

Definition at line 223 of file ForeignStorageInterface.h.

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

Member Function Documentation

void ForeignStorageInterface::dropBufferManager ( const int  db_id,
const int  table_id 
)

Definition at line 169 of file ForeignStorageInterface.cpp.

References managers_map_, and persistent_storage_interfaces_mutex_.

169  {
170  std::lock_guard<std::mutex> persistent_storage_interfaces_lock(
172  managers_map_.erase(std::make_pair(db_id, table_id));
173 }
std::map< std::pair< int, int >, std::unique_ptr< ForeignStorageBufferMgr > > managers_map_
Data_Namespace::AbstractBufferMgr * ForeignStorageInterface::lookupBufferManager ( const int  db_id,
const int  table_id 
)

Definition at line 149 of file ForeignStorageInterface.cpp.

References CHECK, managers_map_, persistent_storage_interfaces_mutex_, and table_persistent_storage_interface_map_.

Referenced by registerTable().

151  {
152  auto key = std::make_pair(db_id, table_id);
153  if (managers_map_.count(key)) {
154  return managers_map_[key].get();
155  }
156 
157  std::lock_guard<std::mutex> persistent_storage_interfaces_lock(
159  const auto it = table_persistent_storage_interface_map_.find(key);
160  if (it == table_persistent_storage_interface_map_.end()) {
161  return nullptr;
162  }
163  const auto it_ok = managers_map_.emplace(
164  key, std::make_unique<ForeignStorageBufferMgr>(db_id, table_id, it->second));
165  CHECK(it_ok.second);
166  return it_ok.first->second.get();
167 }
std::map< std::pair< int, int >, PersistentForeignStorageInterface * > table_persistent_storage_interface_map_
#define CHECK(condition)
Definition: Logger.h:291
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 190 of file ForeignStorageInterface.cpp.

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

192  {
193  auto type = parseStorageType(td.storageType);
194  std::unique_lock<std::mutex> persistent_storage_interfaces_lock(
196  const auto it = persistent_storage_interfaces_.find(type.first);
197  if (it == persistent_storage_interfaces_.end()) {
198  throw std::runtime_error("storage type " + type.first + " not supported");
199  }
200  auto& p = it->second;
201  persistent_storage_interfaces_lock.unlock();
202  p->prepareTable(db_id, type.second, td, cols);
203 }
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 175 of file ForeignStorageInterface.cpp.

References CHECK, persistent_storage_interfaces_, and persistent_storage_interfaces_mutex_.

176  {
177  std::lock_guard<std::mutex> persistent_storage_interfaces_lock(
179  const auto it_ok = persistent_storage_interfaces_.emplace(
180  persistent_foreign_storage->getType(), std::move(persistent_foreign_storage));
181  CHECK(it_ok.second);
182 }
std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > persistent_storage_interfaces_
#define CHECK(condition)
Definition: Logger.h:291
void ForeignStorageInterface::registerTable ( Catalog_Namespace::Catalog catalog,
const TableDescriptor td,
const std::list< ColumnDescriptor > &  cols 
)

ids are created

Definition at line 205 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.

207  {
208  const int table_id = td.tableId;
209  auto type = parseStorageType(td.storageType);
210 
211  std::unique_lock<std::mutex> persistent_storage_interfaces_lock(
213  const auto it = persistent_storage_interfaces_.find(type.first);
214  if (it == persistent_storage_interfaces_.end()) {
215  throw std::runtime_error("storage type " + type.first + " not supported");
216  }
217 
218  auto db_id = catalog->getCurrentDB().dbId;
219  const auto it_ok = table_persistent_storage_interface_map_.emplace(
220  std::make_pair(db_id, table_id), it->second.get());
221  // this check fails if we create table, drop it and create again
222  // CHECK(it_ok.second);
223  persistent_storage_interfaces_lock.unlock();
224  it_ok.first->second->registerTable(catalog,
225  it_ok.first->first,
226  type.second,
227  td,
228  cols,
229  lookupBufferManager(db_id, table_id));
230 }
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:265
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 252 of file ForeignStorageInterface.h.

Referenced by dropBufferManager(), and 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 251 of file ForeignStorageInterface.h.

Referenced by lookupBufferManager(), and registerTable().


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