Skip to content

Add support of the new command SINTERCARD(Redis 7) #1444

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

Merged
merged 11 commits into from
Jun 13, 2023

Conversation

infdahai
Copy link
Contributor

@infdahai infdahai commented May 18, 2023

closes #1083
closes #1116 (replace)

This PR introduces a sintercard command to kvrocks from redis 7.0.

BTW, the go-redis package's version is v9.0.0-beta.2 in the project so it doesn't support this command(more infomation in redis/go-redis#2291). And I just write a bare test in go-test now.

Perhaps we can bump go-redis to a newer version.

@infdahai infdahai force-pushed the support_sintercard branch from 4ebf856 to 52e1308 Compare May 18, 2023 14:17
@infdahai infdahai force-pushed the support_sintercard branch from 52e1308 to fa3f797 Compare May 18, 2023 17:13
@infdahai
Copy link
Contributor Author

infdahai commented May 19, 2023

@git-hulk I haven't finished go tests because of waiting for #1446. If I write it done, I will ask for reviewers.

@git-hulk
Copy link
Member

The flaky test still exists after applying #1449 and it should be caused by the retry in Go redis client.

@infdahai infdahai force-pushed the support_sintercard branch 2 times, most recently from 576073e to dd0ab3c Compare May 23, 2023 10:54
@infdahai
Copy link
Contributor Author

ready for reviews.

@git-hulk git-hulk changed the title feat: add sintercard command from redis 7.0 Add support of the new command SINTERCARD(Redis 7) May 26, 2023
@PragmaTwice PragmaTwice requested review from torwig and git-hulk May 26, 2023 09:13
@infdahai
Copy link
Contributor Author

infdahai commented May 26, 2023

The PR doesn't have complete tests for wrong parsing msgs based on the latest updating currently. Please wait me for a few days(Sorry, I am moving home).

@git-hulk
Copy link
Member

@infdahai Thanks, no hurry. Can ping back while your PR is ready to review.

@infdahai infdahai force-pushed the support_sintercard branch from 582d1b5 to 4796c4b Compare June 4, 2023 04:42
@infdahai
Copy link
Contributor Author

infdahai commented Jun 4, 2023

@git-hulk I was resurrected. Ready to review.

Signed-off-by: clundro <infdahai@outlook.com>
@infdahai infdahai force-pushed the support_sintercard branch from 0dc91ff to f31a711 Compare June 5, 2023 13:46
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.

In general, it seems like the functionality is correct.

However, I don't like the implementation because (if I understood properly) the cnt parameter of the Set::Inter function serves as the sign that this function calculates only cardinality AND passes the limit (which has only the SINTERCARD command) AND simultaneously serves as the return value. The idea to introduce a separate function directly is bothering me every time I review this PR.
The disadvantage is obviously the additional function in this case.

I would like to hear @git-hulk , @PragmaTwice on this.

Signed-off-by: clundro <infdahai@outlook.com>
@infdahai
Copy link
Contributor Author

infdahai commented Jun 11, 2023

@PragmaTwice
Copy link
Member

PragmaTwice commented Jun 11, 2023

https://github.com/apache/incubator-kvrocks/actions/runs/5234808336/jobs/9452175246

Do we need to ignore this?

Nope. The build procedure need to succeed in Darwin. It cannot be ignored.

You can add some type cast before the std::min call to make it compile successfully.

Signed-off-by: clundro <infdahai@outlook.com>
@infdahai infdahai requested review from torwig and PragmaTwice June 12, 2023 07:34
@torwig
Copy link
Contributor

torwig commented Jun 12, 2023

@infdahai You didn't actually split the Inter function into two separate :) I meant that the Inter function should calculate the intersection between sets and return members while InterCard should only calculate the cardinality and return the computed value. The command Inter will call Set::Inter and the command InterCard will call the Set::InterCard (currently the Set::InterCard function calls Set::Inter and all the complexity is still in the Set::Inter function). In this case, you will get rid of some of the if statements and simplify the code.

@infdahai
Copy link
Contributor Author

infdahai commented Jun 12, 2023

@infdahai You didn't actually split the Inter function into two separate :) I meant that the Inter function should calculate the intersection between sets and return members while InterCard should only calculate the cardinality and return the computed value. The command Inter will call Set::Inter and the command InterCard will call the Set::InterCard (currently the Set::InterCard function calls Set::Inter and all the complexity is still in the Set::Inter function). In this case, you will get rid of some of the if statements and simplify the code.

@torwig I just thought if I split the functions, these two functions exist duplicate codes before and we add the limit 0 to Set::Inter to unify the two functions currently. And I also find the generic function is integrated in redis. https://github.com/redis/redis/blob/f228ec1ea5ef8f3734f1dc0297c5181a651aba1d/src/t_set.c#L1276

I remove the if statements but use duplicate for statements. Of course, I will do as you say.

infdahai added 2 commits June 12, 2023 23:22
Signed-off-by: clundro <infdahai@outlook.com>
Signed-off-by: clundro <infdahai@outlook.com>
Signed-off-by: clundro <infdahai@outlook.com>
torwig
torwig previously approved these changes Jun 12, 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.

Generally, LGTM.

@PragmaTwice PragmaTwice requested a review from torwig June 13, 2023 03:28
@git-hulk
Copy link
Member

Thanks all, merging...

@git-hulk git-hulk merged commit ad704f5 into apache:unstable Jun 13, 2023
@git-hulk
Copy link
Member

@infdahai infdahai deleted the support_sintercard branch June 13, 2023 17:02
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.

[NEW] Add SINTERCARD command aligned Redis
4 participants