]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Test merge op covered by range deletion in memtable
authorAndrew Kryczka <andrewkr@fb.com>
Mon, 23 Jan 2017 20:18:42 +0000 (12:18 -0800)
committerAndrew Kryczka <andrewkr@fb.com>
Mon, 23 Jan 2017 20:28:46 +0000 (12:28 -0800)
db/db_range_del_test.cc
db/memtable.cc

index a5047c5541e6a7870f1002152f0223a5ef53cc33..ffc4e6c05e7ca7aeeede30ad30f628cfad837195 100644 (file)
@@ -528,6 +528,36 @@ TEST_F(DBRangeDelTest, GetCoveredKeyFromSst) {
   db_->ReleaseSnapshot(snapshot);
 }
 
+TEST_F(DBRangeDelTest, GetCoveredMergeOperandFromMemtable) {
+  const int kNumMergeOps = 10;
+  Options opts = CurrentOptions();
+  opts.merge_operator = MergeOperators::CreateUInt64AddOperator();
+  Reopen(opts);
+
+  for (int i = 0; i < kNumMergeOps; ++i) {
+    std::string val;
+    PutFixed64(&val, i);
+    db_->Merge(WriteOptions(), "key", val);
+    if (i == kNumMergeOps / 2) {
+      // deletes [0, 5]
+      db_->DeleteRange(WriteOptions(), db_->DefaultColumnFamily(), "key",
+                       "key_");
+    }
+  }
+
+  ReadOptions read_opts;
+  std::string expected, actual;
+  ASSERT_OK(db_->Get(read_opts, "key", &actual));
+  PutFixed64(&expected, 30);  // 6+7+8+9
+  ASSERT_EQ(expected, actual);
+
+  expected.clear();
+  read_opts.ignore_range_deletions = true;
+  ASSERT_OK(db_->Get(read_opts, "key", &actual));
+  PutFixed64(&expected, 45);  // 0+1+2+...+9
+  ASSERT_EQ(expected, actual);
+}
+
 TEST_F(DBRangeDelTest, GetIgnoresRangeDeletions) {
   Options opts = CurrentOptions();
   opts.max_write_buffer_number = 4;
index 23cb3398e4cec9f57c021eb1845052a57409b96a..6da600e8241d0505a3b2b09e0176256e247ea33c 100644 (file)
@@ -560,7 +560,7 @@ static bool SaveValue(void* arg, const char* entry) {
     ValueType type;
     UnPackSequenceAndType(tag, &s->seq, &type);
 
-    if ((type == kTypeValue || type == kTypeDeletion) &&
+    if ((type == kTypeValue || type == kTypeMerge) &&
         range_del_agg->ShouldDelete(Slice(key_ptr, key_length))) {
       type = kTypeRangeDeletion;
     }