MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
ob_compaction.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 "oblsm/table/ob_sstable.h"
14#include "oblsm/include/ob_lsm_options.h"
15
16namespace oceanbase {
17
18class ObCompactionPicker;
19
28{
29public:
34 friend class ObCompactionPicker;
35 friend class TiredCompactionPicker;
36 friend class LeveledCompactionPicker;
37
42 explicit ObCompaction(int level) : level_(level) {}
43
44 ~ObCompaction() = default;
45
50 int level() const { return level_; }
51
58 shared_ptr<ObSSTable> input(int which, int i) const { return inputs_[which][i]; }
59
64 int size() const { return inputs_[0].size() + inputs_[1].size(); }
65
69 const vector<shared_ptr<ObSSTable>> &inputs(int which) const { return inputs_[which]; }
70
71private:
73 std::vector<shared_ptr<ObSSTable>> inputs_[2];
74
78 int level_;
79};
80
81} // namespace oceanbase
Abstract base class for compaction picker strategies in an LSM-Tree.
Definition: ob_compaction_picker.h:28
Represents a compaction task in the LSM-Tree.
Definition: ob_compaction.h:28
int level() const
Gets the target level for this compaction.
Definition: ob_compaction.h:50
int level_
The current level of SSTables involved in the compaction.
Definition: ob_compaction.h:78
const vector< shared_ptr< ObSSTable > > & inputs(int which) const
Retrieves the vector of SSTables from the specified input level.
Definition: ob_compaction.h:69
std::vector< shared_ptr< ObSSTable > > inputs_[2]
Each compaction reads inputs from "level_" and "level_+1"
Definition: ob_compaction.h:73
shared_ptr< ObSSTable > input(int which, int i) const
Retrieves an SSTable from the input SSTable list.
Definition: ob_compaction.h:58
ObCompaction(int level)
Constructs a compaction task targeting a specific level.
Definition: ob_compaction.h:42
int size() const
Computes the total number of input SSTables for the compaction task.
Definition: ob_compaction.h:64
A class implementing the tiered compaction strategy.
Definition: ob_compaction_picker.h:62