forked from scylladb/scylladb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compaction_strategy.hh
84 lines (70 loc) · 2.68 KB
/
compaction_strategy.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Copyright 2015 Cloudius Systems
*/
/*
* This file is part of Scylla.
*
* Scylla is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Scylla is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
class column_family;
namespace sstables {
enum class compaction_strategy_type {
null,
major,
size_tiered,
// FIXME: Add support to LevelTiered, and DateTiered.
};
class compaction_strategy_impl;
class compaction_strategy {
::shared_ptr<compaction_strategy_impl> _compaction_strategy_impl;
public:
compaction_strategy(::shared_ptr<compaction_strategy_impl> impl);
compaction_strategy();
~compaction_strategy();
compaction_strategy(const compaction_strategy&);
compaction_strategy(compaction_strategy&&);
compaction_strategy& operator=(compaction_strategy&&);
future<> compact(column_family& cfs);
static sstring name(compaction_strategy_type type) {
switch (type) {
case compaction_strategy_type::null:
return "NullCompactionStrategy";
case compaction_strategy_type::major:
return "MajorCompactionStrategy";
case compaction_strategy_type::size_tiered:
return "SizeTieredCompactionStrategy";
default:
throw std::runtime_error("Invalid Compaction Strategy");
}
}
static compaction_strategy_type type(const sstring& name) {
if (name == "NullCompactionStrategy") {
return compaction_strategy_type::null;
} else if (name == "MajorCompactionStrategy") {
return compaction_strategy_type::major;
} else if (name == "SizeTieredCompactionStrategy") {
return compaction_strategy_type::size_tiered;
} else {
throw exceptions::configuration_exception(sprint("Unable to find compaction strategy class 'org.apache.cassandra.db.compaction.%s", name));
}
}
compaction_strategy_type type() const;
sstring name() const {
return name(type());
}
};
// Creates a compaction_strategy object from one of the strategies available.
compaction_strategy make_compaction_strategy(compaction_strategy_type strategy, const std::map<sstring, sstring>& options);
}