From: Sage Weil Date: Mon, 19 Oct 2015 17:15:13 +0000 (-0400) Subject: kv/RocksDBStore: implement single-item get() X-Git-Tag: v10.0.1~116^2~19 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1f3c01b3db6564acdb43217d38a07dae99462331;p=ceph.git kv/RocksDBStore: implement single-item get() Signed-off-by: Sage Weil --- diff --git a/src/kv/RocksDBStore.cc b/src/kv/RocksDBStore.cc index ce46b93d0fc8..6d2a10217f06 100644 --- a/src/kv/RocksDBStore.cc +++ b/src/kv/RocksDBStore.cc @@ -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; diff --git a/src/kv/RocksDBStore.h b/src/kv/RocksDBStore.h index 9ea125fcf872..257bb2d1c24b 100644 --- a/src/kv/RocksDBStore.h +++ b/src/kv/RocksDBStore.h @@ -161,6 +161,11 @@ public: const std::set &key, std::map *out ); + int get( + const string &prefix, + const string &key, + bufferlist *out + ); class RocksDBWholeSpaceIteratorImpl : public KeyValueDB::WholeSpaceIteratorImpl {