sstables: Obtain the key from entries using get_key() rather than casting to bytes_view
The entry contains not only the key, but other stuff like position. Why would casting to bytes_view give the view on just the key and not the whole entry. Better to be explicit.
This commit is contained in:
@@ -33,7 +33,7 @@ namespace sstables {
|
||||
* the extra information when not needed.
|
||||
*
|
||||
* This code should work in all kinds of vectors in whose's elements is possible to aquire
|
||||
* a key view.
|
||||
* a key view via get_key().
|
||||
*/
|
||||
template <typename T>
|
||||
int sstable::binary_search(const T& entries, const key& sk, const dht::token& token) {
|
||||
@@ -47,8 +47,7 @@ int sstable::binary_search(const T& entries, const key& sk, const dht::token& to
|
||||
// creation by keeping only a key view, and then manually carrying out
|
||||
// both parts of the comparison ourselves.
|
||||
mid = low + ((high - low) >> 1);
|
||||
auto mid_bytes = bytes_view(entries[mid]);
|
||||
auto mid_key = key_view(mid_bytes);
|
||||
key_view mid_key = entries[mid].get_key();
|
||||
auto mid_token = partitioner.get_token(mid_key);
|
||||
|
||||
if (token == mid_token) {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "streaming_histogram.hh"
|
||||
#include "estimated_histogram.hh"
|
||||
#include "column_name_helper.hh"
|
||||
#include "sstables/key.hh"
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <type_traits>
|
||||
@@ -43,8 +44,8 @@ struct index_entry {
|
||||
uint64_t position;
|
||||
disk_string<uint32_t> promoted_index;
|
||||
|
||||
explicit operator bytes_view() const {
|
||||
return bytes_view(key);
|
||||
key_view get_key() const {
|
||||
return { bytes_view(key) };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -52,8 +53,8 @@ struct summary_entry {
|
||||
bytes key;
|
||||
uint64_t position;
|
||||
|
||||
explicit operator bytes_view() const {
|
||||
return key;
|
||||
key_view get_key() const {
|
||||
return { key };
|
||||
}
|
||||
|
||||
bool operator==(const summary_entry& x) const {
|
||||
|
||||
Reference in New Issue
Block a user