Last active
December 29, 2015 05:08
-
-
Save aozturk/7619361 to your computer and use it in GitHub Desktop.
Revisions
-
aozturk revised this gist
Nov 23, 2013 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,7 @@ db->Put(rocksdb::WriteOptions(), key3, val3); for (it->SeekToFirst(); it->Valid(); it->Next()) { cout << it->key().ToString() << ": " << it->value().ToString() << endl; } delete it; // do not forget to release the snapshot db->ReleaseSnapshot(readOptions.snapshot); -
aozturk created this gist
Nov 23, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ rocksdb::Slice key1 = "1"; rocksdb::Slice key2 = "2"; std::string val1 = "one"; std::string val2 = "two"; // populate db first db->Put(rocksdb::WriteOptions(), key1, val1); db->Put(rocksdb::WriteOptions(), key2, val2); rocksdb::ReadOptions readOptions; readOptions.snapshot = db->GetSnapshot(); rocksdb::Iterator* it = db->NewIterator(readOptions); // apply some updates to database rocksdb::Slice key3 = "3"; std::string val3 = "three"; db->Put(rocksdb::WriteOptions(), key3, val3); // read using iter to view the state when the snapshot was created for (it->SeekToFirst(); it->Valid(); it->Next()) { cout << it->key().ToString() << ": " << it->value().ToString() << endl; } delete it; db->ReleaseSnapshot(readOptions.snapshot);