]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os: add omap_get_values()
authorKefu Chai <kchai@redhat.com>
Tue, 29 Jan 2019 09:10:47 +0000 (17:10 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 29 Jan 2019 12:04:53 +0000 (20:04 +0800)
osd uses it for storing the pg_info.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/os/cyan_store.cc
src/crimson/os/cyan_store.h

index 2cac32c9c3b9ef7913740cbe86e40e7586f21faf..adebd41e74bd56befe936fbdf31e45ec7eeed0c1 100644 (file)
@@ -152,6 +152,26 @@ seastar::future<bufferlist> CyanStore::read(CollectionRef c,
   return seastar::make_ready_future<bufferlist>(std::move(bl));
 }
 
+seastar::future<CyanStore::omap_values_t>
+CyanStore::omap_get_values(CollectionRef c,
+                           const ghobject_t& oid,
+                           std::vector<std::string>&& 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<omap_values_t>(std::move(values));
+}
+
 seastar::future<> CyanStore::do_transaction(CollectionRef ch,
                                             Transaction&& t)
 {
index e85b6d076b6b6d3dcf718fb82fc3bab49096c7c8..0b7f3d871e45986062ff059b39992c4c05029206 100644 (file)
@@ -37,6 +37,11 @@ public:
                                   uint64_t offset,
                                   size_t len,
                                   uint32_t op_flags = 0);
+  using omap_values_t = std::map<std::string,bufferlist, std::less<>>;
+  seastar::future<omap_values_t> omap_get_values(
+    CollectionRef c,
+    const ghobject_t& oid,
+    std::vector<std::string>&& keys);
   CollectionRef create_new_collection(const coll_t& cid);
   CollectionRef open_collection(const coll_t& cid);
   std::vector<coll_t> list_collections();