OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MutableCachePersistentStorageMgr Class Reference

#include <MutableCachePersistentStorageMgr.h>

+ Inheritance diagram for MutableCachePersistentStorageMgr:
+ Collaboration diagram for MutableCachePersistentStorageMgr:

Public Member Functions

 MutableCachePersistentStorageMgr (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
 
AbstractBufferputBuffer (const ChunkKey &chunk_key, AbstractBuffer *source_buffer, const size_t num_bytes) override
 
void checkpoint () override
 
void checkpoint (const int db_id, const int tb_id) override
 
void removeTableRelatedDS (const int db_id, const int table_id) override
 
- Public Member Functions inherited from PersistentStorageMgr
 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 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 () const
 
foreign_storage::ForeignStorageMgrgetForeignStorageMgr () const
 
foreign_storage::ForeignStorageCachegetDiskCache () const
 
const DiskCacheConfig getDiskCacheConfig () const
 

Private Attributes

std::map< const ChunkKey,
AbstractBuffer * > 
cached_buffer_map_
 

Additional Inherited Members

- Static Public Member Functions inherited from PersistentStorageMgr
static PersistentStorageMgrcreatePersistentStorageMgr (const std::string &data_dir, const size_t num_reader_threads, const DiskCacheConfig &disk_cache_config)
 
- Protected Member Functions inherited from PersistentStorageMgr
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 inherited from PersistentStorageMgr
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_
 
DiskCacheConfig disk_cache_config_
 

Detailed Description

Definition at line 24 of file MutableCachePersistentStorageMgr.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file MutableCachePersistentStorageMgr.cpp.

References CHECK, PersistentStorageMgr::disk_cache_, PersistentStorageMgr::disk_cache_config_, and DiskCacheConfig::isEnabledForMutableTables().

23  : PersistentStorageMgr(data_dir, num_reader_threads, disk_cache_config) {
26 }
bool isEnabledForMutableTables() const
PersistentStorageMgr(const std::string &data_dir, const size_t num_reader_threads, const DiskCacheConfig &disk_cache_config)
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
DiskCacheConfig disk_cache_config_
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

Member Function Documentation

void MutableCachePersistentStorageMgr::checkpoint ( )
override

Definition at line 73 of file MutableCachePersistentStorageMgr.cpp.

References cached_buffer_map_, PersistentStorageMgr::disk_cache_, and PersistentStorageMgr::global_file_mgr_.

73  {
74  for (auto& [key, buf] : cached_buffer_map_) {
75  if (buf->isDirty()) {
77  global_file_mgr_->fetchBuffer(key, &temp_buf, 0);
78  disk_cache_->cacheChunk(key, &temp_buf);
79  }
80  }
82 }
std::map< const ChunkKey, AbstractBuffer * > cached_buffer_map_
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
void MutableCachePersistentStorageMgr::checkpoint ( const int  db_id,
const int  tb_id 
)
override

Definition at line 84 of file MutableCachePersistentStorageMgr.cpp.

References cached_buffer_map_, PersistentStorageMgr::disk_cache_, and PersistentStorageMgr::global_file_mgr_.

84  {
85  ChunkKey chunk_prefix{db_id, tb_id};
86  ChunkKey upper_prefix(chunk_prefix);
87  upper_prefix.push_back(std::numeric_limits<int>::max());
88  auto end_it = cached_buffer_map_.upper_bound(static_cast<const ChunkKey>(upper_prefix));
89  for (auto&& chunk_it = cached_buffer_map_.lower_bound(chunk_prefix); chunk_it != end_it;
90  ++chunk_it) {
91  if (chunk_it->second->isDirty()) {
93  global_file_mgr_->fetchBuffer(chunk_it->first, &temp_buf, 0);
94  disk_cache_->cacheChunk(chunk_it->first, &temp_buf);
95  }
96  }
97  PersistentStorageMgr::global_file_mgr_->checkpoint(db_id, tb_id);
98 }
std::vector< int > ChunkKey
Definition: types.h:37
std::map< const ChunkKey, AbstractBuffer * > cached_buffer_map_
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
AbstractBuffer * MutableCachePersistentStorageMgr::createBuffer ( const ChunkKey chunk_key,
const size_t  page_size,
const size_t  initial_size 
)
override

Definition at line 28 of file MutableCachePersistentStorageMgr.cpp.

References cached_buffer_map_, PersistentStorageMgr::createBuffer(), and PersistentStorageMgr::isChunkPrefixCacheable().

31  {
32  auto buf = PersistentStorageMgr::createBuffer(chunk_key, page_size, initial_size);
33  if (isChunkPrefixCacheable(chunk_key)) {
34  cached_buffer_map_.emplace(chunk_key, buf);
35  }
36  return buf;
37 }
AbstractBuffer * createBuffer(const ChunkKey &chunk_key, const size_t page_size, const size_t initial_size) override
std::map< const ChunkKey, AbstractBuffer * > cached_buffer_map_
bool isChunkPrefixCacheable(const ChunkKey &chunk_prefix) const

+ Here is the call graph for this function:

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

Definition at line 39 of file MutableCachePersistentStorageMgr.cpp.

References cached_buffer_map_, CHECK, PersistentStorageMgr::deleteBuffer(), PersistentStorageMgr::disk_cache_, and PersistentStorageMgr::isForeignStorage().

40  {
41  // No need to delete for FSI-only cache as Foreign Tables are immutable and we should
42  // not be deleting buffers for them.
43  CHECK(!isForeignStorage(chunk_key));
44  disk_cache_->deleteBufferIfExists(chunk_key);
45  cached_buffer_map_.erase(chunk_key);
46  PersistentStorageMgr::deleteBuffer(chunk_key, purge);
47 }
void deleteBuffer(const ChunkKey &chunk_key, const bool purge) override
bool isForeignStorage(const ChunkKey &chunk_key) const
std::map< const ChunkKey, AbstractBuffer * > cached_buffer_map_
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

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

Definition at line 49 of file MutableCachePersistentStorageMgr.cpp.

References cached_buffer_map_, CHECK, PersistentStorageMgr::deleteBuffersWithPrefix(), PersistentStorageMgr::disk_cache_, get_table_key(), and has_table_prefix().

51  {
52  CHECK(has_table_prefix(chunk_key_prefix));
53  disk_cache_->clearForTablePrefix(get_table_key(chunk_key_prefix));
54 
55  ChunkKey upper_prefix(chunk_key_prefix);
56  upper_prefix.push_back(std::numeric_limits<int>::max());
57  auto end_it = cached_buffer_map_.upper_bound(static_cast<const ChunkKey>(upper_prefix));
58  for (auto&& chunk_it = cached_buffer_map_.lower_bound(chunk_key_prefix);
59  chunk_it != end_it;) {
60  chunk_it = cached_buffer_map_.erase(chunk_it);
61  }
62  PersistentStorageMgr::deleteBuffersWithPrefix(chunk_key_prefix, purge);
63 }
std::vector< int > ChunkKey
Definition: types.h:37
ChunkKey get_table_key(const ChunkKey &key)
Definition: types.h:52
bool has_table_prefix(const ChunkKey &key)
Definition: types.h:48
void deleteBuffersWithPrefix(const ChunkKey &chunk_key_prefix, const bool purge) override
std::map< const ChunkKey, AbstractBuffer * > cached_buffer_map_
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

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

Definition at line 65 of file MutableCachePersistentStorageMgr.cpp.

References PersistentStorageMgr::disk_cache_, and PersistentStorageMgr::putBuffer().

67  {
68  auto buf = PersistentStorageMgr::putBuffer(chunk_key, source_buffer, num_bytes);
69  disk_cache_->cacheChunk(chunk_key, source_buffer);
70  return buf;
71 }
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
AbstractBuffer * putBuffer(const ChunkKey &chunk_key, AbstractBuffer *source_buffer, const size_t num_bytes) override

+ Here is the call graph for this function:

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

Definition at line 100 of file MutableCachePersistentStorageMgr.cpp.

References cached_buffer_map_, and PersistentStorageMgr::removeTableRelatedDS().

101  {
103  const ChunkKey table_key{db_id, table_id};
104  ChunkKey upper_prefix(table_key);
105  upper_prefix.push_back(std::numeric_limits<int>::max());
106  auto end_it = cached_buffer_map_.upper_bound(static_cast<const ChunkKey>(upper_prefix));
107  for (auto&& chunk_it = cached_buffer_map_.lower_bound(table_key); chunk_it != end_it;) {
108  chunk_it = cached_buffer_map_.erase(chunk_it);
109  }
110 }
std::vector< int > ChunkKey
Definition: types.h:37
std::map< const ChunkKey, AbstractBuffer * > cached_buffer_map_
void removeTableRelatedDS(const int db_id, const int table_id) override

+ Here is the call graph for this function:

Member Data Documentation

std::map<const ChunkKey, AbstractBuffer*> MutableCachePersistentStorageMgr::cached_buffer_map_
private

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