OmniSciDB  a667adc9c8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CachingFileMgr.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 
24 #pragma once
25 
26 #include "FileMgr.h"
27 
28 namespace File_Namespace {
29 
30 inline std::string get_dir_name_for_table(int db_id, int tb_id) {
31  std::stringstream file_name;
32  file_name << "table_" << db_id << "_" << tb_id << "/";
33  return file_name.str();
34 }
35 
44 class CachingFileMgr : public FileMgr {
45  public:
46  CachingFileMgr(const std::string& base_path, const size_t num_reader_threads = 0);
53  bool coreInit() override;
54 
55  // Simple getters.
56  inline MgrType getMgrType() override { return CACHING_FILE_MGR; };
57  inline std::string getStringMgrType() override { return ToString(CACHING_FILE_MGR); }
58  inline size_t getDefaultPageSize() { return defaultPageSize_; }
59 
60  // TODO(Misiu): These are unimplemented for now, but will become necessary when we want
61  // to limit the size.
62  inline size_t getMaxSize() override {
63  UNREACHABLE() << "Unimplemented";
64  return 0;
65  }
66  inline size_t getInUseSize() override {
67  UNREACHABLE() << "Unimplemented";
68  return 0;
69  }
70  inline size_t getAllocated() override {
71  UNREACHABLE() << "Unimplemented";
72  return 0;
73  }
74  inline bool isAllocationCapped() override { return false; }
75 
79  void clearForTable(int db_id, int tb_id);
80 
85  std::string getOrAddTableDir(int db_id, int tb_id);
86 
91  inline bool hasFileMgrKey() const override { return false; }
95  void closeRemovePhysical() override;
96 
100  uint64_t getChunkSpaceReservedByTable(int db_id, int tb_id);
101  uint64_t getMetadataSpaceReservedByTable(int db_id, int tb_id);
102  uint64_t getWrapperSpaceReservedByTable(int db_id, int tb_id);
103  uint64_t getSpaceReservedByTable(int db_id, int tb_id);
104 
105  std::string describeSelf() override;
106 };
107 
108 } // namespace File_Namespace
uint64_t getSpaceReservedByTable(int db_id, int tb_id)
uint64_t getMetadataSpaceReservedByTable(int db_id, int tb_id)
uint64_t getWrapperSpaceReservedByTable(int db_id, int tb_id)
std::string getStringMgrType() override
std::string get_dir_name_for_table(int db_id, int tb_id)
#define UNREACHABLE()
Definition: Logger.h:241
std::string getOrAddTableDir(int db_id, int tb_id)
Returns (and optionally creates) a subdirectory for table-specific persistent data (e...
std::string describeSelf() override
void clearForTable(int db_id, int tb_id)
Removes all data related to the given table (pages and subdirectories).
bool isAllocationCapped() override
bool coreInit() override
Determines file path, and if exists, runs file migration and opens and reads epoch file...
size_t getInUseSize() override
size_t defaultPageSize_
number of threads used when loading data
Definition: FileMgr.h:378
MgrType getMgrType() override
bool hasFileMgrKey() const override
Query to determine if the contained pages will have their database and table ids overriden by the fil...
uint64_t getChunkSpaceReservedByTable(int db_id, int tb_id)
CachingFileMgr(const std::string &base_path, const size_t num_reader_threads=0)
A FileMgr capable of limiting it&#39;s size and storing data from multiple tables in a shared directory...
size_t getAllocated() override