-
Notifications
You must be signed in to change notification settings - Fork 472
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
Conversation
src/types/redis_bloom_chain.cc
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
Outdated
*output += redis::SimpleString("Number of items inserted"); | ||
*output += redis::Integer(info.size); | ||
*output += redis::SimpleString("Expansion rate"); | ||
*output += redis::Integer(info.expansion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/RedisBloom/RedisBloom/blob/master/src/rebloom.c#L990
Since info.expansion
might be null if it's 0?
src/commands/cmd_bloom_filter.cc
Outdated
public: | ||
Status Parse(const std::vector<std::string> &args) override { | ||
CommandParser parser(args, 2); | ||
while (parser.Good()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while (parser.Good()) { | |
if (parser.Good()) { |
src/commands/cmd_bloom_filter.cc
Outdated
*output = redis::Integer(info.expansion); | ||
break; | ||
default: | ||
LOG(ERROR) << "Failed to parse the type of BF.INFO command"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return error here?
There was a problem hiding this comment.
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 ".
There was a problem hiding this comment.
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.
src/types/redis_bloom_chain.cc
Outdated
|
||
rocksdb::Status BloomChain::Info(const Slice &user_key, BloomFilterInfo *info) { | ||
std::string ns_key = AppendNamespacePrefix(user_key); | ||
LockGuard guard(storage_->GetLockManager(), ns_key); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@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 |
Sure, I think I made a mistake. It should return 0 in this case. I will fix it. |
Thanks all, merging |
This PR introduce the bloom BF.INFO command.
[1] https://redis.io/commands/bf.info/