/// Set Keys
void set(
const std::string &prefix, ///< [in] Prefix for keys, or CF name
- const std::map<std::string, bufferlist> &to_set ///< [in] keys/values to set
+ const std::map<std::string, ceph::buffer::list> &to_set ///< [in] keys/values to set
) {
- std::map<std::string, bufferlist>::const_iterator it;
- for (it = to_set.begin(); it != to_set.end(); ++it)
+ for (auto it = to_set.cbegin(); it != to_set.cend(); ++it)
set(prefix, it->first, it->second);
}
- /// Set Keys (via encoded bufferlist)
+ /// Set Keys (via encoded ceph::buffer::list)
void set(
const std::string &prefix, ///< [in] prefix, or CF name
- bufferlist& to_set_bl ///< [in] encoded key/values to set
+ ceph::buffer::list& to_set_bl ///< [in] encoded key/values to set
) {
+ using ceph::decode;
auto p = std::cbegin(to_set_bl);
uint32_t num;
decode(num, p);
while (num--) {
string key;
- bufferlist value;
+ ceph::buffer::list value;
decode(key, p);
decode(value, p);
set(prefix, key, value);
virtual void set(
const std::string &prefix, ///< [in] Prefix or CF for the key
const std::string &k, ///< [in] Key to set
- const bufferlist &bl ///< [in] Value to set
+ const ceph::buffer::list &bl ///< [in] Value to set
) = 0;
virtual void set(
const std::string &prefix,
const char *k,
size_t keylen,
- const bufferlist& bl) {
+ const ceph::buffer::list& bl) {
set(prefix, string(k, keylen), bl);
}
- /// Removes Keys (via encoded bufferlist)
+ /// Removes Keys (via encoded ceph::buffer::list)
void rmkeys(
const std::string &prefix, ///< [in] Prefix or CF to search for
- bufferlist &keys_bl ///< [in] Keys to remove
+ ceph::buffer::list &keys_bl ///< [in] Keys to remove
) {
+ using ceph::decode;
auto p = std::cbegin(keys_bl);
uint32_t num;
decode(num, p);
const std::string &prefix, ///< [in] Prefix/CF to search for
const std::set<std::string> &keys ///< [in] Keys to remove
) {
- std::set<std::string>::const_iterator it;
- for (it = keys.begin(); it != keys.end(); ++it)
+ for (auto it = keys.cbegin(); it != keys.cend(); ++it)
rmkey(prefix, *it);
}
virtual void merge(
const std::string &prefix, ///< [in] Prefix/CF ==> MUST match some established merge operator
const std::string &key, ///< [in] Key to be merged
- const bufferlist &value ///< [in] value to be merged into key
+ const ceph::buffer::list &value ///< [in] value to be merged into key
) { ceph_abort_msg("Not implemented"); }
virtual ~TransactionImpl() {}
/// create a new instance
static KeyValueDB *create(CephContext *cct, const std::string& type,
const std::string& dir,
- map<std::string,std::string> options = {},
+ std::map<std::string,std::string> options = {},
void *p = NULL);
/// test whether we can successfully initialize; may have side effects (e.g., create)
static int test_init(const std::string& type, const std::string& dir);
virtual int init(string option_str="") = 0;
- virtual int open(std::ostream &out, const vector<ColumnFamily>& cfs = {}) = 0;
- // vector cfs contains column families to be created when db is created.
+ virtual int open(std::ostream &out, const std::vector<ColumnFamily>& cfs = {}) = 0;
+ // std::vector cfs contains column families to be created when db is created.
virtual int create_and_open(std::ostream &out,
- const vector<ColumnFamily>& cfs = {}) = 0;
+ const std::vector<ColumnFamily>& cfs = {}) = 0;
- virtual int open_read_only(ostream &out, const vector<ColumnFamily>& cfs = {}) {
+ virtual int open_read_only(std::ostream &out, const std::vector<ColumnFamily>& cfs = {}) {
return -ENOTSUP;
}
virtual int get(
const std::string &prefix, ///< [in] Prefix/CF for key
const std::set<std::string> &key, ///< [in] Key to retrieve
- std::map<std::string, bufferlist> *out ///< [out] Key value retrieved
+ std::map<std::string, ceph::buffer::list> *out ///< [out] Key value retrieved
) = 0;
virtual int get(const std::string &prefix, ///< [in] prefix or CF name
const std::string &key, ///< [in] key
- bufferlist *value) { ///< [out] value
+ ceph::buffer::list *value) { ///< [out] value
std::set<std::string> ks;
ks.insert(key);
- std::map<std::string,bufferlist> om;
+ std::map<std::string,ceph::buffer::list> om;
int r = get(prefix, ks, &om);
if (om.find(key) != om.end()) {
*value = std::move(om[key]);
} else {
- *value = bufferlist();
+ *value = ceph::buffer::list();
r = -ENOENT;
}
return r;
}
virtual int get(const string &prefix,
const char *key, size_t keylen,
- bufferlist *value) {
+ ceph::buffer::list *value) {
return get(prefix, string(key, keylen), value);
}
virtual bool valid() = 0;
virtual int next() = 0;
virtual std::string key() = 0;
- virtual bufferlist value() = 0;
+ virtual std::string tail_key() {
+ return "";
+ }
+ virtual ceph::buffer::list value() = 0;
virtual int status() = 0;
virtual ~SimplestIteratorImpl() {}
};
virtual int seek_to_last() = 0;
virtual int prev() = 0;
virtual std::pair<std::string, std::string> raw_key() = 0;
- virtual bufferptr value_as_ptr() {
- bufferlist bl = value();
+ virtual ceph::buffer::ptr value_as_ptr() {
+ ceph::buffer::list bl = value();
if (bl.length() == 1) {
return *bl.buffers().begin();
} else if (bl.length() == 0) {
- return bufferptr();
+ return ceph::buffer::ptr();
} else {
ceph_abort();
}
virtual std::string key() = 0;
virtual std::pair<std::string,std::string> raw_key() = 0;
virtual bool raw_key_is_prefixed(const std::string &prefix) = 0;
- virtual bufferlist value() = 0;
- virtual bufferptr value_as_ptr() {
- bufferlist bl = value();
+ virtual ceph::buffer::list value() = 0;
+ virtual ceph::buffer::ptr value_as_ptr() {
+ ceph::buffer::list bl = value();
if (bl.length()) {
return *bl.buffers().begin();
} else {
- return bufferptr();
+ return ceph::buffer::ptr();
}
}
virtual int status() = 0;
std::pair<std::string, std::string> raw_key() override {
return generic_iter->raw_key();
}
- bufferlist value() override {
+ ceph::buffer::list value() override {
return generic_iter->value();
}
- bufferptr value_as_ptr() override {
+ ceph::buffer::ptr value_as_ptr() override {
return generic_iter->value_as_ptr();
}
int status() override {
virtual ~KeyValueDB() {}
/// estimate space utilization for a prefix (in bytes)
- virtual int64_t estimate_prefix_size(const string& prefix) {
+ virtual int64_t estimate_prefix_size(const string& prefix,
+ const string& key_prefix) {
return 0;
}
return -EOPNOTSUPP;
}
- virtual void get_statistics(Formatter *f) {
+ virtual void get_statistics(ceph::Formatter *f) {
return;
}
virtual PerfCounters *get_perf_counters() {
return nullptr;
}
+
+ /**
+ * Access implementation specific integral property corresponding
+ * to passed property and prefic.
+ * Return value is true if property is valid for prefix, populates out.
+ */
+ virtual bool get_property(
+ const std::string &property,
+ uint64_t *out) {
+ return false;
+ }
protected:
/// List of matching prefixes/ColumnFamilies and merge operators
std::vector<std::pair<std::string,