MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
全部  文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
catalog.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11#pragma once
12#include "common/lang/unordered_map.h"
13#include "common/lang/mutex.h"
14#include "catalog/table_stats.h"
15
25{
26
27public:
28 Catalog() = default;
29
30 ~Catalog() = default;
31
32 Catalog(const Catalog &) = delete;
33
34 Catalog &operator=(const Catalog &) = delete;
35
42 const TableStats &get_table_stats(int table_id);
43
50 void update_table_stats(int table_id, const TableStats &table_stats);
51
60 {
61 static Catalog instance;
62 return instance;
63 }
64
65private:
66 mutex mutex_;
67
73 unordered_map<int, TableStats> table_stats_;
74};
Store metadata, such as table statistics.
Definition: catalog.h:25
void update_table_stats(int table_id, const TableStats &table_stats)
Updates table statistics for a given table.
Definition: catalog.cpp:19
static Catalog & get_instance()
Gets the singleton instance of the Catalog.
Definition: catalog.h:59
const TableStats & get_table_stats(int table_id)
Retrieves table statistics for a given table_id.
Definition: catalog.cpp:13
unordered_map< int, TableStats > table_stats_
A map storing the table statistics indexed by table_id.
Definition: catalog.h:73
Represents statistics related to a table.
Definition: table_stats.h:22