mirror of
https://github.com/fluencelabs/redis
synced 2025-05-09 17:32:15 +00:00
Some manual merging of encoded values direct saving
This commit is contained in:
parent
552a6fb39d
commit
73f01b0606
44
src/rdb.c
44
src/rdb.c
@ -304,39 +304,10 @@ int rdbSaveObject(FILE *fp, robj *o) {
|
|||||||
} else if (o->type == REDIS_ZSET) {
|
} else if (o->type == REDIS_ZSET) {
|
||||||
/* Save a sorted set value */
|
/* Save a sorted set value */
|
||||||
if (o->encoding == REDIS_ENCODING_ZIPLIST) {
|
if (o->encoding == REDIS_ENCODING_ZIPLIST) {
|
||||||
unsigned char *zl = o->ptr;
|
size_t l = ziplistBlobLen((unsigned char*)o->ptr);
|
||||||
unsigned char *eptr, *sptr;
|
|
||||||
unsigned char *vstr;
|
|
||||||
unsigned int vlen;
|
|
||||||
long long vlong;
|
|
||||||
double score;
|
|
||||||
|
|
||||||
if ((n = rdbSaveLen(fp,zsetLength(o))) == -1) return -1;
|
if ((n = rdbSaveRawString(fp,o->ptr,l)) == -1) return -1;
|
||||||
nwritten += n;
|
nwritten += n;
|
||||||
|
|
||||||
eptr = ziplistIndex(zl,0);
|
|
||||||
redisAssert(eptr != NULL);
|
|
||||||
sptr = ziplistNext(zl,eptr);
|
|
||||||
redisAssert(sptr != NULL);
|
|
||||||
|
|
||||||
while (eptr != NULL) {
|
|
||||||
redisAssert(ziplistGet(eptr,&vstr,&vlen,&vlong));
|
|
||||||
if (vstr) {
|
|
||||||
if ((n = rdbSaveRawString(fp,vstr,vlen)) == -1)
|
|
||||||
return -1;
|
|
||||||
nwritten += n;
|
|
||||||
} else {
|
|
||||||
if ((n = rdbSaveLongLongAsStringObject(fp,vlong)) == -1)
|
|
||||||
return -1;
|
|
||||||
nwritten += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
score = zzlGetScore(sptr);
|
|
||||||
if ((n = rdbSaveDoubleValue(fp,score)) == -1) return -1;
|
|
||||||
nwritten += n;
|
|
||||||
|
|
||||||
zzlNext(zl,&eptr,&sptr);
|
|
||||||
}
|
|
||||||
} else if (o->encoding == REDIS_ENCODING_SKIPLIST) {
|
} else if (o->encoding == REDIS_ENCODING_SKIPLIST) {
|
||||||
zset *zs = o->ptr;
|
zset *zs = o->ptr;
|
||||||
dictIterator *di = dictGetIterator(zs->dict);
|
dictIterator *di = dictGetIterator(zs->dict);
|
||||||
@ -869,7 +840,8 @@ robj *rdbLoadObject(int type, FILE *fp) {
|
|||||||
}
|
}
|
||||||
} else if (type == REDIS_HASH_ZIPMAP ||
|
} else if (type == REDIS_HASH_ZIPMAP ||
|
||||||
type == REDIS_LIST_ZIPLIST ||
|
type == REDIS_LIST_ZIPLIST ||
|
||||||
type == REDIS_SET_INTSET)
|
type == REDIS_SET_INTSET ||
|
||||||
|
type == REDIS_ZSET_ZIPLIST)
|
||||||
{
|
{
|
||||||
robj *aux = rdbLoadStringObject(fp);
|
robj *aux = rdbLoadStringObject(fp);
|
||||||
|
|
||||||
@ -904,8 +876,14 @@ robj *rdbLoadObject(int type, FILE *fp) {
|
|||||||
if (intsetLen(o->ptr) > server.set_max_intset_entries)
|
if (intsetLen(o->ptr) > server.set_max_intset_entries)
|
||||||
setTypeConvert(o,REDIS_ENCODING_HT);
|
setTypeConvert(o,REDIS_ENCODING_HT);
|
||||||
break;
|
break;
|
||||||
|
case REDIS_ZSET_ZIPLIST:
|
||||||
|
o->type = REDIS_ZSET;
|
||||||
|
o->encoding = REDIS_ENCODING_ZIPLIST;
|
||||||
|
if (zsetLength(o) > server.zset_max_ziplist_entries)
|
||||||
|
zsetConvert(o,REDIS_ENCODING_SKIPLIST);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
redisPanic("Unknown enoding");
|
redisPanic("Unknown encoding");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user