21 namespace File_Namespace {
24 std::shared_ptr<ForeignStorageInterface> fsi,
25 const std::string& base_path,
26 size_t num_reader_threads,
28 size_t default_page_size)
29 :
GlobalFileMgr(device_id, fsi, base_path, num_reader_threads, default_page_size)
30 , disk_cache_(disk_cache) {
35 const size_t page_size,
36 const size_t initial_size) {
58 ChunkKey upper_prefix(chunk_key_prefix);
59 upper_prefix.push_back(std::numeric_limits<int>::max());
63 chunk_key_it != end_it;) {
92 const size_t num_bytes) {
99 if (file_mgr && file_mgr->getBuffer(chunk_key)->isDirty()) {
108 buffer->
copyTo(destination_buffer, num_bytes);
121 const size_t num_bytes) {
130 std::set<File_Namespace::TablePair> tables_to_checkpoint;
139 for (
auto [db, tb] : tables_to_checkpoint) {
147 bool need_checkpoint{
false};
148 ChunkKey chunk_prefix{db_id, tb_id};
149 ChunkKey upper_prefix(chunk_prefix);
150 upper_prefix.push_back(std::numeric_limits<int>::max());
154 chunk_key_it != end_it;
157 need_checkpoint =
true;
163 if (need_checkpoint) {
172 const ChunkKey table_key{db_id, table_id};
175 upper_prefix.push_back(std::numeric_limits<int>::max());
179 chunk_key_it != end_it;) {
AbstractBuffer * putBuffer(const ChunkKey &key, AbstractBuffer *d, const size_t numBytes=0) override
Puts the contents of d into the Chunk with the given key.
void deleteBuffersWithPrefix(const ChunkKey &keyPrefix, const bool purge=true) override
std::vector< int > ChunkKey
void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector &chunk_metadata, const ChunkKey &keyPrefix) override
std::shared_ptr< ForeignStorageInterface > fsi_
foreign_storage::ForeignStorageCache * disk_cache_
void checkpoint() override
Fsyncs data files, writes out epoch and fsyncs that.
AbstractBuffer * createBuffer(const ChunkKey &key, size_t pageSize=0, const size_t numBytes=0) override
Creates a chunk with the specified key and page size.
void clearForTablePrefix(const ChunkKey &)
CachingGlobalFileMgr(int32_t device_id, std::shared_ptr< ForeignStorageInterface > fsi, const std::string &base_path, size_t num_reader_threads, foreign_storage::ForeignStorageCache *disk_cache, size_t defaultPageSize=DEFAULT_PAGE_SIZE)
void checkpoint() override
void deleteBuffer(const ChunkKey &chunk_key, const bool purge) override
ChunkKey get_table_key(const ChunkKey &key)
void getCachedMetadataVecForKeyPrefix(ChunkMetadataVector &, const ChunkKey &) const
AbstractBuffer * createBuffer(const ChunkKey &chunk_key, const size_t page_size, const size_t initial_size) override
#define CHUNK_KEY_TABLE_IDX
void removeCachedData(const int db_id, const int table_id)
bool has_table_prefix(const ChunkKey &key)
An AbstractBuffer is a unit of data management for a data manager.
void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector &chunkMetadataVec, const ChunkKey &keyPrefix) override
bool isChunkPrefixCacheable(const ChunkKey &chunk_prefix) const
void putBuffer(const ChunkKey &, AbstractBuffer *, const size_t numBytes=0)
void cacheMetadataVec(const ChunkMetadataVector &)
void deleteBuffersWithPrefix(const ChunkKey &chunk_key_prefix, const bool purge) override
void deleteBuffer(const ChunkKey &key, const bool purge=true) override
Deletes the chunk with the specified key.
void deleteBufferIfExists(const ChunkKey &chunk_key)
AbstractBuffer * putBuffer(const ChunkKey &chunk_key, AbstractBuffer *source_buffer, const size_t num_bytes) override
void removeTableRelatedDS(const int db_id, const int table_id) override
void fetchBuffer(const ChunkKey &chunk_key, AbstractBuffer *destination_buffer, const size_t num_bytes) override
AbstractBuffer * getBuffer(const ChunkKey &key, const size_t numBytes=0) override
Returns the a pointer to the chunk with the specified key.
void copyTo(AbstractBuffer *destination_buffer, const size_t num_bytes=0)
std::pair< int, int > get_table_prefix(const ChunkKey &key)
void checkpoint(const int32_t db_id, const int32_t tb_id)
File_Namespace::FileBuffer * getCachedChunkIfExists(const ChunkKey &)
AbstractBufferMgr * findFileMgr(const int32_t db_id, const int32_t tb_id)
bool hasCachedMetadataForKeyPrefix(const ChunkKey &) const
void fetchBuffer(const ChunkKey &key, AbstractBuffer *destBuffer, const size_t numBytes) override
std::set< ChunkKey > cached_chunk_keys_
void removeTableRelatedDS(const int32_t db_id, const int32_t tb_id) override