db = _db;
}
-void RocksDBStore::RocksDBTransactionImpl::set(
- const string &prefix,
- const string &k,
+static void put_bat(
+ rocksdb::WriteBatch& bat,
+ const string &key,
const bufferlist &to_set_bl)
{
- string key = combine_strings(prefix, k);
-
// bufferlist::c_str() is non-constant, so we can't call c_str()
if (to_set_bl.is_contiguous() && to_set_bl.length() > 0) {
bat.Put(rocksdb::Slice(key),
}
}
+void RocksDBStore::RocksDBTransactionImpl::set(
+ const string &prefix,
+ const string &k,
+ const bufferlist &to_set_bl)
+{
+ string key = combine_strings(prefix, k);
+
+ put_bat(bat, key, to_set_bl);
+}
+
void RocksDBStore::RocksDBTransactionImpl::set(
const string &prefix,
const char *k, size_t keylen,
string key;
combine_strings(prefix, k, keylen, &key);
- // bufferlist::c_str() is non-constant, so we can't call c_str()
- if (to_set_bl.is_contiguous() && to_set_bl.length() > 0) {
- bat.Put(rocksdb::Slice(key),
- rocksdb::Slice(to_set_bl.buffers().front().c_str(),
- to_set_bl.length()));
- } else {
- rocksdb::Slice key_slice(key);
- vector<rocksdb::Slice> value_slices(to_set_bl.buffers().size());
- bat.Put(nullptr, rocksdb::SliceParts(&key_slice, 1),
- prepare_sliceparts(to_set_bl, &value_slices));
- }
+ put_bat(bat, key, to_set_bl);
}
void RocksDBStore::RocksDBTransactionImpl::rmkey(const string &prefix,