MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
ob_lsm.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
13#include "common/lang/string.h"
14#include "common/lang/string_view.h"
15#include "common/sys/rc.h"
16#include "common/lang/utility.h"
17#include "oblsm/include/ob_lsm_options.h"
18#include "oblsm/include/ob_lsm_iterator.h"
19
20namespace oceanbase {
21
22class ObLsmTransaction;
28class ObLsm
29{
30public:
45 static RC open(const ObLsmOptions &options, const string &path, ObLsm **dbptr);
46
47 ObLsm() = default;
48
49 ObLsm(const ObLsm &) = delete;
50
51 ObLsm &operator=(const ObLsm &) = delete;
52
53 virtual ~ObLsm() = default;
54
64 virtual RC put(const string_view &key, const string_view &value) = 0;
65
76 virtual RC get(const string_view &key, string *value) = 0;
77
86 virtual RC remove(const string_view &key) = 0;
87
88 // TODO: distinguish transaction interface and non-transaction interface, refer to rocksdb
89 virtual ObLsmTransaction *begin_transaction() = 0;
90
104
111 virtual RC batch_put(const vector<pair<string, string>> &kvs) = 0;
112
119 virtual void dump_sstables() = 0;
120};
121
122} // namespace oceanbase
Abstract class for iterating over key-value pairs in an LSM-Tree.
Definition: ob_lsm_iterator.h:41
A class representing a transaction in oblsm.
Definition: ob_lsm_transaction.h:36
ObLsm is a key-value storage engine for educational purpose. ObLsm learned a lot about design from le...
Definition: ob_lsm.h:29
virtual RC get(const string_view &key, string *value)=0
Retrieves the value associated with a specified key.
virtual void dump_sstables()=0
Dumps all SSTables for debugging purposes.
static RC open(const ObLsmOptions &options, const string &path, ObLsm **dbptr)
Opens an LSM-Tree database at the specified path.
Definition: ob_lsm_impl.cpp:94
virtual ObLsmIterator * new_iterator(ObLsmReadOptions options)=0
Creates a new iterator for traversing the LSM-Tree database.
virtual RC put(const string_view &key, const string_view &value)=0
Inserts or updates a key-value entry in the LSM-Tree.
virtual RC remove(const string_view &key)=0
Delete a key-value entry in the LSM-Tree.
virtual RC batch_put(const vector< pair< string, string > > &kvs)=0
Inserts a batch of key-value entries into the LSM-Tree.
Configuration options for the LSM-Tree implementation.
Definition: ob_lsm_options.h:22
Definition: ob_lsm_options.h:48