OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PersistentStorageMgr Class Reference

#include <PersistentStorageMgr.h>

+ Inheritance diagram for PersistentStorageMgr:
+ Collaboration diagram for PersistentStorageMgr:

Public Member Functions

 PersistentStorageMgr (const std::string &data_dir, const size_t num_reader_threads, const File_Namespace::DiskCacheConfig &disk_cache_config)
 
AbstractBuffercreateBuffer (const ChunkKey &chunk_key, const size_t page_size, const size_t initial_size) override
 
void deleteBuffer (const ChunkKey &chunk_key, const bool purge) override
 
void deleteBuffersWithPrefix (const ChunkKey &chunk_key_prefix, const bool purge) override
 
AbstractBuffergetBuffer (const ChunkKey &chunk_key, const size_t num_bytes) override
 
void fetchBuffer (const ChunkKey &chunk_key, AbstractBuffer *destination_buffer, const size_t num_bytes) override
 
AbstractBufferputBuffer (const ChunkKey &chunk_key, AbstractBuffer *source_buffer, const size_t num_bytes) override
 
void getChunkMetadataVecForKeyPrefix (ChunkMetadataVector &chunk_metadata, const ChunkKey &chunk_key_prefix) override
 
bool isBufferOnDevice (const ChunkKey &chunk_key) override
 
std::string printSlabs () override
 
size_t getMaxSize () override
 
size_t getInUseSize () override
 
size_t getAllocated () override
 
bool isAllocationCapped () override
 
void checkpoint () override
 
void checkpoint (const int db_id, const int tb_id) override
 
AbstractBufferalloc (const size_t num_bytes) override
 
void free (AbstractBuffer *buffer) override
 
MgrType getMgrType () override
 
std::string getStringMgrType () override
 
size_t getNumChunks () override
 
void removeTableRelatedDS (const int db_id, const int table_id) override
 
File_Namespace::GlobalFileMgrgetGlobalFileMgr () const
 
foreign_storage::ForeignStorageMgrgetForeignStorageMgr () const
 
foreign_storage::ForeignStorageCachegetDiskCache () const
 
const
File_Namespace::DiskCacheConfig 
getDiskCacheConfig () const
 
const std::shared_ptr
< ForeignStorageInterface
getForeignStorageInterface () const
 

Protected Member Functions

bool isForeignStorage (const ChunkKey &chunk_key) const
 
AbstractBufferMgrgetStorageMgrForTableKey (const ChunkKey &table_key) const
 
bool isChunkPrefixCacheable (const ChunkKey &chunk_prefix) const
 
int recoverDataWrapperIfCachedAndGetHighestFragId (const ChunkKey &table_key)
 

Protected Attributes

std::unique_ptr
< File_Namespace::GlobalFileMgr
global_file_mgr_
 
std::unique_ptr
< foreign_storage::ForeignStorageMgr
foreign_storage_mgr_
 
std::unique_ptr
< foreign_storage::ForeignStorageCache
disk_cache_
 
File_Namespace::DiskCacheConfig disk_cache_config_
 
std::shared_ptr
< ForeignStorageInterface
fsi_
 

Detailed Description

Definition at line 26 of file PersistentStorageMgr.h.

Constructor & Destructor Documentation

PersistentStorageMgr::PersistentStorageMgr ( const std::string &  data_dir,
const size_t  num_reader_threads,
const File_Namespace::DiskCacheConfig disk_cache_config 
)

Definition at line 24 of file PersistentStorageMgr.cpp.

References CHECK, disk_cache_, disk_cache_config_, foreign_storage_mgr_, fsi_, global_file_mgr_, File_Namespace::DiskCacheConfig::isEnabled(), File_Namespace::DiskCacheConfig::isEnabledForFSI(), File_Namespace::DiskCacheConfig::isEnabledForMutableTables(), registerArrowCsvForeignStorage(), and registerArrowForeignStorage().

