Skip to content

feat(CuckooFilter): add CF.ADDNX command - #3784

Open
httpanish wants to merge 1 commit into
apache:unstablefrom
httpanish:feat/cuckoo-filter-addnx
Open

httpanish wants to merge 1 commit into
apache:unstablefrom
httpanish:feat/cuckoo-filter-addnx

Conversation

@httpanish

@httpanish httpanish commented Nov 13, 2026 •

Copy link
Copy Markdown

Links to #3552

This PR adds the CF.ADDNX command

CF.ADDNX key item

Cuckoo:Chain::AddNx: checks sub-fillers from oldest to newest unlike MExists so newest filter's pages which the insert tries first are still cached and aren't read from RocksDB twice

I have used Claude Opus 5.5 for generating integration and unit tests

@github-actions

Copy link
Copy Markdown

Hi @httpanish,

Thank you for your pull request. Please review our Contributing Guide.

Please make sure you understand your changes and explain your reasoning in this pull request. Low-quality pull requests may be closed.

@httpanish

Copy link
Copy Markdown
Author

hi @jihuayu @nagisa-kunhah! could you take a look at my PR when there's time please?

@nagisa-kunhah nagisa-kunhah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally LGTM. I left two non-blocking issue here, and you can choose whether to fix it or not. Thanks for your contribution!

Comment on lines +1815 to +1816

TEST_F(RedisCuckooFilterTest, AddNxBasic) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a test that triggers expansion via AddNx and verifies that duplicate items are still detected afterward?

Comment on lines +183 to +198
auto s = getCuckooChainMetadata(ctx, ns_key, &metadata);
bool is_new = false;
if (s.IsNotFound()) {
metadata = CuckooChainMetadata();
metadata.size = 0;
metadata.base_capacity = kCFDefaultCapacity;
metadata.bucket_size = kCFDefaultBucketSize;
metadata.max_iterations = kCFDefaultMaxIterations;
metadata.expansion = kCFDefaultExpansion;
metadata.n_filters = 1;
metadata.num_deleted_items = 0;
metadata.page_size = kCuckooFilterDefaultPageSize;
is_new = true;
} else if (!s.ok()) {
return s;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this logic overlaps with the logic in the Add command, can we extract it into a common function for easier future maintenance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants