OmniSciDB  8a228a1076
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 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 getChunkMetadataVec (ChunkMetadataVector &chunk_metadata) override
 
void getChunkMetadataVecForKeyPrefix (ChunkMetadataVector &chunk_metadata, const ChunkKey &chunk_key_prefix) override
 
bool isBufferOnDevice (const ChunkKey &chunk_key) override
 
std::string printSlabs () override
 
void clearSlabs () 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 ()
 
foreign_storage::ForeignStorageMgrgetForeignStorageMgr () const
 
foreign_storage::ForeignStorageCachegetDiskCache () const
 

Private Member Functions

bool isForeignStorage (const ChunkKey &chunk_key)
 

Private Attributes

std::unique_ptr< File_Namespace::GlobalFileMgrglobal_file_mgr_
 
std::unique_ptr< foreign_storage::ForeignStorageMgrforeign_storage_mgr_
 
std::unique_ptr< foreign_storage::ForeignStorageCachedisk_cache_
 

Detailed Description

Definition at line 24 of file PersistentStorageMgr.h.

Constructor & Destructor Documentation

◆ PersistentStorageMgr()

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

Definition at line 20 of file PersistentStorageMgr.cpp.

References disk_cache_, DiskCacheConfig::entry_limit, foreign_storage_mgr_, DiskCacheConfig::is_enabled, and DiskCacheConfig::path.

23  : AbstractBufferMgr(0)
25  std::make_unique<File_Namespace::GlobalFileMgr>(0,
26  data_dir,
27  num_reader_threads)) {
28  if (disk_cache_config.is_enabled) {
29  disk_cache_ = std::make_unique<foreign_storage::ForeignStorageCache>(
30  disk_cache_config.path, num_reader_threads, disk_cache_config.entry_limit);
32  std::make_unique<foreign_storage::ForeignStorageMgr>(disk_cache_.get());
33  } else {
34  foreign_storage_mgr_ = std::make_unique<foreign_storage::ForeignStorageMgr>();
35  }
36 }
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
std::unique_ptr< foreign_storage::ForeignStorageMgr > foreign_storage_mgr_

Member Function Documentation

◆ alloc()

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

Definition at line 129 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

