OmniSciDB  a5dc49c757
 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
 
void removeMutableTableCacheData (const int db_id, const int table_id) const
 
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:291
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 202 of file PersistentStorageMgr.cpp.

References disk_cache_.

Referenced by Catalog_Namespace::anonymous_namespace{Catalog.cpp}::clear_cached_table_data().

202  {
203  return disk_cache_ ? disk_cache_.get() : nullptr;
204 }
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_

+ Here is the caller graph for this function:

const File_Namespace::DiskCacheConfig PersistentStorageMgr::getDiskCacheConfig ( ) const
inline

Definition at line 66 of file PersistentStorageMgr.h.

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

Definition at line 69 of file PersistentStorageMgr.h.

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

Definition at line 198 of file PersistentStorageMgr.cpp.

References foreign_storage_mgr_.

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

198  {
199  return foreign_storage_mgr_.get();
200 }
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 189 of file PersistentStorageMgr.cpp.

References foreign_storage_mgr_, global_file_mgr_, and isForeignStorage().

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

190  {
191  if (isForeignStorage(table_key)) {
192  return foreign_storage_mgr_.get();
193  } else {
194  return global_file_mgr_.get();
195  }
196 }
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 169 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().

169  {
170  CHECK(has_table_prefix(chunk_key));
171  auto db_id = chunk_key[CHUNK_KEY_DB_IDX];
172  auto table_id = chunk_key[CHUNK_KEY_TABLE_IDX];
173  auto catalog = Catalog_Namespace::SysCatalog::instance().getCatalog(db_id);
174 
175  // if catalog doesnt exist at this point we must be in an old migration.
176  // Old migration can not, at this point 5.5.1, be using foreign storage
177  // so this hack is to avoid the crash, when migrating old
178  // catalogs that have not been upgraded over time due to issue
179  // [BE-5728]
180  if (!catalog) {
181  return false;
182  }
183 
184  auto table = catalog->getMetadataForTable(table_id, false);
185  CHECK(table);
186  return table->storageType == StorageType::FOREIGN_TABLE;
187 }
#define CHUNK_KEY_DB_IDX
Definition: types.h:38
static SysCatalog & instance()
Definition: SysCatalog.h:343
#define CHUNK_KEY_TABLE_IDX
Definition: types.h:39
bool has_table_prefix(const ChunkKey &key)
Definition: types.h:48
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
#define CHECK(condition)
Definition: Logger.h:291
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::removeMutableTableCacheData ( const int  db_id,
const int  table_id 
) const

Definition at line 158 of file PersistentStorageMgr.cpp.

References disk_cache_config_, global_file_mgr_, and File_Namespace::DiskCacheConfig::isEnabledForMutableTables().

Referenced by Data_Namespace::DataMgr::removeMutableTableDiskCacheData().

159  {
161  // If the disk cache supports mutable tables then clear the cached data.
162  if (auto cfm =
163  dynamic_cast<File_Namespace::CachingGlobalFileMgr*>(global_file_mgr_.get())) {
164  cfm->removeCachedData(db_id, tb_id);
165  }
166  }
167 }
File_Namespace::DiskCacheConfig disk_cache_config_
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 82 of file PersistentStorageMgr.h.

Referenced by getDiskCache(), and PersistentStorageMgr().

File_Namespace::DiskCacheConfig PersistentStorageMgr::disk_cache_config_
protected

Definition at line 83 of file PersistentStorageMgr.h.

Referenced by PersistentStorageMgr(), and removeMutableTableCacheData().

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

Definition at line 84 of file PersistentStorageMgr.h.

Referenced by PersistentStorageMgr().


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