OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PersistentStorageMgr.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 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 
23 
24 using namespace Data_Namespace;
25 
27  public:
28  static PersistentStorageMgr* createPersistentStorageMgr(
29  const std::string& data_dir,
30  const size_t num_reader_threads,
31  const DiskCacheConfig& disk_cache_config);
32 
33  PersistentStorageMgr(const std::string& data_dir,
34  const size_t num_reader_threads,
35  const DiskCacheConfig& disk_cache_config);
36 
37  AbstractBuffer* createBuffer(const ChunkKey& chunk_key,
38  const size_t page_size,
39  const size_t initial_size) override;
40  void deleteBuffer(const ChunkKey& chunk_key, const bool purge) override;
41  void deleteBuffersWithPrefix(const ChunkKey& chunk_key_prefix,
42  const bool purge) override;
43  AbstractBuffer* getBuffer(const ChunkKey& chunk_key, const size_t num_bytes) override;
44  void fetchBuffer(const ChunkKey& chunk_key,
45  AbstractBuffer* destination_buffer,
46  const size_t num_bytes) override;
47  AbstractBuffer* putBuffer(const ChunkKey& chunk_key,
48  AbstractBuffer* source_buffer,
49  const size_t num_bytes) override;
50  void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector& chunk_metadata,
51  const ChunkKey& chunk_key_prefix) override;
52  bool isBufferOnDevice(const ChunkKey& chunk_key) override;
53  std::string printSlabs() override;
54  void clearSlabs() override;
55  size_t getMaxSize() override;
56  size_t getInUseSize() override;
57  size_t getAllocated() override;
58  bool isAllocationCapped() override;
59  void checkpoint() override;
60  void checkpoint(const int db_id, const int tb_id) override;
61  AbstractBuffer* alloc(const size_t num_bytes) override;
62  void free(AbstractBuffer* buffer) override;
63  MgrType getMgrType() override;
64  std::string getStringMgrType() override;
65  size_t getNumChunks() override;
66  void removeTableRelatedDS(const int db_id, const int table_id) override;
67 
68  File_Namespace::GlobalFileMgr* getGlobalFileMgr() const;
69  foreign_storage::ForeignStorageMgr* getForeignStorageMgr() const;
70  foreign_storage::ForeignStorageCache* getDiskCache() const;
71  inline const DiskCacheConfig getDiskCacheConfig() const { return disk_cache_config_; }
72 
73  protected:
74  bool isForeignStorage(const ChunkKey& chunk_key) const;
75  AbstractBufferMgr* getStorageMgrForTableKey(const ChunkKey& table_key) const;
76  bool isChunkPrefixCacheable(const ChunkKey& chunk_prefix) const;
77  int recoverDataWrapperIfCachedAndGetHighestFragId(const ChunkKey& table_key);
78 
79  std::unique_ptr<File_Namespace::GlobalFileMgr> global_file_mgr_;
80  std::unique_ptr<foreign_storage::ForeignStorageMgr> foreign_storage_mgr_;
81  std::unique_ptr<foreign_storage::ForeignStorageCache> disk_cache_;
83 };
std::vector< int > ChunkKey
Definition: types.h:37
const DiskCacheConfig getDiskCacheConfig() const
std::vector< std::pair< ChunkKey, std::shared_ptr< ChunkMetadata >>> ChunkMetadataVector
An AbstractBuffer is a unit of data management for a data manager.
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
DiskCacheConfig disk_cache_config_
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
std::unique_ptr< foreign_storage::ForeignStorageMgr > foreign_storage_mgr_