Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the support of the bloom BF.INFO command #1710

Merged
merged 15 commits into from
Aug 31, 2023

Conversation

zncleon
Copy link
Contributor

@zncleon zncleon commented Aug 29, 2023

This PR introduce the bloom BF.INFO command.

[1] https://redis.io/commands/bf.info/

@@ -151,6 +151,7 @@ rocksdb::Status BloomChain::Add(const Slice &user_key, const Slice &item, int *r
s = bloomCheck(bf_key_list[check_index], item_string, ret);
Copy link
Member

Choose a reason for hiding this comment

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

I think we should add another variable to identify the check result(e.g. exists or check_ret) instead of resuing the add result.

src/types/redis_bloom_chain.cc Outdated Show resolved Hide resolved
src/types/redis_bloom_chain.h Outdated Show resolved Hide resolved
Copy link
Member

@mapleFU mapleFU left a comment

Choose a reason for hiding this comment

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

Rest LGTM

src/commands/cmd_bloom_filter.cc Show resolved Hide resolved
*output += redis::SimpleString("Number of items inserted");
*output += redis::Integer(info.size);
*output += redis::SimpleString("Expansion rate");
*output += redis::Integer(info.expansion);
Copy link
Member

Choose a reason for hiding this comment

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

public:
Status Parse(const std::vector<std::string> &args) override {
CommandParser parser(args, 2);
while (parser.Good()) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
while (parser.Good()) {
if (parser.Good()) {

*output = redis::Integer(info.expansion);
break;
default:
LOG(ERROR) << "Failed to parse the type of BF.INFO command";
Copy link
Member

Choose a reason for hiding this comment

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

return error here?

Copy link
Contributor Author

@zncleon zncleon Aug 31, 2023

Choose a reason for hiding this comment

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

If I add a return here, lint would prompt an error: "Unreachable code ".

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah, we can just remove this branch.


rocksdb::Status BloomChain::Info(const Slice &user_key, BloomFilterInfo *info) {
std::string ns_key = AppendNamespacePrefix(user_key);
LockGuard guard(storage_->GetLockManager(), ns_key);
Copy link
Member

Choose a reason for hiding this comment

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

Info doesn't need to lock since it just atomicly get the metadata?

mapleFU
mapleFU previously approved these changes Aug 31, 2023
torwig
torwig previously approved these changes Aug 31, 2023
Copy link
Contributor

@torwig torwig left a comment

Choose a reason for hiding this comment

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

LGTM

@torwig
Copy link
Contributor

torwig commented Aug 31, 2023

@zncleon BTW, according to the Redis documentation, the BF.EXISTS command returns 0 if the key doesn't exist. But I see that currently, the code returns an error {Status::RedisExecErr, "key is not found"}. Is it intentional?

@zncleon
Copy link
Contributor Author

zncleon commented Aug 31, 2023

@zncleon BTW, according to the Redis documentation, the BF.EXISTS command returns 0 if the key doesn't exist. But I see that currently, the code returns an error {Status::RedisExecErr, "key is not found"}. Is it intentional?

Sure, I think I made a mistake. It should return 0 in this case. I will fix it.

@zncleon zncleon dismissed stale reviews from torwig and mapleFU via 63a982b August 31, 2023 08:56
@mapleFU
Copy link
Member

mapleFU commented Aug 31, 2023

Thanks all, merging

@mapleFU mapleFU merged commit 088eae0 into apache:unstable Aug 31, 2023
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.

5 participants