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 HRANDFIELD command #1565

Merged
merged 13 commits into from
Jul 16, 2023

Conversation

zevin02
Copy link
Contributor

@zevin02 zevin02 commented Jul 8, 2023

Close :#1510

- Add parse for hrandfield
- Implemented the case where the requested data is a positive number
  greater than the size of the hash.

Signed-off-by: Zewen Xu <zevin9427@gmail.com>
src/commands/cmd_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
- add test for hrandfield
- Fix output (nil) when the key does not exist

Signed-off-by: Zewen Xu <zevin9427@gmail.com>
src/types/redis_hash.cc Outdated Show resolved Hide resolved
src/commands/cmd_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
@Yangsx-1
Copy link
Contributor

Yangsx-1 commented Jul 9, 2023

You can also add some go tests.

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.

I didn't review the Hash::RandField implements, just some style nits

src/types/redis_hash.cc Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
@zevin02
Copy link
Contributor Author

zevin02 commented Jul 10, 2023

You can also add some go tests.

I will do it later

- call the GetAll function to get all elements
- add some cpp tests
- wrap functions with lambdas
- updated random selection

Signed-off-by: Zewen Xu <zevin9427@gmail.com>
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.

Looks much better now!

src/commands/cmd_hash.cc Outdated Show resolved Hide resolved
src/commands/cmd_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
zevin02 added 2 commits July 11, 2023 17:54
Signed-off-by: Zewen Xu <zevin9427@gmail.com>
@PragmaTwice PragmaTwice requested a review from mapleFU July 11, 2023 17:56
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.

Looks much better! I didn't check the tests carefully

src/types/redis_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Show resolved Hide resolved
src/types/redis_hash.h Outdated Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
@PragmaTwice
Copy link
Member

Seems here are some clang-tidy reports that need to be fixed.

https://github.com/apache/kvrocks/actions/runs/5542464594/jobs/10117205769?pr=1565

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!

By the way, I noticed that you have written:

// TODO: Add test to verify randomness of the selected random fields

Would this be added in this patch or later?

src/commands/cmd_hash.cc Show resolved Hide resolved
@zevin02
Copy link
Contributor Author

zevin02 commented Jul 14, 2023

Rest LGTM!

By the way, I noticed that you have written:

// TODO: Add test to verify randomness of the selected random fields

Would this be added in this patch or later?

This patch will not implement that

tests/gocase/unit/type/hash/hash_test.go Outdated Show resolved Hide resolved
tests/gocase/unit/type/hash/hash_test.go 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.

Copy link
Contributor

@Yangsx-1 Yangsx-1 left a comment

Choose a reason for hiding this comment

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

Others are good to me. :)

src/commands/cmd_hash.cc Show resolved Hide resolved
src/commands/cmd_hash.cc Show resolved Hide resolved
src/types/redis_hash.cc Outdated Show resolved Hide resolved
src/types/redis_hash.cc Show resolved Hide resolved
@Yangsx-1
Copy link
Contributor

Yangsx-1 commented Jul 15, 2023

fixes :#1510

  • Add parse for hrandfield
  • Implemented the case where the requested data is a positive number greater than the size of the hash.

Close #1510 is better.

PragmaTwice
PragmaTwice previously approved these changes Jul 15, 2023
@git-hulk
Copy link
Member

@zevin02 Thanks for your contribution and patience and greater thanks to reviewers: @mapleFU @PragmaTwice @Yangsx-1

@git-hulk git-hulk merged commit 0a2dcee into apache:unstable Jul 16, 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