]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os: KeyValueDB: Add virtual raw_key() function to return (prefix,key) pair
authorJoao Eduardo Luis <joao.luis@inktank.com>
Mon, 23 Jul 2012 18:48:43 +0000 (19:48 +0100)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Tue, 24 Jul 2012 01:30:14 +0000 (02:30 +0100)
If we were to use solely the key() function, whenever we had a key with,
say, prefix 'Foo' and key 'Bar', the key() function would return something
similar to 'Foo<separator>Bar'. Therefore, obtaining the prefix and the key
would require one to be aware of the separator used, and, since that is
implementation specific, we can't rely on such prior knowledge.

This new function must then be implemented by any derivative class of
KeyValueDB, and is expected to return a pair (prefix,key) for the
current iterator's position -- the key() function should behave as
previously, returning only the 'key' component of the pair.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/os/KeyValueDB.h
src/os/LevelDBStore.h
src/test/ObjectMap/KeyValueDBMemory.cc

index 11b8436b022f58cce28b11a1eafa13c60afbf5a4..3b8b009990d9894f1602ea0636133631cf21e407 100644 (file)
@@ -86,6 +86,7 @@ public:
     virtual int next() = 0;
     virtual int prev() = 0;
     virtual string key() = 0;
+    virtual pair<string,string> raw_key() = 0;
     virtual bufferlist value() = 0;
     virtual int status() = 0;
     virtual ~IteratorImpl() {}
index 957b3dd17446128f4949a67b9631ed5d41dc5901..570ff6d495d0f478db8931e20a13d9c5c52de8b7 100644 (file)
@@ -125,6 +125,11 @@ public:
       split_key(dbiter->key(), 0, &out_key);
       return out_key;
     }
+    pair<string,string> raw_key() {
+      string prefix, key;
+      split_key(dbiter->key(), &prefix, &key);
+      return make_pair(prefix, key);
+    }
     bufferlist value() {
       return to_bufferlist(dbiter->value());
     }
index 930be1f42e5281d95a8cfc4161c015b632af5ad7..43ba1b2fcdeb3e0555a2f6b699916611ea0efb17 100644 (file)
@@ -91,6 +91,13 @@ public:
       return "";
   }
 
+  pair<string,string> raw_key() {
+    if (valid())
+      return make_pair(prefix, key());
+    else
+      return make_pair("","");
+  }
+
   bufferlist value() {
     if (valid())
       return iter->second;