]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/RocksDBStore: implement single-item get()
authorSage Weil <sage@redhat.com>
Mon, 19 Oct 2015 17:15:13 +0000 (13:15 -0400)
committerSage Weil <sage@redhat.com>
Mon, 19 Oct 2015 17:15:13 +0000 (13:15 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/kv/RocksDBStore.cc
src/kv/RocksDBStore.h

index ce46b93d0fc8e49c07ff83e8dc9ffd5f388baccf..6d2a10217f06374d2cab10cc34445add40926bda 100644 (file)
@@ -286,6 +286,26 @@ int RocksDBStore::get(
   return 0;
 }
 
+int RocksDBStore::get(
+    const string &prefix,
+    const string &key,
+    bufferlist *out)
+{
+  utime_t start = ceph_clock_now(g_ceph_context);
+  int r = 0;
+  KeyValueDB::Iterator it = get_iterator(prefix);
+  it->lower_bound(key);
+  if (it->valid() && it->key() == key) {
+    *out = it->value();
+  } else {
+    r = -ENOENT;
+  }
+  utime_t lat = ceph_clock_now(g_ceph_context) - start;
+  logger->inc(l_rocksdb_gets);
+  logger->tinc(l_rocksdb_get_latency, lat);
+  return r;
+}
+
 string RocksDBStore::combine_strings(const string &prefix, const string &value)
 {
   string out = prefix;
index 9ea125fcf872819c2d24546cb16830883cf4fb30..257bb2d1c24bef8038f6645d307749c6832c2e33 100644 (file)
@@ -161,6 +161,11 @@ public:
     const std::set<string> &key,
     std::map<string, bufferlist> *out
     );
+  int get(
+    const string &prefix,
+    const string &key,
+    bufferlist *out
+    );
 
   class RocksDBWholeSpaceIteratorImpl :
     public KeyValueDB::WholeSpaceIteratorImpl {