OmniSciDB  340b00dbf6
 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 211 of file ForeignStorageInterface.h.

Member Function Documentation

void ForeignStorageInterface::destroy ( )
static

Definition at line 213 of file ForeignStorageInterface.cpp.

References managers_map_, and persistent_storage_interfaces_.

Referenced by startMapdServer().

213  {
215  managers_map_.clear();
216 }
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 136 of file ForeignStorageInterface.cpp.

References CHECK, managers_map_, persistent_storage_interfaces_mutex_, and table_persistent_storage_interface_map_.

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

138  {
139  auto key = std::make_pair(db_id, table_id);
140  if (managers_map_.count(key)) {
141  return managers_map_[key].get();
142  }
143 
144  std::lock_guard<std::mutex> persistent_storage_interfaces_lock(
146  const auto it = table_persistent_storage_interface_map_.find(key);
147  if (it == table_persistent_storage_interface_map_.end()) {
148  return nullptr;
149  }
150  const auto it_ok = managers_map_.emplace(
151  key, std::make_unique<ForeignStorageBufferMgr>(db_id, table_id, it->second));
152  CHECK(it_ok.second);
153  return it_ok.first->second.get();
154 }
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_
#define CHECK(condition)
Definition: Logger.h:197

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

173  {
174  auto type = parseStorageType(td.storageType);
175  std::unique_lock<std::mutex> persistent_storage_interfaces_lock(
177  const auto it = persistent_storage_interfaces_.find(type.first);
178  if (it == persistent_storage_interfaces_.end()) {
179  throw std::runtime_error("storage type " + type.first + " not supported");
180  }
181  auto& p = it->second;
182  persistent_storage_interfaces_lock.unlock();
183  p->prepareTable(db_id, type.second, td, cols);
184 }
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 156 of file ForeignStorageInterface.cpp.

References CHECK, persistent_storage_interfaces_, and persistent_storage_interfaces_mutex_.

Referenced by registerArrowCsvForeignStorage(), and registerArrowForeignStorage().

157  {
158  std::lock_guard<std::mutex> persistent_storage_interfaces_lock(
160  const auto it_ok = persistent_storage_interfaces_.emplace(
161  persistent_foreign_storage->getType(), std::move(persistent_foreign_storage));
162  CHECK(it_ok.second);
163 }
static std::mutex persistent_storage_interfaces_mutex_
#define CHECK(condition)
Definition: Logger.h:197
static std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > persistent_storage_interfaces_

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

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

Referenced by lookupBufferManager(), and registerTable().


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