Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
be899b82
Unverified
Commit
be899b82
authored
Jun 08, 2018
by
Salvatore Sanfilippo
Committed by
GitHub
Jun 08, 2018
Browse files
Merge pull request #4519 from soloestoy/zset-int-problem
Zset int problem
parents
5ebaadc9
109ee497
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/server.h
View file @
be899b82
...
...
@@ -339,7 +339,7 @@ typedef long long mstime_t; /* millisecond time type. */
/* Anti-warning macro... */
#define UNUSED(V) ((void) V)
#define ZSKIPLIST_MAXLEVEL
32
/* Should be enough for 2^
32
elements */
#define ZSKIPLIST_MAXLEVEL
64
/* Should be enough for 2^
64
elements */
#define ZSKIPLIST_P 0.25
/* Skiplist P = 1/4 */
/* Append only defines */
...
...
@@ -782,7 +782,7 @@ typedef struct zskiplistNode {
struct
zskiplistNode
*
backward
;
struct
zskiplistLevel
{
struct
zskiplistNode
*
forward
;
unsigned
int
span
;
unsigned
long
span
;
}
level
[];
}
zskiplistNode
;
...
...
@@ -1628,7 +1628,7 @@ void zzlNext(unsigned char *zl, unsigned char **eptr, unsigned char **sptr);
void
zzlPrev
(
unsigned
char
*
zl
,
unsigned
char
**
eptr
,
unsigned
char
**
sptr
);
unsigned
char
*
zzlFirstInRange
(
unsigned
char
*
zl
,
zrangespec
*
range
);
unsigned
char
*
zzlLastInRange
(
unsigned
char
*
zl
,
zrangespec
*
range
);
unsigned
int
zsetLength
(
const
robj
*
zobj
);
unsigned
long
zsetLength
(
const
robj
*
zobj
);
void
zsetConvert
(
robj
*
zobj
,
int
encoding
);
void
zsetConvertToZiplistIfNeeded
(
robj
*
zobj
,
size_t
maxelelen
);
int
zsetScore
(
robj
*
zobj
,
sds
member
,
double
*
score
);
...
...
src/t_zset.c
View file @
be899b82
...
...
@@ -1100,8 +1100,8 @@ unsigned char *zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsig
* Common sorted set API
*----------------------------------------------------------------------------*/
unsigned
int
zsetLength(const robj *zobj) {
int
length =
-1
;
unsigned
long
zsetLength(const robj *zobj) {
unsigned long
length =
0
;
if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
length = zzlLength(zobj->ptr);
} else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
...
...
@@ -1878,7 +1878,7 @@ void zuiClearIterator(zsetopsrc *op) {
}
}
int
zuiLength(zsetopsrc *op) {
unsigned long
zuiLength(zsetopsrc *op) {
if (op->subject == NULL)
return 0;
...
...
@@ -2085,7 +2085,11 @@ int zuiFind(zsetopsrc *op, zsetopval *val, double *score) {
}
int zuiCompareByCardinality(const void *s1, const void *s2) {
return zuiLength((zsetopsrc*)s1) - zuiLength((zsetopsrc*)s2);
unsigned long first = zuiLength((zsetopsrc*)s1);
unsigned long second = zuiLength((zsetopsrc*)s2);
if (first > second) return 1;
if (first < second) return -1;
return 0;
}
#define REDIS_AGGR_SUM 1
...
...
@@ -2129,7 +2133,7 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
zsetopsrc *src;
zsetopval zval;
sds tmp;
unsigned in
t maxelelen = 0;
size_
t maxelelen = 0;
robj *dstobj;
zset *dstzset;
zskiplistNode *znode;
...
...
@@ -2363,8 +2367,8 @@ void zrangeGenericCommand(client *c, int reverse) {
int withscores = 0;
long start;
long end;
int
llen;
int
rangelen;
long
llen;
long
rangelen;
if ((getLongFromObjectOrReply(c, c->argv[2], &start, NULL) != C_OK) ||
(getLongFromObjectOrReply(c, c->argv[3], &end, NULL) != C_OK)) return;
...
...
@@ -2671,7 +2675,7 @@ void zcountCommand(client *c) {
robj *key = c->argv[1];
robj *zobj;
zrangespec range;
int
count = 0;
unsigned long
count = 0;
/* Parse the range arguments */
if (zslParseRange(c->argv[2],c->argv[3],&range) != C_OK) {
...
...
@@ -2748,7 +2752,7 @@ void zlexcountCommand(client *c) {
robj *key = c->argv[1];
robj *zobj;
zlexrangespec range;
int
count = 0;
unsigned long
count = 0;
/* Parse the range arguments */
if (zslParseLexRange(c->argv[2],c->argv[3],&range) != C_OK) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment