Skip to content

Fix return value of randomEntries for HRANDFIELD when count is negative #2343

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

Closed
BalaKaza opened this issue Jun 10, 2022 · 1 comment
Closed
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@BalaKaza
Copy link

Expected behavior

randomEntries(H key, long count) should return the count equivalent entries in case of a negative (absolute value of count) or a positive count value.

Actual behavior

randomEntries(H key, long count) currently returns a Map<HK, HV> which does not account for the duplicates that can be returned(https://redis.io/commands/hrandfield/) when a negative count is given. This results in an inaccurate number (less than the count) of random entries being returned when there is a negative count.

Steps to reproduce:

Create a Hash Set with size 5
Call random entries(H key, long count); with a count of -3.
Assert for the size of the result.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 10, 2022
@mp911de
Copy link
Member

mp911de commented Jun 13, 2022

This limitation is a deliberate design choice of the original ticket as the API would have required two methods or an inconvenient return type that would not allow map lookups. If you want to obtain non-distinct map entries, please use the hRandFieldWithValues(…) method on RedisConnection directly.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2022
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

3 participants