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

#include <ForeignStorageInterface.h>

Static Public Member Functions

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

Static Private Attributes

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

Detailed Description

Definition at line 215 of file ForeignStorageInterface.h.

Member Function Documentation

void ForeignStorageInterface::destroy ( )
static

Definition at line 212 of file ForeignStorageInterface.cpp.

References managers_map_, and persistent_storage_interfaces_.

Referenced by startMapdServer().

212  {
214  managers_map_.clear();
215 }
static std::map< std::pair< int, int >, std::unique_ptr< ForeignStorageBufferMgr > > managers_map_
static std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > persistent_storage_interfaces_

+ Here is the caller graph for this function:

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

Definition at line 135 of file ForeignStorageInterface.cpp.

References CHECK(), managers_map_, persistent_storage_interfaces_mutex_, and table_persistent_storage_interface_map_.

Referenced by File_Namespace::GlobalFileMgr::getFileMgr(), and registerTable().

137  {
138  auto key = std::make_pair(db_id, table_id);
139  if (managers_map_.count(key)) {
140  return managers_map_[key].get();
141  }
142 
143  std::lock_guard<std::mutex> persistent_storage_interfaces_lock(
145  const auto it = table_persistent_storage_interface_map_.find(key);
146  if (it == table_persistent_storage_interface_map_.end()) {
147  return nullptr;
148  }
149  const auto it_ok = managers_map_.emplace(
150  key, std::make_unique<ForeignStorageBufferMgr>(db_id, table_id, it->second));
151  CHECK(it_ok.second);
152  return it_ok.first->second.get();
153 }
CHECK(cgen_state)
static std::map< std::pair< int, int >, std::unique_ptr< ForeignStorageBufferMgr > > managers_map_
static std::mutex persistent_storage_interfaces_mutex_
static std::map< std::pair< int, int >, PersistentForeignStorageInterface * > table_persistent_storage_interface_map_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ForeignStorageInterface::prepareTable ( const int  db_id,
TableDescriptor td,
std::list< ColumnDescriptor > &  cols 
)
static

prepare table options and modify columns

Definition at line 170 of file ForeignStorageInterface.cpp.

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

Referenced by Catalog_Namespace::Catalog::createTable().

172  {
173  auto type = parseStorageType(td.storageType);
174  std::unique_lock<std::mutex> persistent_storage_interfaces_lock(
176  const auto it = persistent_storage_interfaces_.find(type.first);
177  if (it == persistent_storage_interfaces_.end()) {
178  throw std::runtime_error("storage type " + type.first + " not supported");
179  }
180  auto& p = it->second;
181  persistent_storage_interfaces_lock.unlock();
182  p->prepareTable(db_id, type.second, td, cols);
183 }
std::string storageType
static std::mutex persistent_storage_interfaces_mutex_
static std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > persistent_storage_interfaces_
std::pair< std::string, std::string > parseStorageType(const std::string &type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 155 of file ForeignStorageInterface.cpp.

References CHECK(), persistent_storage_interfaces_, and persistent_storage_interfaces_mutex_.

Referenced by registerArrowCsvForeignStorage().

156  {
157  std::lock_guard<std::mutex> persistent_storage_interfaces_lock(
159  const auto it_ok = persistent_storage_interfaces_.emplace(
160  persistent_foreign_storage->getType(), std::move(persistent_foreign_storage));
161  CHECK(it_ok.second);
162 }
CHECK(cgen_state)
static std::mutex persistent_storage_interfaces_mutex_
static std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > persistent_storage_interfaces_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ForeignStorageInterface::registerTable ( Catalog_Namespace::Catalog catalog,
const TableDescriptor td,
const std::list< ColumnDescriptor > &  cols 
)
static

ids are created

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

Referenced by Catalog_Namespace::Catalog::createTable().

187  {
188  const int table_id = td.tableId;
189  auto type = parseStorageType(td.storageType);
190 
191  std::unique_lock<std::mutex> persistent_storage_interfaces_lock(
193  const auto it = persistent_storage_interfaces_.find(type.first);
194  if (it == persistent_storage_interfaces_.end()) {
195  throw std::runtime_error("storage type " + type.first + " not supported");
196  }
197 
198  auto db_id = catalog->getCurrentDB().dbId;
199  const auto it_ok = table_persistent_storage_interface_map_.emplace(
200  std::make_pair(db_id, table_id), it->second.get());
201  // this check fails if we create table, drop it and create again
202  // CHECK(it_ok.second);
203  persistent_storage_interfaces_lock.unlock();
204  it_ok.first->second->registerTable(catalog,
205  it_ok.first->first,
206  type.second,
207  td,
208  cols,
209  lookupBufferManager(db_id, table_id));
210 }
static Data_Namespace::AbstractBufferMgr * lookupBufferManager(const int db_id, const int table_id)
std::string storageType
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:182
static std::mutex persistent_storage_interfaces_mutex_
static std::map< std::pair< int, int >, PersistentForeignStorageInterface * > table_persistent_storage_interface_map_
static std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > persistent_storage_interfaces_
std::pair< std::string, std::string > parseStorageType(const std::string &type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 241 of file ForeignStorageInterface.h.

Referenced by destroy(), and lookupBufferManager().

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

Definition at line 239 of file ForeignStorageInterface.h.

Referenced by lookupBufferManager(), and registerTable().


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