From ea7d0b943a07ee54bba826e30d022927376c6f77 Mon Sep 17 00:00:00 2001 From: alabid Date: Tue, 27 Jan 2015 19:37:36 -0500 Subject: [PATCH 1/2] Added WriteBatch block to simple_example.cc --- examples/simple_example.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/simple_example.cc b/examples/simple_example.cc index 20e7faa4b0..28a7c9e8b1 100644 --- a/examples/simple_example.cc +++ b/examples/simple_example.cc @@ -27,14 +27,28 @@ int main() { assert(s.ok()); // Put key-value - s = db->Put(WriteOptions(), "key", "value"); + s = db->Put(WriteOptions(), "key1", "value"); assert(s.ok()); std::string value; // get value - s = db->Get(ReadOptions(), "key", &value); + s = db->Get(ReadOptions(), "key1", &value); assert(s.ok()); assert(value == "value"); + // atomically apply a set of updates + { + WriteBatch batch; + batch.Delete("key1"); + batch.Put("key2", value); + s = db->Write(WriteOptions(), &batch); + } + + s = db->Get(ReadOptions(), "key1", &value); + assert(s.IsNotFound()); + + db->Get(ReadOptions(), "key2", &value); + assert(value == "value"); + delete db; return 0; From f8f040ccc7baed78425dd55e996653e9e2ded9e4 Mon Sep 17 00:00:00 2001 From: alabid Date: Tue, 27 Jan 2015 19:39:39 -0500 Subject: [PATCH 2/2] Updated .gitignore to ignore *~ files and example object files --- .gitignore | 1 + examples/.gitignore | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 70316aebc8..dfd3f49240 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ make_config.mk *.d-e *.o-* *.swp +*~ ldb manifest_dump diff --git a/examples/.gitignore b/examples/.gitignore index d3c22099a5..5cb04d4b66 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -1,2 +1,4 @@ column_families_example simple_example +c_simple_example +compact_files_example