OmniSciDB  8a228a1076
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

◆ destroy()

void ForeignStorageInterface::destroy ( )
static

Definition at line 214 of file ForeignStorageInterface.cpp.

References managers_map_, persistent_storage_interfaces_, persistent_storage_interfaces_mutex_, and table_persistent_storage_interface_map_.

Referenced by startMapdServer().

214  {
216  managers_map_.clear();
217 }
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:

◆ lookupBufferManager()

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

Definition at line 137 of file ForeignStorageInterface.cpp.

References CHECK.

Referenced by File_Namespace::GlobalFileMgr::getFileMgr().

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

◆ prepareTable()

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

prepare table options and modify columns

Definition at line 172 of file ForeignStorageInterface.cpp.

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

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

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

◆ registerPersistentStorageInterface()

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

Definition at line 157 of file ForeignStorageInterface.cpp.

References CHECK.

Referenced by registerArrowCsvForeignStorage().

158  {
159  std::lock_guard<std::mutex> persistent_storage_interfaces_lock(
161  const auto it_ok = persistent_storage_interfaces_.emplace(
162  persistent_foreign_storage->getType(), std::move(persistent_foreign_storage));
163  CHECK(it_ok.second);
164 }
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:

◆ registerTable()

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

ids are created

Definition at line 187 of file ForeignStorageInterface.cpp.

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

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

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

◆ managers_map_

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

◆ persistent_storage_interfaces_

std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > ForeignStorageInterface::persistent_storage_interfaces_
staticprivate

Definition at line 237 of file ForeignStorageInterface.h.

Referenced by destroy().

◆ persistent_storage_interfaces_mutex_

std::mutex ForeignStorageInterface::persistent_storage_interfaces_mutex_
staticprivate

Definition at line 242 of file ForeignStorageInterface.h.

Referenced by destroy().

◆ table_persistent_storage_interface_map_

std::map< std::pair< int, int >, PersistentForeignStorageInterface * > ForeignStorageInterface::table_persistent_storage_interface_map_
staticprivate

Definition at line 239 of file ForeignStorageInterface.h.

Referenced by destroy().


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