diff --git a/sstables/sstables.cc b/sstables/sstables.cc index 07551953e2..c934ed2088 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -3914,6 +3914,17 @@ sstable::compute_shards_for_this_sstable() const { return boost::copy_range>(shards); } +future sstable::has_partition_key(const utils::hashed_key& hk, const dht::decorated_key& dk) { + shared_sstable s = shared_from_this(); + if (!filter_has_key(hk)) { + return make_ready_future(false); + } + seastar::shared_ptr lh_index = seastar::make_shared(s, default_priority_class()); + return lh_index->advance_lower_and_check_if_present(dk).then([lh_index, s, this] (bool present) { + return make_ready_future(present); + }); +} + utils::hashed_key sstable::make_hashed_key(const schema& s, const partition_key& key) { return utils::make_hashed_key(static_cast(key::from_partition_key(s, key))); } diff --git a/sstables/sstables.hh b/sstables/sstables.hh index 1ad8531d8e..4dfd290211 100644 --- a/sstables/sstables.hh +++ b/sstables/sstables.hh @@ -604,6 +604,14 @@ public: return _components->filter->is_present(bytes_view(key)); } + /*! + * \brief check if the sstable contains the given key. + * The method would search that the key is actually + * found in the sstable not just in the filter. + * + */ + future has_partition_key(const utils::hashed_key& hk, const dht::decorated_key& dk); + bool filter_has_key(utils::hashed_key key) { return _components->filter->is_present(key); }