Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
59e51f92
Commit
59e51f92
authored
Dec 08, 2017
by
zhaozhao.zz
Committed by
antirez
Jun 12, 2018
Browse files
zset: fix the int problem
parent
3502d1f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/server.h
View file @
59e51f92
...
@@ -1624,7 +1624,7 @@ void zzlNext(unsigned char *zl, unsigned char **eptr, unsigned char **sptr);
...
@@ -1624,7 +1624,7 @@ void zzlNext(unsigned char *zl, unsigned char **eptr, unsigned char **sptr);
void
zzlPrev
(
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
*
zzlFirstInRange
(
unsigned
char
*
zl
,
zrangespec
*
range
);
unsigned
char
*
zzlLastInRange
(
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
zsetConvert
(
robj
*
zobj
,
int
encoding
);
void
zsetConvertToZiplistIfNeeded
(
robj
*
zobj
,
size_t
maxelelen
);
void
zsetConvertToZiplistIfNeeded
(
robj
*
zobj
,
size_t
maxelelen
);
int
zsetScore
(
robj
*
zobj
,
sds
member
,
double
*
score
);
int
zsetScore
(
robj
*
zobj
,
sds
member
,
double
*
score
);
...
...
src/t_zset.c
View file @
59e51f92
...
@@ -1100,8 +1100,8 @@ unsigned char *zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsig
...
@@ -1100,8 +1100,8 @@ unsigned char *zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsig
* Common sorted set API
* Common sorted set API
*----------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
unsigned
int
zsetLength(const robj *zobj) {
unsigned
long
zsetLength(const robj *zobj) {
int
length =
-1
;
unsigned long
length =
0
;
if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
length = zzlLength(zobj->ptr);
length = zzlLength(zobj->ptr);
} else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
} else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
...
@@ -1878,7 +1878,7 @@ void zuiClearIterator(zsetopsrc *op) {
...
@@ -1878,7 +1878,7 @@ void zuiClearIterator(zsetopsrc *op) {
}
}
}
}
int
zuiLength(zsetopsrc *op) {
unsigned long
zuiLength(zsetopsrc *op) {
if (op->subject == NULL)
if (op->subject == NULL)
return 0;
return 0;
...
@@ -2085,7 +2085,11 @@ int zuiFind(zsetopsrc *op, zsetopval *val, double *score) {
...
@@ -2085,7 +2085,11 @@ int zuiFind(zsetopsrc *op, zsetopval *val, double *score) {
}
}
int zuiCompareByCardinality(const void *s1, const void *s2) {
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
#define REDIS_AGGR_SUM 1
...
@@ -2129,7 +2133,7 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
...
@@ -2129,7 +2133,7 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
zsetopsrc *src;
zsetopsrc *src;
zsetopval zval;
zsetopval zval;
sds tmp;
sds tmp;
unsigned in
t maxelelen = 0;
size_
t maxelelen = 0;
robj *dstobj;
robj *dstobj;
zset *dstzset;
zset *dstzset;
zskiplistNode *znode;
zskiplistNode *znode;
...
@@ -2363,8 +2367,8 @@ void zrangeGenericCommand(client *c, int reverse) {
...
@@ -2363,8 +2367,8 @@ void zrangeGenericCommand(client *c, int reverse) {
int withscores = 0;
int withscores = 0;
long start;
long start;
long end;
long end;
int
llen;
long
llen;
int
rangelen;
long
rangelen;
if ((getLongFromObjectOrReply(c, c->argv[2], &start, NULL) != C_OK) ||
if ((getLongFromObjectOrReply(c, c->argv[2], &start, NULL) != C_OK) ||
(getLongFromObjectOrReply(c, c->argv[3], &end, NULL) != C_OK)) return;
(getLongFromObjectOrReply(c, c->argv[3], &end, NULL) != C_OK)) return;
...
@@ -2671,7 +2675,7 @@ void zcountCommand(client *c) {
...
@@ -2671,7 +2675,7 @@ void zcountCommand(client *c) {
robj *key = c->argv[1];
robj *key = c->argv[1];
robj *zobj;
robj *zobj;
zrangespec range;
zrangespec range;
int
count = 0;
unsigned long
count = 0;
/* Parse the range arguments */
/* Parse the range arguments */
if (zslParseRange(c->argv[2],c->argv[3],&range) != C_OK) {
if (zslParseRange(c->argv[2],c->argv[3],&range) != C_OK) {
...
@@ -2748,7 +2752,7 @@ void zlexcountCommand(client *c) {
...
@@ -2748,7 +2752,7 @@ void zlexcountCommand(client *c) {
robj *key = c->argv[1];
robj *key = c->argv[1];
robj *zobj;
robj *zobj;
zlexrangespec range;
zlexrangespec range;
int
count = 0;
unsigned long
count = 0;
/* Parse the range arguments */
/* Parse the range arguments */
if (zslParseLexRange(c->argv[2],c->argv[3],&range) != C_OK) {
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