129  {
130  return global_file_mgr_->alloc(num_bytes);
131 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ checkpoint() [1/2]

void PersistentStorageMgr::checkpoint ( )
override

Definition at line 121 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

121  {
122  global_file_mgr_->checkpoint();
123 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ checkpoint() [2/2]

void PersistentStorageMgr::checkpoint ( const int  db_id,
const int  tb_id 
)
override

Definition at line 125 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

125  {
126  global_file_mgr_->checkpoint(db_id, tb_id);
127 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ clearSlabs()

void PersistentStorageMgr::clearSlabs ( )
override

Definition at line 101 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

101  {
102  global_file_mgr_->clearSlabs();
103 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ createBuffer()

AbstractBuffer * PersistentStorageMgr::createBuffer ( const ChunkKey chunk_key,
const size_t  page_size,
const size_t  initial_size 
)
override

Definition at line 38 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

40  {
41  return global_file_mgr_->createBuffer(chunk_key, page_size, initial_size);
42 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ deleteBuffer()

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

Definition at line 44 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

44  {
45  global_file_mgr_->deleteBuffer(chunk_key, purge);
46 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ deleteBuffersWithPrefix()

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

Definition at line 48 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

49  {
50  global_file_mgr_->deleteBuffersWithPrefix(chunk_key_prefix, purge);
51 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ fetchBuffer()

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

Definition at line 62 of file PersistentStorageMgr.cpp.

References foreign_storage_mgr_, global_file_mgr_, and isForeignStorage().

64  {
65  if (isForeignStorage(chunk_key)) {
66  foreign_storage_mgr_->fetchBuffer(chunk_key, destination_buffer, num_bytes);
67  } else {
68  global_file_mgr_->fetchBuffer(chunk_key, destination_buffer, num_bytes);
69  }
70 }
bool isForeignStorage(const ChunkKey &chunk_key)
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:

◆ free()

void PersistentStorageMgr::free ( AbstractBuffer buffer)
override

Definition at line 133 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

133  {
134  global_file_mgr_->free(buffer);
135 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ getAllocated()

size_t PersistentStorageMgr::getAllocated ( )
override

Definition at line 113 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

113  {
114  return global_file_mgr_->getAllocated();
115 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ getBuffer()

AbstractBuffer * PersistentStorageMgr::getBuffer ( const ChunkKey chunk_key,
const size_t  num_bytes 
)
override

Definition at line 53 of file PersistentStorageMgr.cpp.

References foreign_storage_mgr_, global_file_mgr_, and isForeignStorage().

54  {
55  if (isForeignStorage(chunk_key)) {
56  return foreign_storage_mgr_->getBuffer(chunk_key, num_bytes);
57  } else {
58  return global_file_mgr_->getBuffer(chunk_key, num_bytes);
59  }
60 }
bool isForeignStorage(const ChunkKey &chunk_key)
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:

◆ getChunkMetadataVec()

void PersistentStorageMgr::getChunkMetadataVec ( ChunkMetadataVector chunk_metadata)
override

Definition at line 78 of file PersistentStorageMgr.cpp.

References foreign_storage_mgr_, and global_file_mgr_.

78  {
79  global_file_mgr_->getChunkMetadataVec(chunk_metadata);
80  foreign_storage_mgr_->getChunkMetadataVec(chunk_metadata);
81 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
std::unique_ptr< foreign_storage::ForeignStorageMgr > foreign_storage_mgr_

◆ getChunkMetadataVecForKeyPrefix()

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

Definition at line 83 of file PersistentStorageMgr.cpp.

References foreign_storage_mgr_, global_file_mgr_, and isForeignStorage().

85  {
86  if (isForeignStorage(keyPrefix)) {
87  foreign_storage_mgr_->getChunkMetadataVecForKeyPrefix(chunk_metadata, keyPrefix);
88  } else {
89  global_file_mgr_->getChunkMetadataVecForKeyPrefix(chunk_metadata, keyPrefix);
90  }
91 }
bool isForeignStorage(const ChunkKey &chunk_key)
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:

◆ getDiskCache()

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

Definition at line 176 of file PersistentStorageMgr.cpp.

References disk_cache_.

176  {
177  return disk_cache_ ? disk_cache_.get() : nullptr;
178 }
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_

◆ getForeignStorageMgr()

foreign_storage::ForeignStorageMgr * PersistentStorageMgr::getForeignStorageMgr ( ) const

Definition at line 172 of file PersistentStorageMgr.cpp.

References foreign_storage_mgr_.

172  {
173  return foreign_storage_mgr_.get();
174 }
std::unique_ptr< foreign_storage::ForeignStorageMgr > foreign_storage_mgr_

◆ getGlobalFileMgr()

File_Namespace::GlobalFileMgr * PersistentStorageMgr::getGlobalFileMgr ( )

Definition at line 149 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

149  {
150  return global_file_mgr_.get();
151 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ getInUseSize()

size_t PersistentStorageMgr::getInUseSize ( )
override

Definition at line 109 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

109  {
110  return global_file_mgr_->getInUseSize();
111 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ getMaxSize()

size_t PersistentStorageMgr::getMaxSize ( )
override

Definition at line 105 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

105  {
106  return global_file_mgr_->getMaxSize();
107 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ getMgrType()

MgrType PersistentStorageMgr::getMgrType ( )
override

Definition at line 137 of file PersistentStorageMgr.cpp.

137  {
138  return PERSISTENT_STORAGE_MGR;
139 }

◆ getNumChunks()

size_t PersistentStorageMgr::getNumChunks ( )
override

Definition at line 145 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

145  {
146  return global_file_mgr_->getNumChunks();
147 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ getStringMgrType()

std::string PersistentStorageMgr::getStringMgrType ( )
override

Definition at line 141 of file PersistentStorageMgr.cpp.

141  {
142  return ToString(PERSISTENT_STORAGE_MGR);
143 }

◆ isAllocationCapped()

bool PersistentStorageMgr::isAllocationCapped ( )
override

Definition at line 117 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

117  {
118  return global_file_mgr_->isAllocationCapped();
119 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ isBufferOnDevice()

bool PersistentStorageMgr::isBufferOnDevice ( const ChunkKey chunk_key)
override

Definition at line 93 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

93  {
94  return global_file_mgr_->isBufferOnDevice(chunk_key);
95 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ isForeignStorage()

bool PersistentStorageMgr::isForeignStorage ( const ChunkKey chunk_key)
private

Definition at line 160 of file PersistentStorageMgr.cpp.

References CHECK, StorageType::FOREIGN_TABLE, and Catalog_Namespace::Catalog::get().

Referenced by fetchBuffer(), getBuffer(), getChunkMetadataVecForKeyPrefix(), and removeTableRelatedDS().

160  {
161  auto db_id = chunk_key[0];
162  auto table_id = chunk_key[1];
163 
164  auto catalog = Catalog_Namespace::Catalog::get(db_id);
165  CHECK(catalog);
166 
167  auto table = catalog->getMetadataForTableImpl(table_id, false);
168  CHECK(table);
169  return table->storageType == StorageType::FOREIGN_TABLE;
170 }
static std::shared_ptr< Catalog > get(const std::string &dbName)
Definition: Catalog.cpp:3671
#define CHECK(condition)
Definition: Logger.h:197
static constexpr char const * FOREIGN_TABLE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printSlabs()

std::string PersistentStorageMgr::printSlabs ( )
override

Definition at line 97 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

97  {
98  return global_file_mgr_->printSlabs();
99 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ putBuffer()

AbstractBuffer * PersistentStorageMgr::putBuffer ( const ChunkKey chunk_key,
AbstractBuffer source_buffer,
const size_t  num_bytes 
)
override

Definition at line 72 of file PersistentStorageMgr.cpp.

References global_file_mgr_.

74  {
75  return global_file_mgr_->putBuffer(chunk_key, source_buffer, num_bytes);
76 }
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_

◆ removeTableRelatedDS()

void PersistentStorageMgr::removeTableRelatedDS ( const int  db_id,
const int  table_id 
)
override

Definition at line 153 of file PersistentStorageMgr.cpp.

References foreign_storage_mgr_, global_file_mgr_, and isForeignStorage().

153  {
154  if (isForeignStorage({db_id, table_id})) {
155  foreign_storage_mgr_->removeTableRelatedDS(db_id, table_id);
156  }
157  global_file_mgr_->removeTableRelatedDS(db_id, table_id);
158 }
bool isForeignStorage(const ChunkKey &chunk_key)
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:

Member Data Documentation

◆ disk_cache_

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

Definition at line 70 of file PersistentStorageMgr.h.

Referenced by getDiskCache(), and PersistentStorageMgr().

◆ foreign_storage_mgr_

◆ global_file_mgr_


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