OmniSciDB  94e8789169
 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 218 of file ForeignStorageInterface.h.

Member Function Documentation

void ForeignStorageInterface::destroy ( )
static

Definition at line 225 of file ForeignStorageInterface.cpp.

References managers_map_, and persistent_storage_interfaces_.

Referenced by startMapdServer().

225  {
227  managers_map_.clear();
228 }
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 148 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().

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 }
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 183 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().

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::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 168 of file ForeignStorageInterface.cpp.

References CHECK, persistent_storage_interfaces_, and persistent_storage_interfaces_mutex_.

Referenced by registerArrowCsvForeignStorage(), and registerArrowForeignStorage().

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 }
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 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.

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

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 }
static Data_Namespace::AbstractBufferMgr * lookupBufferManager(const int db_id, const int table_id)
std::string storageType
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:221
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 244 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 242 of file ForeignStorageInterface.h.

Referenced by lookupBufferManager(), and registerTable().


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