partitioner: move default_partitioner to schema.cc
Make it inaccessible to other compilation units. Signed-off-by: Piotr Jastrzebski <piotr@scylladb.com>
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
#include "i_partitioner.hh"
|
||||
#include "sharder.hh"
|
||||
#include <seastar/core/reactor.hh>
|
||||
#include "dht/murmur3_partitioner.hh"
|
||||
#include "dht/token-sharding.hh"
|
||||
#include "utils/class_registrator.hh"
|
||||
#include "types.hh"
|
||||
@@ -80,14 +79,6 @@ std::ostream& operator<<(std::ostream& out, partition_ranges_view v) {
|
||||
return out;
|
||||
}
|
||||
|
||||
// FIXME: make it per-keyspace
|
||||
std::unique_ptr<i_partitioner> default_partitioner;
|
||||
|
||||
void set_global_partitioner(const sstring& class_name, unsigned ignore_msb)
|
||||
{
|
||||
default_partitioner = make_partitioner(class_name, smp::count, ignore_msb);
|
||||
}
|
||||
|
||||
std::unique_ptr<dht::i_partitioner> make_partitioner(sstring partitioner_name, unsigned shard_count, unsigned sharding_ignore_msb_bits) {
|
||||
try {
|
||||
return create_object<i_partitioner, const unsigned&, const unsigned&>(partitioner_name, shard_count, sharding_ignore_msb_bits);
|
||||
@@ -99,14 +90,6 @@ std::unique_ptr<dht::i_partitioner> make_partitioner(sstring partitioner_name, u
|
||||
}
|
||||
}
|
||||
|
||||
i_partitioner&
|
||||
global_partitioner() {
|
||||
if (!default_partitioner) {
|
||||
default_partitioner = std::make_unique<murmur3_partitioner>(smp::count, 12);
|
||||
}
|
||||
return *default_partitioner;
|
||||
}
|
||||
|
||||
bool
|
||||
decorated_key::equal(const schema& s, const decorated_key& other) const {
|
||||
if (_token == other._token) {
|
||||
|
||||
@@ -660,9 +660,6 @@ public:
|
||||
};
|
||||
std::ostream& operator<<(std::ostream& out, partition_ranges_view v);
|
||||
|
||||
void set_global_partitioner(const sstring& class_name, unsigned ignore_msb = 0);
|
||||
i_partitioner& global_partitioner();
|
||||
|
||||
unsigned shard_of(const schema&, const token&);
|
||||
inline decorated_key decorate_key(const schema& s, const partition_key& key) {
|
||||
return s.get_partitioner().decorate_key(s, key);
|
||||
|
||||
2
main.cc
2
main.cc
@@ -550,7 +550,7 @@ int main(int ac, char** av) {
|
||||
feature_service.stop().get();
|
||||
});
|
||||
|
||||
dht::set_global_partitioner(cfg->partitioner(), cfg->murmur3_partitioner_ignore_msb_bits());
|
||||
schema::set_default_partitioner(cfg->partitioner(), cfg->murmur3_partitioner_ignore_msb_bits());
|
||||
auto make_sched_group = [&] (sstring name, unsigned shares) {
|
||||
if (cfg->cpu_scheduler()) {
|
||||
return seastar::create_scheduling_group(name, shares).get0();
|
||||
|
||||
@@ -104,6 +104,8 @@ std::ostream& operator<<(std::ostream& os, ordinal_column_id id)
|
||||
}
|
||||
|
||||
thread_local std::map<std::tuple<sstring, unsigned, unsigned>, std::unique_ptr<dht::i_partitioner>> partitioners;
|
||||
sstring default_partitioner_name = "org.apache.cassandra.dht.Murmur3Partitioner";
|
||||
unsigned default_partitioner_ignore_msb = 12;
|
||||
|
||||
static const dht::i_partitioner& get_partitioner(const sstring& name, unsigned shard_count, unsigned ignore_msb) {
|
||||
auto it = partitioners.find({name, shard_count, ignore_msb});
|
||||
@@ -114,11 +116,16 @@ static const dht::i_partitioner& get_partitioner(const sstring& name, unsigned s
|
||||
return *it->second;
|
||||
}
|
||||
|
||||
void schema::set_default_partitioner(const sstring& class_name, unsigned ignore_msb) {
|
||||
default_partitioner_name = class_name;
|
||||
default_partitioner_ignore_msb = ignore_msb;
|
||||
}
|
||||
|
||||
const dht::i_partitioner& schema::get_partitioner() const {
|
||||
if (_raw._partitioner) {
|
||||
return _raw._partitioner->get();
|
||||
}
|
||||
return dht::global_partitioner();
|
||||
return ::get_partitioner(default_partitioner_name, smp::count, default_partitioner_ignore_msb);
|
||||
}
|
||||
|
||||
bool schema::has_custom_partitioner() const {
|
||||
|
||||
Reference in New Issue
Block a user