OmniSciDB  ba1bac9284
 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 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
 
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 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
 
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
File_Namespace::DiskCacheConfig 
getDiskCacheConfig () const
 
const std::shared_ptr
< ForeignStorageInterface
getForeignStorageInterface () const
 

Private Attributes

std::set< ChunkKeycached_chunk_keys_
 

Additional Inherited Members

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

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 File_Namespace::DiskCacheConfig disk_cache_config 
)

Definition at line 19 of file MutableCachePersistentStorageMgr.cpp.

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

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

+ 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_chunk_keys_, PersistentStorageMgr::disk_cache_, and PersistentStorageMgr::global_file_mgr_.

73  {
74  for (auto& key : cached_chunk_keys_) {
75  if (global_file_mgr_->getBuffer(key)->isDirty()) {
77  global_file_mgr_->fetchBuffer(key, &temp_buf, 0);
78  disk_cache_->cacheChunk(key, &temp_buf);
79  }
80  }
82 }
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_chunk_keys_, 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_chunk_keys_.upper_bound(static_cast<const ChunkKey>(upper_prefix));
89  for (auto&& chunk_key_it = cached_chunk_keys_.lower_bound(chunk_prefix);
90  chunk_key_it != end_it;
91  ++chunk_key_it) {
92  if (global_file_mgr_->getBuffer(*chunk_key_it)->isDirty()) {
94  global_file_mgr_->fetchBuffer(*chunk_key_it, &temp_buf, 0);
95  disk_cache_->cacheChunk(*chunk_key_it, &temp_buf);
96  }
97  }
98  PersistentStorageMgr::global_file_mgr_->checkpoint(db_id, tb_id);
99 }
std::vector< int > ChunkKey
Definition: types.h:37
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_chunk_keys_, PersistentStorageMgr::createBuffer(), and PersistentStorageMgr::isChunkPrefixCacheable().

31  {
32  auto buf = PersistentStorageMgr::createBuffer(chunk_key, page_size, initial_size);
33  if (isChunkPrefixCacheable(chunk_key)) {
34  cached_chunk_keys_.emplace(chunk_key);
35  }
36  return buf;
37 }
AbstractBuffer * createBuffer(const ChunkKey &chunk_key, const size_t page_size, const size_t initial_size) override
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_chunk_keys_, 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_chunk_keys_.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::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
#define CHECK(condition)
Definition: Logger.h:206

+ 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_chunk_keys_, 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_chunk_keys_.upper_bound(static_cast<const ChunkKey>(upper_prefix));
58  for (auto&& chunk_key_it = cached_chunk_keys_.lower_bound(chunk_key_prefix);
59  chunk_key_it != end_it;) {
60  chunk_key_it = cached_chunk_keys_.erase(chunk_key_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:53
bool has_table_prefix(const ChunkKey &key)
Definition: types.h:49
void deleteBuffersWithPrefix(const ChunkKey &chunk_key_prefix, const bool purge) override
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
#define CHECK(condition)
Definition: Logger.h:206

+ 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 101 of file MutableCachePersistentStorageMgr.cpp.

References cached_chunk_keys_, and PersistentStorageMgr::removeTableRelatedDS().

102  {
104  const ChunkKey table_key{db_id, table_id};
105  ChunkKey upper_prefix(table_key);
106  upper_prefix.push_back(std::numeric_limits<int>::max());
107  auto end_it = cached_chunk_keys_.upper_bound(static_cast<const ChunkKey>(upper_prefix));
108  for (auto&& chunk_key_it = cached_chunk_keys_.lower_bound(table_key);
109  chunk_key_it != end_it;) {
110  chunk_key_it = cached_chunk_keys_.erase(chunk_key_it);
111  }
112 }
std::vector< int > ChunkKey
Definition: types.h:37
void removeTableRelatedDS(const int db_id, const int table_id) override

+ Here is the call graph for this function:

Member Data Documentation

std::set<ChunkKey> MutableCachePersistentStorageMgr::cached_chunk_keys_
private

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