From aa032af1ebddb02dac67024459c048dbb1169fe4 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 29 Jan 2019 17:10:47 +0800 Subject: [PATCH] crimson/os: add omap_get_values() osd uses it for storing the pg_info. Signed-off-by: Kefu Chai --- src/crimson/os/cyan_store.cc | 20 ++++++++++++++++++++ src/crimson/os/cyan_store.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/src/crimson/os/cyan_store.cc b/src/crimson/os/cyan_store.cc index 2cac32c9c3b9e..adebd41e74bd5 100644 --- a/src/crimson/os/cyan_store.cc +++ b/src/crimson/os/cyan_store.cc @@ -152,6 +152,26 @@ seastar::future CyanStore::read(CollectionRef c, return seastar::make_ready_future(std::move(bl)); } +seastar::future +CyanStore::omap_get_values(CollectionRef c, + const ghobject_t& oid, + std::vector&& keys) +{ + logger().info("{} {} {}", + __func__, c->cid, oid); + auto o = c->get_object(oid); + if (!o) { + throw std::runtime_error(fmt::format("object does not exist: {}", oid)); + } + omap_values_t values; + for (auto& key : keys) { + if (auto found = o->omap.find(key); found != o->omap.end()) { + values.insert(*found); + } + } + return seastar::make_ready_future(std::move(values)); +} + seastar::future<> CyanStore::do_transaction(CollectionRef ch, Transaction&& t) { diff --git a/src/crimson/os/cyan_store.h b/src/crimson/os/cyan_store.h index e85b6d076b6b6..0b7f3d871e459 100644 --- a/src/crimson/os/cyan_store.h +++ b/src/crimson/os/cyan_store.h @@ -37,6 +37,11 @@ public: uint64_t offset, size_t len, uint32_t op_flags = 0); + using omap_values_t = std::map>; + seastar::future omap_get_values( + CollectionRef c, + const ghobject_t& oid, + std::vector&& keys); CollectionRef create_new_collection(const coll_t& cid); CollectionRef open_collection(const coll_t& cid); std::vector list_collections(); -- 2.39.5