storage_proxy: Extract get_restricted_ranges() as a free function

To make it directly testable.
This commit is contained in:
Tomasz Grabiec
2015-12-15 17:48:54 +01:00
parent 756624ef18
commit e445e4785c
2 changed files with 9 additions and 2 deletions

View File

@@ -2275,6 +2275,12 @@ float storage_proxy::estimate_result_rows_per_range(lw_shared_ptr<query::read_co
*/
std::vector<query::partition_range>
storage_proxy::get_restricted_ranges(keyspace& ks, const schema& s, query::partition_range range) {
locator::token_metadata& tm = get_local_storage_service().get_token_metadata();
return service::get_restricted_ranges(tm, s, std::move(range));
}
std::vector<query::partition_range>
get_restricted_ranges(locator::token_metadata& tm, const schema& s, query::partition_range range) {
dht::ring_position_comparator cmp(s);
// special case for bounds containing exactly 1 token
@@ -2285,8 +2291,6 @@ storage_proxy::get_restricted_ranges(keyspace& ks, const schema& s, query::parti
return std::vector<query::partition_range>({std::move(range)});
}
locator::token_metadata& tm = get_local_storage_service().get_token_metadata();
std::vector<query::partition_range> ranges;
auto add_range = [&ranges, &cmp] (query::partition_range&& r) {

View File

@@ -241,4 +241,7 @@ inline shared_ptr<storage_proxy> get_local_shared_storage_proxy() {
return _the_storage_proxy.local_shared();
}
std::vector<query::partition_range> get_restricted_ranges(locator::token_metadata&,
const schema&, query::partition_range);
}