From 1bd12ec2ff3483eb907e78d30a35dd78ca236a39 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Wed, 29 Apr 2015 21:30:41 -0400 Subject: [PATCH] binary search: fix token comparator compare_unsigned cannot be used directly on a token. We need to use the dht-provided token comparators. Signed-off-by: Glauber Costa --- sstables/partition.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sstables/partition.cc b/sstables/partition.cc index e0c4778b68..717b3ad31b 100644 --- a/sstables/partition.cc +++ b/sstables/partition.cc @@ -42,9 +42,10 @@ int sstable::binary_search(const T& entries, const key& sk) { auto mid_key = key_view(mid_bytes); auto mid_token = partitioner.get_token(mid_key); - result = compare_unsigned(bytes_view(token._data), bytes_view(mid_token._data)); - if (result == 0) { + if (token == mid_token) { result = compare_unsigned(sk_bytes, mid_bytes); + } else { + result = token < mid_token ? -1 : 1; } if (result > 0) {