mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Convert encoding of result when in limits
This commit is contained in:
parent
dba3a153a7
commit
255eebe221
18
src/t_zset.c
18
src/t_zset.c
@ -1426,6 +1426,7 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
|||||||
zsetopsrc *src;
|
zsetopsrc *src;
|
||||||
zsetopval zval;
|
zsetopval zval;
|
||||||
robj *tmp;
|
robj *tmp;
|
||||||
|
unsigned int maxelelen = 0;
|
||||||
robj *dstobj;
|
robj *dstobj;
|
||||||
zset *dstzset;
|
zset *dstzset;
|
||||||
zskiplistNode *znode;
|
zskiplistNode *znode;
|
||||||
@ -1539,6 +1540,10 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
|||||||
incrRefCount(tmp); /* added to skiplist */
|
incrRefCount(tmp); /* added to skiplist */
|
||||||
dictAdd(dstzset->dict,tmp,&znode->score);
|
dictAdd(dstzset->dict,tmp,&znode->score);
|
||||||
incrRefCount(tmp); /* added to dictionary */
|
incrRefCount(tmp); /* added to dictionary */
|
||||||
|
|
||||||
|
if (tmp->encoding == REDIS_ENCODING_RAW)
|
||||||
|
if (sdslen(tmp->ptr) > maxelelen)
|
||||||
|
maxelelen = sdslen(tmp->ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1571,6 +1576,10 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
|||||||
incrRefCount(zval.ele); /* added to skiplist */
|
incrRefCount(zval.ele); /* added to skiplist */
|
||||||
dictAdd(dstzset->dict,tmp,&znode->score);
|
dictAdd(dstzset->dict,tmp,&znode->score);
|
||||||
incrRefCount(zval.ele); /* added to dictionary */
|
incrRefCount(zval.ele); /* added to dictionary */
|
||||||
|
|
||||||
|
if (tmp->encoding == REDIS_ENCODING_RAW)
|
||||||
|
if (sdslen(tmp->ptr) > maxelelen)
|
||||||
|
maxelelen = sdslen(tmp->ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1586,13 +1595,18 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
|||||||
server.dirty++;
|
server.dirty++;
|
||||||
}
|
}
|
||||||
if (dstzset->zsl->length) {
|
if (dstzset->zsl->length) {
|
||||||
|
/* Convert to ziplist when in limits. */
|
||||||
|
if (dstzset->zsl->length <= server.zset_max_ziplist_entries &&
|
||||||
|
maxelelen <= server.zset_max_ziplist_value)
|
||||||
|
zsConvert(dstobj,REDIS_ENCODING_ZIPLIST);
|
||||||
|
|
||||||
dbAdd(c->db,dstkey,dstobj);
|
dbAdd(c->db,dstkey,dstobj);
|
||||||
addReplyLongLong(c, dstzset->zsl->length);
|
addReplyLongLong(c,zsLength(dstobj));
|
||||||
if (!touched) signalModifiedKey(c->db,dstkey);
|
if (!touched) signalModifiedKey(c->db,dstkey);
|
||||||
server.dirty++;
|
server.dirty++;
|
||||||
} else {
|
} else {
|
||||||
decrRefCount(dstobj);
|
decrRefCount(dstobj);
|
||||||
addReply(c, shared.czero);
|
addReply(c,shared.czero);
|
||||||
}
|
}
|
||||||
zfree(src);
|
zfree(src);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user