summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorcostan <costan@google.com>2018-08-14 15:23:53 -0700
committerVictor Costan <pwnall@chromium.org>2018-08-14 15:30:29 -0700
commitf7b0e1d901da26ac5ce6ad7f0a9806ce1440197e (patch)
tree2cc4735f612860a94982e1db830ab2632cb2a1bf /db
parent6caf73ad9dae0ee91873bcb39554537b85163770 (diff)
downloadleveldb-f7b0e1d901da26ac5ce6ad7f0a9806ce1440197e.tar.gz
Expose WriteBatch::Append().
WriteBatchInternal has a method for efficiently concatenating two WriteBatches. This commit exposes the method to the public API. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208724311
Diffstat (limited to 'db')
-rw-r--r--db/write_batch.cc4
-rw-r--r--db/write_batch_test.cc8
2 files changed, 8 insertions, 4 deletions
diff --git a/db/write_batch.cc b/db/write_batch.cc
index 7f8f3e8..40eed2e 100644
--- a/db/write_batch.cc
+++ b/db/write_batch.cc
@@ -112,6 +112,10 @@ void WriteBatch::Delete(const Slice& key) {
PutLengthPrefixedSlice(&rep_, key);
}
+void WriteBatch::Append(const WriteBatch &source) {
+ WriteBatchInternal::Append(this, &source);
+}
+
namespace {
class MemTableInserter : public WriteBatch::Handler {
public:
diff --git a/db/write_batch_test.cc b/db/write_batch_test.cc
index 8d38023..49c178d 100644
--- a/db/write_batch_test.cc
+++ b/db/write_batch_test.cc
@@ -91,21 +91,21 @@ TEST(WriteBatchTest, Append) {
WriteBatch b1, b2;
WriteBatchInternal::SetSequence(&b1, 200);
WriteBatchInternal::SetSequence(&b2, 300);
- WriteBatchInternal::Append(&b1, &b2);
+ b1.Append(b2);
ASSERT_EQ("",
PrintContents(&b1));
b2.Put("a", "va");
- WriteBatchInternal::Append(&b1, &b2);
+ b1.Append(b2);
ASSERT_EQ("Put(a, va)@200",
PrintContents(&b1));
b2.Clear();
b2.Put("b", "vb");
- WriteBatchInternal::Append(&b1, &b2);
+ b1.Append(b2);
ASSERT_EQ("Put(a, va)@200"
"Put(b, vb)@201",
PrintContents(&b1));
b2.Delete("foo");
- WriteBatchInternal::Append(&b1, &b2);
+ b1.Append(b2);
ASSERT_EQ("Put(a, va)@200"
"Put(b, vb)@202"
"Put(b, vb)@201"