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>
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() {}
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());
}
return "";
}
+ pair<string,string> raw_key() {
+ if (valid())
+ return make_pair(prefix, key());
+ else
+ return make_pair("","");
+ }
+
bufferlist value() {
if (valid())
return iter->second;