Commit 5f19e8a4 authored by antirez's avatar antirez
Browse files

computeObjectSwappability is now able to compute swappability for intset encoded sets

parent 740eee1c
...@@ -395,6 +395,10 @@ double computeObjectSwappability(robj *o) { ...@@ -395,6 +395,10 @@ double computeObjectSwappability(robj *o) {
z = (o->type == REDIS_ZSET); z = (o->type == REDIS_ZSET);
d = z ? ((zset*)o->ptr)->dict : o->ptr; d = z ? ((zset*)o->ptr)->dict : o->ptr;
if (!z && o->encoding == REDIS_ENCODING_INTSET) {
intset *is = o->ptr;
asize = sizeof(*is)+is->encoding*is->length;
} else {
asize = sizeof(dict)+(sizeof(struct dictEntry*)*dictSlots(d)); asize = sizeof(dict)+(sizeof(struct dictEntry*)*dictSlots(d));
if (z) asize += sizeof(zset)-sizeof(dict); if (z) asize += sizeof(zset)-sizeof(dict);
if (dictSize(d)) { if (dictSize(d)) {
...@@ -405,6 +409,7 @@ double computeObjectSwappability(robj *o) { ...@@ -405,6 +409,7 @@ double computeObjectSwappability(robj *o) {
asize += (sizeof(struct dictEntry)+elesize)*dictSize(d); asize += (sizeof(struct dictEntry)+elesize)*dictSize(d);
if (z) asize += sizeof(zskiplistNode)*dictSize(d); if (z) asize += sizeof(zskiplistNode)*dictSize(d);
} }
}
break; break;
case REDIS_HASH: case REDIS_HASH:
if (o->encoding == REDIS_ENCODING_ZIPMAP) { if (o->encoding == REDIS_ENCODING_ZIPMAP) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment