size_estimates_virtual_reader: Make get_local_ranges static

There's the call of the same name in storage_service, so
make this one explicitly static for better readability.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2020-01-28 11:22:33 +03:00
parent de1dc59548
commit 17db6df15c
3 changed files with 10 additions and 7 deletions

View File

@@ -186,7 +186,10 @@ static system_keyspace::range_estimates estimate(const column_family& cf, const
return {cf.schema(), r.start, r.end, count, count > 0 ? hist.mean() : 0};
}
future<std::vector<token_range>> get_local_ranges() {
/**
* Returns the primary ranges for the local node.
*/
static future<std::vector<token_range>> get_local_ranges() {
auto& ss = service::get_local_storage_service();
return ss.get_local_tokens().then([&ss] (auto&& tokens) {
auto ranges = ss.get_token_metadata().get_primary_ranges_for(std::move(tokens));
@@ -219,6 +222,10 @@ future<std::vector<token_range>> get_local_ranges() {
});
}
future<std::vector<token_range>> test_get_local_ranges() {
return get_local_ranges();
}
size_estimates_mutation_reader::size_estimates_mutation_reader(schema_ptr schema, const dht::partition_range& prange, const query::partition_slice& slice, streamed_mutation::forwarding fwd)
: impl(schema)
, _schema(std::move(schema))

View File

@@ -69,11 +69,7 @@ struct virtual_reader {
}
};
/**
* Returns the primary ranges for the local node.
* Used for testing as well.
*/
future<std::vector<token_range>> get_local_ranges();
future<std::vector<token_range>> test_get_local_ranges();
} // namespace size_estimates

View File

@@ -46,7 +46,7 @@ using namespace std::literals::chrono_literals;
SEASTAR_TEST_CASE(test_query_size_estimates_virtual_table) {
return do_with_cql_env_thread([] (cql_test_env& e) {
auto ranges = db::size_estimates::get_local_ranges().get0();
auto ranges = db::size_estimates::test_get_local_ranges().get0();
auto start_token1 = utf8_type->to_string(ranges[3].start);
auto start_token2 = utf8_type->to_string(ranges[5].start);
auto end_token1 = utf8_type->to_string(ranges[3].end);