table: Return shared sstable from get_sstables_by_partition_key()
The call is generic enough not to drop the sstable itself on return so that callers can do whatever they need with it. The only today's caller is API which will convert sstables to filenames on its own Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -1020,8 +1020,9 @@ void set_column_family(http_context& ctx, routes& r, sharded<db::system_keyspace
|
||||
return ctx.db.map_reduce0([key, uuid] (replica::database& db) {
|
||||
return db.find_column_family(uuid).get_sstables_by_partition_key(key);
|
||||
}, std::unordered_set<sstring>(),
|
||||
[](std::unordered_set<sstring> a, std::unordered_set<sstring>&& b) mutable {
|
||||
a.insert(b.begin(),b.end());
|
||||
[](std::unordered_set<sstring> a, std::unordered_set<sstables::shared_sstable>&& b) mutable {
|
||||
auto names = b | boost::adaptors::transformed([] (auto s) { return s->get_filename(); });
|
||||
a.insert(names.begin(), names.end());
|
||||
return a;
|
||||
}).then([](const std::unordered_set<sstring>& res) {
|
||||
return make_ready_future<json::json_return_type>(container_to_vec(res));
|
||||
|
||||
@@ -889,7 +889,7 @@ public:
|
||||
* Return a set of the sstables names that contain the given
|
||||
* partition key in nodetool format
|
||||
*/
|
||||
future<std::unordered_set<sstring>> get_sstables_by_partition_key(const sstring& key) const;
|
||||
future<std::unordered_set<sstables::shared_sstable>> get_sstables_by_partition_key(const sstring& key) const;
|
||||
|
||||
const sstables::sstable_set& get_sstable_set() const;
|
||||
lw_shared_ptr<const sstable_list> get_sstables() const;
|
||||
|
||||
@@ -1403,7 +1403,7 @@ int64_t table::get_unleveled_sstables() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
future<std::unordered_set<sstring>> table::get_sstables_by_partition_key(const sstring& key) const {
|
||||
future<std::unordered_set<sstables::shared_sstable>> table::get_sstables_by_partition_key(const sstring& key) const {
|
||||
auto pk = partition_key::from_nodetool_style_string(_schema, key);
|
||||
auto dk = dht::decorate_key(*_schema, pk);
|
||||
auto hk = sstables::sstable::make_hashed_key(*_schema, dk.key());
|
||||
@@ -1411,13 +1411,13 @@ future<std::unordered_set<sstring>> table::get_sstables_by_partition_key(const s
|
||||
auto sel = make_lw_shared<sstables::sstable_set::incremental_selector>(get_sstable_set().make_incremental_selector());
|
||||
const auto& sst = sel->select(dk).sstables;
|
||||
|
||||
std::unordered_set<sstring> filenames;
|
||||
std::unordered_set<sstables::shared_sstable> ssts;
|
||||
for (auto s : sst) {
|
||||
if (co_await s->has_partition_key(hk, dk)) {
|
||||
filenames.insert(s->get_filename());
|
||||
ssts.insert(s);
|
||||
}
|
||||
}
|
||||
co_return filenames;
|
||||
co_return ssts;
|
||||
}
|
||||
|
||||
const sstables::sstable_set& table::get_sstable_set() const {
|
||||
|
||||
Reference in New Issue
Block a user