mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-24 10:30:38 +00:00
The compaction strategy was modify to return its compaction type. The type method calls the virtual impl type method. Each of the implementations return its type. A name method was added to the compaction strategy that return the name according to the strategy type. And the static type method was modified to recieve a const reference to the string. Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
68 lines
2.0 KiB
C++
68 lines
2.0 KiB
C++
/*
|
|
* Copyright 2015 Cloudius Systems
|
|
*/
|
|
|
|
#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);
|
|
|
|
}
|