You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "nagisa-kunhah (via GitHub)" <gi...@apache.org> on 2026/09/28 16:21:08 UTC

Re: [PR] feat(CuckooFilter): add cf.del command [kvrocks]

nagisa-kunhah commented on code in PR #3567:
URL: https://github.com/apache/kvrocks/pull/3567#discussion_r4124530168


##########
tests/cppunit/types/cuckoo_filter_test.cc:
##########
@@ -743,3 +783,164 @@ TEST_F(RedisCuckooFilterTest, ExpansionWritesNewFilterIndexPage) {
   ASSERT_TRUE(s.ok()) << s.ToString();
   EXPECT_EQ(page.size(), expected_page_size);
 }
+
+TEST_F(RedisCuckooFilterTest, DeleteMissingKeyReturnsNotFound) {
+  bool deleted = true;
+  auto s = cuckoo_->Delete(*ctx_, key_, "missing", &deleted);
+  EXPECT_TRUE(s.IsNotFound()) << s.ToString();
+  EXPECT_NE(s.ToString().find("Not found"), std::string::npos);
+}
+
+TEST_F(RedisCuckooFilterTest, DeleteBasicClearsOneItem) {
+  reserveAndVerify(key_, 1000, 4, 500, 2);
+  addAndVerify(key_, "item", 1000, 4, 500, 2, 1);
+
+  bool deleted = false;
+  auto s = cuckoo_->Delete(*ctx_, key_, "item", &deleted);
+  ASSERT_TRUE(s.ok()) << s.ToString();
+  EXPECT_TRUE(deleted);
+  verifyMetadata(key_, 1000, 4, 500, 2, 0, 1, 1);
+
+  deleted = true;
+  s = cuckoo_->Delete(*ctx_, key_, "item", &deleted);
+  ASSERT_TRUE(s.ok()) << s.ToString();
+  EXPECT_FALSE(deleted);
+  verifyMetadata(key_, 1000, 4, 500, 2, 0, 1, 1);
+}
+
+TEST_F(RedisCuckooFilterTest, DeleteDuplicateItemsOneAtATime) {
+  reserveAndVerify(key_, 1000, 4, 500, 2);
+  for (int i = 0; i < 3; ++i) {
+    addAndVerify(key_, "duplicate", 1000, 4, 500, 2, i + 1);
+  }
+
+  for (int i = 0; i < 3; ++i) {
+    bool deleted = false;
+    auto s = cuckoo_->Delete(*ctx_, key_, "duplicate", &deleted);
+    ASSERT_TRUE(s.ok()) << s.ToString();
+    EXPECT_TRUE(deleted);
+    verifyMetadata(key_, 1000, 4, 500, 2, 2 - i, 1, i + 1);
+  }
+
+  bool deleted = true;
+  auto s = cuckoo_->Delete(*ctx_, key_, "duplicate", &deleted);
+  ASSERT_TRUE(s.ok()) << s.ToString();
+  EXPECT_FALSE(deleted);
+  verifyMetadata(key_, 1000, 4, 500, 2, 0, 1, 3);
+}

Review Comment:
   Thanks for your advice. Yes, these tests duplicate what go test does, so I’ve removed them.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org