return 0; /* not found */
}
-/* Struct to hold a inclusive/exclusive range spec. */
-typedef struct {
- double min, max;
- int minex, maxex; /* are min or max exclusive? */
-} zrangespec;
-
static int zslValueGteMin(double value, zrangespec *spec) {
return spec->minex ? (value > spec->min) : (value >= spec->min);
}
int length = -1;
if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
length = zzlLength(zobj->ptr);
- } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+ } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
length = ((zset*)zobj->ptr)->zsl->length;
} else {
redisPanic("Unknown sorted set encoding");
unsigned int vlen;
long long vlong;
- if (encoding != REDIS_ENCODING_RAW)
+ if (encoding != REDIS_ENCODING_SKIPLIST)
redisPanic("Unknown target encoding");
zs = zmalloc(sizeof(*zs));
zfree(zobj->ptr);
zobj->ptr = zs;
- zobj->encoding = REDIS_ENCODING_RAW;
- } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+ zobj->encoding = REDIS_ENCODING_SKIPLIST;
+ } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
unsigned char *zl = ziplistNew();
if (encoding != REDIS_ENCODING_ZIPLIST)
* too long *before* executing zzlInsert. */
zobj->ptr = zzlInsert(zobj->ptr,ele,score);
if (zzlLength(zobj->ptr) > server.zset_max_ziplist_entries)
- zsetConvert(zobj,REDIS_ENCODING_RAW);
+ zsetConvert(zobj,REDIS_ENCODING_SKIPLIST);
if (sdslen(ele->ptr) > server.zset_max_ziplist_value)
- zsetConvert(zobj,REDIS_ENCODING_RAW);
+ zsetConvert(zobj,REDIS_ENCODING_SKIPLIST);
signalModifiedKey(c->db,key);
server.dirty++;
else /* ZADD */
addReply(c,shared.cone);
}
- } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+ } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplistNode *znode;
dictEntry *de;
addReply(c,shared.czero);
return;
}
- } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+ } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
dictEntry *de;
double score;
if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
zobj->ptr = zzlDeleteRangeByScore(zobj->ptr,range,&deleted);
if (zzlLength(zobj->ptr) == 0) dbDelete(c->db,key);
- } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+ } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
deleted = zslDeleteRangeByScore(zs->zsl,range,zs->dict);
if (htNeedsResize(zs->dict)) dictResize(zs->dict);
/* Correct for 1-based rank. */
zobj->ptr = zzlDeleteRangeByRank(zobj->ptr,start+1,end+1,&deleted);
if (zzlLength(zobj->ptr) == 0) dbDelete(c->db,key);
- } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+ } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
/* Correct for 1-based rank. */
it->zl.sptr = ziplistNext(it->zl.zl,it->zl.eptr);
redisAssert(it->zl.sptr != NULL);
}
- } else if (op->encoding == REDIS_ENCODING_RAW) {
+ } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {
it->sl.zs = op->subject->ptr;
it->sl.node = it->sl.zs->zsl->header->level[0].forward;
} else {
iterzset *it = &op->iter.zset;
if (op->encoding == REDIS_ENCODING_ZIPLIST) {
REDIS_NOTUSED(it); /* skip */
- } else if (op->encoding == REDIS_ENCODING_RAW) {
+ } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {
REDIS_NOTUSED(it); /* skip */
} else {
redisPanic("Unknown sorted set encoding");
iterzset *it = &op->iter.zset;
if (op->encoding == REDIS_ENCODING_ZIPLIST) {
return zzlLength(it->zl.zl);
- } else if (op->encoding == REDIS_ENCODING_RAW) {
+ } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {
return it->sl.zs->zsl->length;
} else {
redisPanic("Unknown sorted set encoding");
if (op->type == REDIS_SET) {
iterset *it = &op->iter.set;
if (op->encoding == REDIS_ENCODING_INTSET) {
- if (!intsetGet(it->is.is,it->is.ii,&val->ell))
+ if (!intsetGet(it->is.is,it->is.ii,(int64_t*)&val->ell))
return 0;
val->score = 1.0;
/* Move to next element. */
zzlNext(it->zl.zl,&it->zl.eptr,&it->zl.sptr);
- } else if (op->encoding == REDIS_ENCODING_RAW) {
+ } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {
if (it->sl.node == NULL)
return 0;
val->ele = it->sl.node->obj;
} else {
return 0;
}
- } else if (op->encoding == REDIS_ENCODING_RAW) {
+ } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {
dictEntry *de;
if ((de = dictFind(it->sl.zs->dict,val->ele)) != NULL) {
*score = *(double*)dictGetEntryVal(de);
dstobj = createZsetObject();
dstzset = dstobj->ptr;
+ memset(&zval, 0, sizeof(zval));
if (op == REDIS_OP_INTER) {
/* Skip everything if the smallest input is empty. */
zzlNext(zl,&eptr,&sptr);
}
- } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+ } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplist *zsl = zs->zsl;
zskiplistNode *ln;
else
zzlNext(zl,&eptr,&sptr);
}
- } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+ } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplist *zsl = zs->zsl;
zskiplistNode *ln;
addReplyDouble(c,score);
else
addReply(c,shared.nullbulk);
- } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+ } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
dictEntry *de;
} else {
addReply(c,shared.nullbulk);
}
- } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+ } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplist *zsl = zs->zsl;
dictEntry *de;