mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
everywhere: use dht::token is_{minimum,maximum}
The is_minimum/is_maximum predicates are more
efficient than comparing the the m{minimum,maximum}_token
values, respectrively. since the is_* functions
need to check only the token kind.
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
@@ -195,10 +195,10 @@ static future<std::vector<token_range>> get_local_ranges(replica::database& db,
|
||||
// All queries will be on that table, where all entries are text and there's no notion of
|
||||
// token ranges form the CQL point of view.
|
||||
auto left_inf = boost::find_if(ranges, [] (auto&& r) {
|
||||
return r.end() && (!r.start() || r.start()->value() == dht::minimum_token());
|
||||
return r.end() && (!r.start() || r.start()->value().is_minimum());
|
||||
});
|
||||
auto right_inf = boost::find_if(ranges, [] (auto&& r) {
|
||||
return r.start() && (!r.end() || r.end()->value() == dht::maximum_token());
|
||||
return r.start() && (!r.end() || r.end()->value().is_maximum());
|
||||
});
|
||||
if (left_inf != right_inf && left_inf != ranges.end() && right_inf != ranges.end()) {
|
||||
local_ranges.push_back(token_range{to_bytes(right_inf->start()), to_bytes(left_inf->end())});
|
||||
|
||||
@@ -67,7 +67,7 @@ static_sharder::next_shard(const token& t) const {
|
||||
auto shard = shard_for_reads(t);
|
||||
auto next_shard = shard + 1 == _shard_count ? 0 : shard + 1;
|
||||
auto next_token = token_for_next_shard_for_reads(t, next_shard);
|
||||
if (next_token == dht::maximum_token()) {
|
||||
if (next_token.is_maximum()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return shard_and_token{next_shard, next_token};
|
||||
@@ -189,7 +189,7 @@ ring_position_range_sharder::next(const schema& s) {
|
||||
auto shard_boundary_token = next_shard_and_token->token;
|
||||
auto shard_boundary = ring_position::starting_at(shard_boundary_token);
|
||||
if ((!_range.end() || shard_boundary.less_compare(s, _range.end()->value()))
|
||||
&& shard_boundary_token != maximum_token()) {
|
||||
&& !shard_boundary_token.is_maximum()) {
|
||||
// split the range at end_of_shard
|
||||
auto start = _range.start();
|
||||
auto end = interval_bound<ring_position>(shard_boundary, false);
|
||||
@@ -240,7 +240,7 @@ split_range_to_single_shard(const schema& s, const static_sharder& sharder, cons
|
||||
start_boundary,
|
||||
shard] () mutable {
|
||||
if (pr.overlaps(partition_range(start_boundary, {}), cmp)
|
||||
&& !(start_boundary && start_boundary->value().token() == maximum_token())) {
|
||||
&& !(start_boundary && start_boundary->value().token().is_maximum())) {
|
||||
dht::token end_token = maximum_token();
|
||||
auto s_a_t = sharder.next_shard(start_token);
|
||||
if (s_a_t) {
|
||||
|
||||
Reference in New Issue
Block a user