28  : AbstractBufferMgr(0), disk_cache_config_(disk_cache_config) {
29  fsi_ = std::make_shared<ForeignStorageInterface>();
32 
33  disk_cache_ =
35  ? std::make_unique<foreign_storage::ForeignStorageCache>(disk_cache_config)
36  : nullptr;
39  global_file_mgr_ = std::make_unique<File_Namespace::CachingGlobalFileMgr>(
40  0, fsi_, data_dir, num_reader_threads, disk_cache_.get());
41  } else {
42  global_file_mgr_ = std::make_unique<File_Namespace::GlobalFileMgr>(
43  0, fsi_, data_dir, num_reader_threads);
44  }
45 
49  std::make_unique<foreign_storage::CachingForeignStorageMgr>(disk_cache_.get());
50  } else {
51  foreign_storage_mgr_ = std::make_unique<foreign_storage::ForeignStorageMgr>();
52  }
53 }
void registerArrowForeignStorage(std::shared_ptr< ForeignStorageInterface > fsi)
void registerArrowCsvForeignStorage(std::shared_ptr< ForeignStorageInterface > fsi)
std::shared_ptr< ForeignStorageInterface > fsi_
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
File_Namespace::DiskCacheConfig disk_cache_config_
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
#define CHECK(condition)
Definition: Logger.h:211
std::unique_ptr< foreign_storage::ForeignStorageMgr > foreign_storage_mgr_

+ Here is the call graph for this function:

Member Function Documentation

AbstractBuffer * PersistentStorageMgr::alloc ( const size_t  num_bytes)
override

Definition at line 130 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

