You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "sam-hn (via GitHub)" <gi...@apache.org> on 2024/01/30 03:13:25 UTC
[I] Command SRANDMEMBER returns empty array when [count] is a negative number [kvrocks]
sam-hn opened a new issue, #2072:
URL: https://github.com/apache/kvrocks/issues/2072
### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/kvrocks/issues) and found no similar issues.
### Version
2.7.0
### Minimal reproduce step
10.70.163.45:6666> srandmember set1 5
1) "mem1"
2) "mem2"
3) "mem3"
10.70.163.45:6666> srandmember set1 -5
(empty array)
10.70.163.45:6666> srandmember set1 -2
(empty array)
### What did you expect to see?
According to https://redis.io/commands/srandmember/, If called with a negative count, the behavior changes and the command is allowed to return the same element multiple times. In this case, the number of returned elements is the absolute value of the specified count
### What did you see instead?
<empty array>
### Anything Else?
_No response_
### Are you willing to submit a PR?
- [X] I'm willing to submit a PR!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Command SRANDMEMBER returns empty array when [count] is a negative number [kvrocks]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on issue #2072:
URL: https://github.com/apache/kvrocks/issues/2072#issuecomment-1964355754
I've fixed this via: https://github.com/apache/kvrocks/pull/2113
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Command SRANDMEMBER returns empty array when [count] is a negative number [kvrocks]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on issue #2072:
URL: https://github.com/apache/kvrocks/issues/2072#issuecomment-1916011614
```c++
rocksdb::Status Set::Take(const Slice &user_key, std::vector<std::string> *members, int count, bool pop) {
int n = 0;
members->clear();
if (count <= 0) return rocksdb::Status::OK();
```
The problem it's the 4th line... It would be easy to fix
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Command SRANDMEMBER returns empty array when [count] is a negative number [kvrocks]
Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk commented on issue #2072:
URL: https://github.com/apache/kvrocks/issues/2072#issuecomment-1916001867
It should be resolved in https://github.com/apache/kvrocks/pull/2032
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Command SRANDMEMBER returns empty array when [count] is a negative number [kvrocks]
Posted by "jihuayu (via GitHub)" <gi...@apache.org>.
jihuayu commented on issue #2072:
URL: https://github.com/apache/kvrocks/issues/2072#issuecomment-1916008214
@git-hulk It looks like no

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Command SRANDMEMBER returns empty array when [count] is a negative number [kvrocks]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU closed issue #2072: Command SRANDMEMBER returns empty array when [count] is a negative number
URL: https://github.com/apache/kvrocks/issues/2072
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Command SRANDMEMBER returns empty array when [count] is a negative number [kvrocks]
Posted by "jihuayu (via GitHub)" <gi...@apache.org>.
jihuayu commented on issue #2072:
URL: https://github.com/apache/kvrocks/issues/2072#issuecomment-1916000606
@sam-hn Thank you.
You can find related code in [this](https://github.com/apache/kvrocks/blob/aa1de3f53252a16e43d381fec83d64ec59228869/src/commands/cmd_set.cc#L190)
And it is better if you can add a [test case](https://github.com/apache/kvrocks/blob/aa1de3f53252a16e43d381fec83d64ec59228869/tests/gocase/unit/type/set/set_test.go#L657)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Command SRANDMEMBER returns empty array when [count] is a negative number [kvrocks]
Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk commented on issue #2072:
URL: https://github.com/apache/kvrocks/issues/2072#issuecomment-1916021417
> @git-hulk It looks like no. First is Redis, second is kvrocks 
Got it, thank you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Command SRANDMEMBER returns empty array when [count] is a negative number [kvrocks]
Posted by "git-hulk (via GitHub)" <gi...@apache.org>.
git-hulk commented on issue #2072:
URL: https://github.com/apache/kvrocks/issues/2072#issuecomment-1916020940
@jihuayu Got it. The issue is still existing while the count parameter was assigned.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org