OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PersistentStorageMgr.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, 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  PersistentStorageMgr(const std::string& data_dir,
29  const size_t num_reader_threads,
30  const File_Namespace::DiskCacheConfig& disk_cache_config);
31 
32  AbstractBuffer* createBuffer(const ChunkKey& chunk_key,
33  const size_t page_size,
34  const size_t initial_size) override;
35  void deleteBuffer(const ChunkKey& chunk_key, const bool purge) override;
36  void deleteBuffersWithPrefix(const ChunkKey& chunk_key_prefix,
37  const bool purge) override;
38  AbstractBuffer* getBuffer(const ChunkKey& chunk_key, const size_t num_bytes) override;
39  void fetchBuffer(const ChunkKey& chunk_key,
40  AbstractBuffer* destination_buffer,
41  const size_t num_bytes) override;
42  AbstractBuffer* putBuffer(const ChunkKey& chunk_key,
43  AbstractBuffer* source_buffer,
44  const size_t num_bytes) override;
45  void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector& chunk_metadata,
46  const ChunkKey& chunk_key_prefix) override;
47  bool isBufferOnDevice(const ChunkKey& chunk_key) override;
48  std::string printSlabs() override;
49  size_t getMaxSize() override;
50  size_t getInUseSize() override;
51  size_t getAllocated() override;
52  bool isAllocationCapped() override;
53  void checkpoint() override;
54  void checkpoint(const int db_id, const int tb_id) override;
55  AbstractBuffer* alloc(const size_t num_bytes) override;
56  void free(AbstractBuffer* buffer) override;
57  MgrType getMgrType() override;
58  std::string getStringMgrType() override;
59  size_t getNumChunks() override;
60  void removeTableRelatedDS(const int db_id, const int table_id) override;
61  void removeMutableTableCacheData(const int db_id, const int table_id) const;
62 
63  File_Namespace::GlobalFileMgr* getGlobalFileMgr() const;
64  foreign_storage::ForeignStorageMgr* getForeignStorageMgr() const;
65  foreign_storage::ForeignStorageCache* getDiskCache() const;
67  return disk_cache_config_;
68  }
69  inline const std::shared_ptr<ForeignStorageInterface> getForeignStorageInterface()
70  const {
71  return fsi_;
72  }
73 
74  protected:
75  bool isForeignStorage(const ChunkKey& chunk_key) const;
76  AbstractBufferMgr* getStorageMgrForTableKey(const ChunkKey& table_key) const;
77  bool isChunkPrefixCacheable(const ChunkKey& chunk_prefix) const;
78  int recoverDataWrapperIfCachedAndGetHighestFragId(const ChunkKey& table_key);
79 
80  std::unique_ptr<File_Namespace::GlobalFileMgr> global_file_mgr_;
81  std::unique_ptr<foreign_storage::ForeignStorageMgr> foreign_storage_mgr_;
82  std::unique_ptr<foreign_storage::ForeignStorageCache> disk_cache_;
84  std::shared_ptr<ForeignStorageInterface> fsi_;
85 };
const File_Namespace::DiskCacheConfig getDiskCacheConfig() const
std::vector< int > ChunkKey
Definition: types.h:36
This file includes the class specification for the FILE manager (FileMgr), and related data structure...
This file includes the class specification for the cache used by the Foreign Storage Interface (FSI)...
const std::shared_ptr< ForeignStorageInterface > getForeignStorageInterface() const
std::shared_ptr< ForeignStorageInterface > fsi_
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_
File_Namespace::DiskCacheConfig disk_cache_config_
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
std::unique_ptr< foreign_storage::ForeignStorageMgr > foreign_storage_mgr_