mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Merge pull request #4509 from soloestoy/set-int-problem
Set int problem
This commit is contained in:
commit
e4903ce586
14
src/t_set.c
14
src/t_set.c
@ -407,7 +407,7 @@ void spopWithCountCommand(client *c) {
|
|||||||
/* Get the count argument */
|
/* Get the count argument */
|
||||||
if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return;
|
if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return;
|
||||||
if (l >= 0) {
|
if (l >= 0) {
|
||||||
count = (unsigned) l;
|
count = (unsigned long) l;
|
||||||
} else {
|
} else {
|
||||||
addReply(c,shared.outofrangeerr);
|
addReply(c,shared.outofrangeerr);
|
||||||
return;
|
return;
|
||||||
@ -626,7 +626,7 @@ void srandmemberWithCountCommand(client *c) {
|
|||||||
|
|
||||||
if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return;
|
if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return;
|
||||||
if (l >= 0) {
|
if (l >= 0) {
|
||||||
count = (unsigned) l;
|
count = (unsigned long) l;
|
||||||
} else {
|
} else {
|
||||||
/* A negative count means: return the same elements multiple times
|
/* A negative count means: return the same elements multiple times
|
||||||
* (i.e. don't remove the extracted element after every extraction). */
|
* (i.e. don't remove the extracted element after every extraction). */
|
||||||
@ -774,15 +774,21 @@ void srandmemberCommand(client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int qsortCompareSetsByCardinality(const void *s1, const void *s2) {
|
int qsortCompareSetsByCardinality(const void *s1, const void *s2) {
|
||||||
return setTypeSize(*(robj**)s1)-setTypeSize(*(robj**)s2);
|
if (setTypeSize(*(robj**)s1) > setTypeSize(*(robj**)s2)) return 1;
|
||||||
|
if (setTypeSize(*(robj**)s1) < setTypeSize(*(robj**)s2)) return -1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is used by SDIFF and in this case we can receive NULL that should
|
/* This is used by SDIFF and in this case we can receive NULL that should
|
||||||
* be handled as empty sets. */
|
* be handled as empty sets. */
|
||||||
int qsortCompareSetsByRevCardinality(const void *s1, const void *s2) {
|
int qsortCompareSetsByRevCardinality(const void *s1, const void *s2) {
|
||||||
robj *o1 = *(robj**)s1, *o2 = *(robj**)s2;
|
robj *o1 = *(robj**)s1, *o2 = *(robj**)s2;
|
||||||
|
unsigned long first = o1 ? setTypeSize(o1) : 0;
|
||||||
|
unsigned long second = o2 ? setTypeSize(o2) : 0;
|
||||||
|
|
||||||
return (o2 ? setTypeSize(o2) : 0) - (o1 ? setTypeSize(o1) : 0);
|
if (first < second) return 1;
|
||||||
|
if (first > second) return -1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sinterGenericCommand(client *c, robj **setkeys,
|
void sinterGenericCommand(client *c, robj **setkeys,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user