MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
全部  文件 函数 变量 枚举 枚举值 宏定义  
bplus_tree_index.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//
12// Created by wangyunlai.wyl on 2021/5/19.
13//
14
15#pragma once
16
17#include "storage/index/index.h"
18#include "storage/index/bplus_tree.h"
19
24class BplusTreeIndex : public Index
25{
26public:
27 BplusTreeIndex() = default;
28 virtual ~BplusTreeIndex() noexcept;
29
30 RC create(const char *file_name, const IndexMeta &index_meta, const FieldMeta &field_meta);
31 RC open(const char *file_name, const IndexMeta &index_meta, const FieldMeta &field_meta);
32 RC close();
33
34 RC insert_entry(const char *record, const RID *rid) override;
35 RC delete_entry(const char *record, const RID *rid) override;
36
40 IndexScanner *create_scanner(const char *left_key, int left_len, bool left_inclusive, const char *right_key,
41 int right_len, bool right_inclusive) override;
42
43 RC sync() override;
44
45private:
46 bool inited_ = false;
47 BplusTreeHandler index_handler_;
48};
49
55{
56public:
58 ~BplusTreeIndexScanner() noexcept override;
59
60 RC next_entry(RID *rid) override;
61 RC destroy() override;
62
63 RC open(const char *left_key, int left_len, bool left_inclusive, const char *right_key, int right_len,
64 bool right_inclusive);
65
66private:
67 BplusTreeScanner tree_scanner_;
68};
B+树的实现
Definition: bplus_tree.h:459
B+树索引扫描器
Definition: bplus_tree_index.h:55
RC next_entry(RID *rid) override
Definition: bplus_tree_index.cpp:133
B+树索引
Definition: bplus_tree_index.h:25
RC sync() override
同步索引数据到磁盘
Definition: bplus_tree_index.cpp:113
RC insert_entry(const char *record, const RID *rid) override
插入一条数据
Definition: bplus_tree_index.cpp:90
RC delete_entry(const char *record, const RID *rid) override
删除一条数据
Definition: bplus_tree_index.cpp:95
IndexScanner * create_scanner(const char *left_key, int left_len, bool left_inclusive, const char *right_key, int right_len, bool right_inclusive) override
Definition: bplus_tree_index.cpp:100
B+树的扫描器
Definition: bplus_tree.h:593
字段元数据
Definition: field_meta.h:31
描述一个索引
Definition: index_meta.h:34
索引扫描器
Definition: index.h:96
索引基类
Definition: index.h:38
标识一个记录的位置 一个记录是放在某个文件的某个页面的某个槽位。这里不记录文件信息,记录页面和槽位信息
Definition: record.h:35