]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
db: add Append interface to allow merge write_batch wip-append
authorHaomai Wang <haomai@xsky.com>
Sun, 26 Feb 2017 16:05:11 +0000 (00:05 +0800)
committerHaomai Wang <haomai@xsky.com>
Sun, 26 Feb 2017 16:05:11 +0000 (00:05 +0800)
Signed-off-by: Haomai Wang <haomai@xsky.com>
db/write_batch.cc
db/write_batch_internal.h
include/rocksdb/write_batch.h

index ea909e244e58d4d2d4e50de6ce00a56359e9ff66..b660922049c48bc6f6cfaa5c3eabb2d815312351 100644 (file)
@@ -1244,7 +1244,7 @@ void WriteBatchInternal::SetContents(WriteBatch* b, const Slice& contents) {
   b->content_flags_.store(ContentFlags::DEFERRED, std::memory_order_relaxed);
 }
 
-void WriteBatchInternal::Append(WriteBatch* dst, const WriteBatch* src) {
+void WriteBatchInternal::Append(WriteBatch* dst, WriteBatch* src) {
   SetCount(dst, Count(dst) + Count(src));
   assert(src->rep_.size() >= WriteBatchInternal::kHeader);
   dst->rep_.append(src->rep_.data() + WriteBatchInternal::kHeader,
@@ -1264,4 +1264,8 @@ size_t WriteBatchInternal::AppendedByteSize(size_t leftByteSize,
   }
 }
 
+void WriteBatch::Append(WriteBatch& src) {
+  WriteBatchInternal::Append(this, &src);
+}
+
 }  // namespace rocksdb
index 1602fdbcc8d54a972754468b138cb5a54352b008..77fbb79c375dd736e19a7d119558c16948da9021 100644 (file)
@@ -177,7 +177,7 @@ class WriteBatchInternal {
                            uint64_t log_number = 0, DB* db = nullptr,
                            bool concurrent_memtable_writes = false);
 
-  static void Append(WriteBatch* dst, const WriteBatch* src);
+  static void Append(WriteBatch* dst, WriteBatch* src);
 
   // Returns the byte size of appending a WriteBatch with ByteSize
   // leftByteSize and a WriteBatch with ByteSize rightByteSize
index 01f2108f1bf1a08d46c86374b938aacbff88b298..ade7c7e6bb8dca451ccc0ebf323cbc389d34313a 100644 (file)
@@ -109,6 +109,7 @@ class WriteBatch : public WriteBatchBase {
   void Merge(const Slice& key, const Slice& value) override {
     Merge(nullptr, key, value);
   }
+  void Append(WriteBatch& src);
 
   // variant that takes SliceParts
   void Merge(ColumnFamilyHandle* column_family, const SliceParts& key,