130  {
131  return global_file_mgr_->alloc(num_bytes);
132 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
void PersistentStorageMgr::checkpoint ( )
override

Definition at line 122 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

122  {
123  global_file_mgr_->checkpoint();
124 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
void PersistentStorageMgr::checkpoint ( const int  db_id,
const int  tb_id 
)
override

Definition at line 126 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

126  {
127  global_file_mgr_->checkpoint(db_id, tb_id);
128 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
AbstractBuffer * PersistentStorageMgr::createBuffer ( const ChunkKey chunk_key,
const size_t  page_size,
const size_t  initial_size 
)
override

Definition at line 55 of file PersistentStorageMgr.cpp.

References getStorageMgrForTableKey().

57  {
58  return getStorageMgrForTableKey(chunk_key)->createBuffer(
59  chunk_key, page_size, initial_size);
60 }
AbstractBufferMgr * getStorageMgrForTableKey(const ChunkKey &table_key) const

+ Here is the call graph for this function:

void PersistentStorageMgr::deleteBuffer ( const ChunkKey chunk_key,
const bool  purge 
)
override

Definition at line 62 of file PersistentStorageMgr.cpp.

References getStorageMgrForTableKey().

62  {
63  getStorageMgrForTableKey(chunk_key)->deleteBuffer(chunk_key, purge);
64 }
AbstractBufferMgr * getStorageMgrForTableKey(const ChunkKey &table_key) const

+ Here is the call graph for this function:

void PersistentStorageMgr::deleteBuffersWithPrefix ( const ChunkKey chunk_key_prefix,
const bool  purge 
)
override

Definition at line 66 of file PersistentStorageMgr.cpp.

References getStorageMgrForTableKey().

67  {
68  getStorageMgrForTableKey(chunk_key_prefix)
69  ->deleteBuffersWithPrefix(chunk_key_prefix, purge);
70 }
AbstractBufferMgr * getStorageMgrForTableKey(const ChunkKey &table_key) const

+ Here is the call graph for this function:

void PersistentStorageMgr::fetchBuffer ( const ChunkKey chunk_key,
AbstractBuffer destination_buffer,
const size_t  num_bytes 
)
override

Definition at line 77 of file PersistentStorageMgr.cpp.

References getStorageMgrForTableKey().

79  {
80  getStorageMgrForTableKey(chunk_key)->fetchBuffer(
81  chunk_key, destination_buffer, num_bytes);
82 }
AbstractBufferMgr * getStorageMgrForTableKey(const ChunkKey &table_key) const

+ Here is the call graph for this function:

void PersistentStorageMgr::free ( AbstractBuffer buffer)
override

Definition at line 134 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

134  {
135  global_file_mgr_->free(buffer);
136 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
size_t PersistentStorageMgr::getAllocated ( )
override

Definition at line 114 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

114  {
115  return global_file_mgr_->getAllocated();
116 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
AbstractBuffer * PersistentStorageMgr::getBuffer ( const ChunkKey chunk_key,
const size_t  num_bytes 
)
override

Definition at line 72 of file PersistentStorageMgr.cpp.

References getStorageMgrForTableKey().

73  {
74  return getStorageMgrForTableKey(chunk_key)->getBuffer(chunk_key, num_bytes);
75 }
AbstractBufferMgr * getStorageMgrForTableKey(const ChunkKey &table_key) const

+ Here is the call graph for this function:

void PersistentStorageMgr::getChunkMetadataVecForKeyPrefix ( ChunkMetadataVector chunk_metadata,
const ChunkKey chunk_key_prefix 
)
override

Definition at line 91 of file PersistentStorageMgr.cpp.

References getStorageMgrForTableKey().

93  {
94  getStorageMgrForTableKey(key_prefix)
95  ->getChunkMetadataVecForKeyPrefix(chunk_metadata, key_prefix);
96 }
AbstractBufferMgr * getStorageMgrForTableKey(const ChunkKey &table_key) const

+ Here is the call graph for this function:

foreign_storage::ForeignStorageCache * PersistentStorageMgr::getDiskCache ( ) const

Definition at line 191 of file PersistentStorageMgr.cpp.

References disk_cache_.

191  {
192  return disk_cache_ ? disk_cache_.get() : nullptr;
193 }
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
const File_Namespace::DiskCacheConfig PersistentStorageMgr::getDiskCacheConfig ( ) const
inline

Definition at line 65 of file PersistentStorageMgr.h.

65  {
66  return disk_cache_config_;
67  }
File_Namespace::DiskCacheConfig disk_cache_config_
const std::shared_ptr<ForeignStorageInterface> PersistentStorageMgr::getForeignStorageInterface ( ) const
inline

Definition at line 68 of file PersistentStorageMgr.h.

69  {
70  return fsi_;
71  }
std::shared_ptr< ForeignStorageInterface > fsi_
foreign_storage::ForeignStorageMgr * PersistentStorageMgr::getForeignStorageMgr ( ) const

Definition at line 187 of file PersistentStorageMgr.cpp.

References foreign_storage_mgr_.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::set_parallelism_hints().

187  {
188  return foreign_storage_mgr_.get();
189 }
std::unique_ptr< foreign_storage::ForeignStorageMgr > foreign_storage_mgr_

+ Here is the caller graph for this function:

File_Namespace::GlobalFileMgr * PersistentStorageMgr::getGlobalFileMgr ( ) const

Definition at line 150 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

150  {
151  return global_file_mgr_.get();
152 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
size_t PersistentStorageMgr::getInUseSize ( )
override

Definition at line 110 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

110  {
111  return global_file_mgr_->getInUseSize();
112 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
size_t PersistentStorageMgr::getMaxSize ( )
override

Definition at line 106 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

106  {
107  return global_file_mgr_->getMaxSize();
108 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
MgrType PersistentStorageMgr::getMgrType ( )
override

Definition at line 138 of file PersistentStorageMgr.cpp.

138  {
139  return PERSISTENT_STORAGE_MGR;
140 }
size_t PersistentStorageMgr::getNumChunks ( )
override

Definition at line 146 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

146  {
147  return global_file_mgr_->getNumChunks();
148 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
AbstractBufferMgr * PersistentStorageMgr::getStorageMgrForTableKey ( const ChunkKey table_key) const
protected

Definition at line 178 of file PersistentStorageMgr.cpp.

References foreign_storage_mgr_, global_file_mgr_, and isForeignStorage().

Referenced by createBuffer(), deleteBuffer(), deleteBuffersWithPrefix(), fetchBuffer(), getBuffer(), getChunkMetadataVecForKeyPrefix(), putBuffer(), and removeTableRelatedDS().

179  {
180  if (isForeignStorage(table_key)) {
181  return foreign_storage_mgr_.get();
182  } else {
183  return global_file_mgr_.get();
184  }
185 }
bool isForeignStorage(const ChunkKey &chunk_key) const
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
std::unique_ptr< foreign_storage::ForeignStorageMgr > foreign_storage_mgr_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string PersistentStorageMgr::getStringMgrType ( )
override

Definition at line 142 of file PersistentStorageMgr.cpp.

142  {
143  return ToString(PERSISTENT_STORAGE_MGR);
144 }
bool PersistentStorageMgr::isAllocationCapped ( )
override

Definition at line 118 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

118  {
119  return global_file_mgr_->isAllocationCapped();
120 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
bool PersistentStorageMgr::isBufferOnDevice ( const ChunkKey chunk_key)
override

Definition at line 98 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

98  {
99  return global_file_mgr_->isBufferOnDevice(chunk_key);
100 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
bool PersistentStorageMgr::isChunkPrefixCacheable ( const ChunkKey chunk_prefix) const
protected
bool PersistentStorageMgr::isForeignStorage ( const ChunkKey chunk_key) const
protected

Definition at line 158 of file PersistentStorageMgr.cpp.

References CHECK, CHUNK_KEY_DB_IDX, CHUNK_KEY_TABLE_IDX, StorageType::FOREIGN_TABLE, Catalog_Namespace::SysCatalog::getCatalog(), has_table_prefix(), and Catalog_Namespace::SysCatalog::instance().

Referenced by getStorageMgrForTableKey().

158  {
159  CHECK(has_table_prefix(chunk_key));
160  auto db_id = chunk_key[CHUNK_KEY_DB_IDX];
161  auto table_id = chunk_key[CHUNK_KEY_TABLE_IDX];
162  auto catalog = Catalog_Namespace::SysCatalog::instance().getCatalog(db_id);
163 
164  // if catalog doesnt exist at this point we must be in an old migration.
165  // Old migration can not, at this point 5.5.1, be using foreign storage
166  // so this hack is to avoid the crash, when migrating old
167  // catalogs that have not been upgraded over time due to issue
168  // [BE-5728]
169  if (!catalog) {
170  return false;
171  }
172 
173  auto table = catalog->getMetadataForTable(table_id, false);
174  CHECK(table);
175  return table->storageType == StorageType::FOREIGN_TABLE;
176 }
#define CHUNK_KEY_DB_IDX
Definition: types.h:39
static SysCatalog & instance()
Definition: SysCatalog.h:326
#define CHUNK_KEY_TABLE_IDX
Definition: types.h:40
bool has_table_prefix(const ChunkKey &key)
Definition: types.h:49
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
#define CHECK(condition)
Definition: Logger.h:211
static constexpr char const * FOREIGN_TABLE

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string PersistentStorageMgr::printSlabs ( )
override

Definition at line 102 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

102  {
103  return global_file_mgr_->printSlabs();
104 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
AbstractBuffer * PersistentStorageMgr::putBuffer ( const ChunkKey chunk_key,
AbstractBuffer source_buffer,
const size_t  num_bytes 
)
override

Definition at line 84 of file PersistentStorageMgr.cpp.

References getStorageMgrForTableKey().

86  {
87  return getStorageMgrForTableKey(chunk_key)->putBuffer(
88  chunk_key, source_buffer, num_bytes);
89 }
AbstractBufferMgr * getStorageMgrForTableKey(const ChunkKey &table_key) const

+ Here is the call graph for this function:

int PersistentStorageMgr::recoverDataWrapperIfCachedAndGetHighestFragId ( const ChunkKey table_key)
protected
void PersistentStorageMgr::removeTableRelatedDS ( const int  db_id,
const int  table_id 
)
override

Definition at line 154 of file PersistentStorageMgr.cpp.

References getStorageMgrForTableKey().

154  {
155  getStorageMgrForTableKey({db_id, table_id})->removeTableRelatedDS(db_id, table_id);
156 }
void removeTableRelatedDS(const int db_id, const int table_id) override
AbstractBufferMgr * getStorageMgrForTableKey(const ChunkKey &table_key) const

+ Here is the call graph for this function:

Member Data Documentation

std::unique_ptr<foreign_storage::ForeignStorageCache> PersistentStorageMgr::disk_cache_
protected

Definition at line 81 of file PersistentStorageMgr.h.

Referenced by getDiskCache(), and PersistentStorageMgr().

File_Namespace::DiskCacheConfig PersistentStorageMgr::disk_cache_config_
protected

Definition at line 82 of file PersistentStorageMgr.h.

Referenced by PersistentStorageMgr().

std::unique_ptr<foreign_storage::ForeignStorageMgr> PersistentStorageMgr::foreign_storage_mgr_
protected
std::shared_ptr<ForeignStorageInterface> PersistentStorageMgr::fsi_
protected

Definition at line 83 of file PersistentStorageMgr.h.

Referenced by PersistentStorageMgr().


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