Skip to content

Instantly share code, notes, and snippets.

@aozturk
Last active December 29, 2015 04:49
Show Gist options
  • Save aozturk/7617344 to your computer and use it in GitHub Desktop.
Save aozturk/7617344 to your computer and use it in GitHub Desktop.
rocksdb::Slice key1 = "one";
rocksdb::Slice key2 = "two";
std::string bar = "bar";
db->Put(rocksdb::WriteOptions(), key1, bar);
std::string value;
rocksdb::Status s = db->Get(rocksdb::ReadOptions(), key1, &value);
if (s.ok()) {
// atomically apply a set of updates
rocksdb::WriteBatch batch;
batch.Delete(key1);
batch.Put(key2, value);
s = db->Write(rocksdb::WriteOptions(), &batch);
}
s = db->Get(rocksdb::ReadOptions(), key1, &value);
assert(s.IsNotFound());
db->Get(rocksdb::ReadOptions(), key2, &value);
assert(value == bar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment