OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CachingGlobalFileMgr.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
20 #include "GlobalFileMgr.h"
21 
22 namespace File_Namespace {
23 /*
24  A GlobalFileMgr with additional functionality for caching mutable tables to disk.
25  */
27  public:
28  CachingGlobalFileMgr(int32_t device_id,
29  std::shared_ptr<ForeignStorageInterface> fsi,
30  const std::string& base_path,
31  size_t num_reader_threads,
33  size_t defaultPageSize = DEFAULT_PAGE_SIZE);
34 
35  AbstractBuffer* createBuffer(const ChunkKey& chunk_key,
36  const size_t page_size,
37  const size_t initial_size) override;
38 
39  void deleteBuffer(const ChunkKey& chunk_key, const bool purge) override;
40 
41  void deleteBuffersWithPrefix(const ChunkKey& chunk_key_prefix,
42  const bool purge) override;
43 
45  const ChunkKey& keyPrefix) override;
46 
47  void fetchBuffer(const ChunkKey& chunk_key,
48  AbstractBuffer* destination_buffer,
49  const size_t num_bytes) override;
50 
51  AbstractBuffer* putBuffer(const ChunkKey& chunk_key,
52  AbstractBuffer* source_buffer,
53  const size_t num_bytes) override;
54 
55  void checkpoint() override;
56 
57  void checkpoint(const int db_id, const int tb_id) override;
58 
59  void removeTableRelatedDS(const int db_id, const int table_id) override;
60 
61  private:
62  bool isChunkPrefixCacheable(const ChunkKey& chunk_prefix) const;
63 
65  std::set<ChunkKey> cached_chunk_keys_;
66 };
67 } // namespace File_Namespace
std::vector< int > ChunkKey
Definition: types.h:37
void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector &chunk_metadata, const ChunkKey &keyPrefix) override
foreign_storage::ForeignStorageCache * disk_cache_
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 deleteBuffer(const ChunkKey &chunk_key, const bool purge) override
AbstractBuffer * createBuffer(const ChunkKey &chunk_key, const size_t page_size, const size_t initial_size) override
std::vector< std::pair< ChunkKey, std::shared_ptr< ChunkMetadata >>> ChunkMetadataVector
An AbstractBuffer is a unit of data management for a data manager.
bool isChunkPrefixCacheable(const ChunkKey &chunk_prefix) const
#define DEFAULT_PAGE_SIZE
void deleteBuffersWithPrefix(const ChunkKey &chunk_key_prefix, const bool purge) override
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