MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
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 Meiyi & Wangyunlai on 2021/5/11.
13//
14
15#pragma once
16
17#include <stddef.h>
18#include <vector>
19
20#include "common/rc.h"
21#include "storage/index/index_meta.h"
22#include "storage/field/field_meta.h"
23#include "storage/record/record_manager.h"
24
25class IndexScanner;
26
37class Index
38{
39public:
40 Index() = default;
41 virtual ~Index() = default;
42
43 const IndexMeta &index_meta() const
44 {
45 return index_meta_;
46 }
47
54 virtual RC insert_entry(const char *record, const RID *rid) = 0;
55
62 virtual RC delete_entry(const char *record, const RID *rid) = 0;
63
74 virtual IndexScanner *create_scanner(const char *left_key, int left_len, bool left_inclusive, const char *right_key,
75 int right_len, bool right_inclusive) = 0;
76
81 virtual RC sync() = 0;
82
83protected:
84 RC init(const IndexMeta &index_meta, const FieldMeta &field_meta);
85
86protected:
89};
90
96{
97public:
98 IndexScanner() = default;
99 virtual ~IndexScanner() = default;
100
105 virtual RC next_entry(RID *rid) = 0;
106 virtual RC destroy() = 0;
107};
字段元数据
Definition: field_meta.h:31
描述一个索引
Definition: index_meta.h:34
索引扫描器
Definition: index.h:96
virtual RC next_entry(RID *rid)=0
索引基类
Definition: index.h:38
virtual RC sync()=0
同步索引数据到磁盘
virtual IndexScanner * create_scanner(const char *left_key, int left_len, bool left_inclusive, const char *right_key, int right_len, bool right_inclusive)=0
创建一个索引数据的扫描器
virtual RC delete_entry(const char *record, const RID *rid)=0
删除一条数据
virtual RC insert_entry(const char *record, const RID *rid)=0
插入一条数据
FieldMeta field_meta_
当前实现仅考虑一个字段的索引
Definition: index.h:88
IndexMeta index_meta_
索引的元数据
Definition: index.h:87
标识一个记录的位置 一个记录是放在某个文件的某个页面的某个槽位。这里不记录文件信息,记录页面和槽位信息
Definition: record.h:35