diff --git a/sstables/key.hh b/sstables/key.hh index 856dfcdf35..c703ca0ef6 100644 --- a/sstables/key.hh +++ b/sstables/key.hh @@ -59,6 +59,9 @@ public: std::vector explode(const schema& s) const; + int32_t tri_compare(key_view k) const { + return compare_unsigned(bytes_view(_bytes), bytes_view(k)); + } operator key_view() const { return key_view(_bytes); } diff --git a/sstables/partition.cc b/sstables/partition.cc index 476d3d143b..8f512e1395 100644 --- a/sstables/partition.cc +++ b/sstables/partition.cc @@ -40,7 +40,6 @@ int sstable::binary_search(const T& entries, const key& sk, const dht::token& to int low = 0, mid = entries.size(), high = mid - 1, result = -1; auto& partitioner = dht::global_partitioner(); - auto sk_bytes = bytes_view(sk); while (low <= high) { // The token comparison should yield the right result most of the time. @@ -53,7 +52,7 @@ int sstable::binary_search(const T& entries, const key& sk, const dht::token& to auto mid_token = partitioner.get_token(mid_key); if (token == mid_token) { - result = compare_unsigned(sk_bytes, mid_bytes); + result = sk.tri_compare(mid_key); } else { result = token < mid_token ? -1 : 1; }