MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
ob_block_builder.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/lang/vector.h"
16#include "common/sys/rc.h"
17
18namespace oceanbase {
19
24{
25
26public:
27 RC add(const string_view &key, const string_view &value);
28
29 string_view finish();
30
31 void reset();
32
33 string last_key() const;
34
35 uint32_t appro_size() { return data_.size() + offsets_.size() * sizeof(uint32_t); }
36
37private:
38 static const uint32_t BLOCK_SIZE = 4 * 1024; // 4KB
39 // Offsets of key-value pairs.
40 vector<uint32_t> offsets_;
41 // key-value pairs
42 // TODO: use block as data container
43 // TODO: add checksum
44 string data_;
45
46 // string first_key_;
47};
48
49} // namespace oceanbase
Build a ObBlock in SSTable
Definition: ob_block_builder.h:24