OmniSciDB  8a228a1076
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 
22 
23 using namespace Data_Namespace;
25  public:
26  PersistentStorageMgr(const std::string& data_dir,
27  const size_t num_reader_threads,
28  const DiskCacheConfig& disk_cache_config);
29 
30  AbstractBuffer* createBuffer(const ChunkKey& chunk_key,
31  const size_t page_size,
32  const size_t initial_size) override;
33  void deleteBuffer(const ChunkKey& chunk_key, const bool purge) override;
34  void deleteBuffersWithPrefix(const ChunkKey& chunk_key_prefix,
35  const bool purge) override;
36  AbstractBuffer* getBuffer(const ChunkKey& chunk_key, const size_t num_bytes) override;
37  void fetchBuffer(const ChunkKey& chunk_key,
38  AbstractBuffer* destination_buffer,
39  const size_t num_bytes) override;
40  AbstractBuffer* putBuffer(const ChunkKey& chunk_key,
41  AbstractBuffer* source_buffer,
42  const size_t num_bytes) override;
43  void getChunkMetadataVec(ChunkMetadataVector& chunk_metadata) override;
44  void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector& chunk_metadata,
45  const ChunkKey& chunk_key_prefix) override;
46  bool isBufferOnDevice(const ChunkKey& chunk_key) override;
47  std::string printSlabs() override;
48  void clearSlabs() 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  File_Namespace::GlobalFileMgr* getGlobalFileMgr();
62  foreign_storage::ForeignStorageMgr* getForeignStorageMgr() const;
63  foreign_storage::ForeignStorageCache* getDiskCache() const;
64 
65  private:
66  bool isForeignStorage(const ChunkKey& chunk_key);
67 
68  std::unique_ptr<File_Namespace::GlobalFileMgr> global_file_mgr_;
69  std::unique_ptr<foreign_storage::ForeignStorageMgr> foreign_storage_mgr_;
70  std::unique_ptr<foreign_storage::ForeignStorageCache> disk_cache_;
71 };
An AbstractBuffer is a unit of data management for a data manager.
std::unique_ptr< foreign_storage::ForeignStorageCache > disk_cache_
std::unique_ptr< File_Namespace::GlobalFileMgr > global_file_mgr_
std::vector< int > ChunkKey
Definition: types.h:35
std::vector< std::pair< ChunkKey, std::shared_ptr< ChunkMetadata > >> ChunkMetadataVector
std::unique_ptr< foreign_storage::ForeignStorageMgr > foreign_storage_mgr_