mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Use RDB_LOAD_PLAIN to load quicklists and encoded types.
Before we needed to create a string object with an embedded SDS, adn basically duplicate the SDS part into a plain zmalloc() allocation.
This commit is contained in:
parent
68bc02c36c
commit
f699b5e801
14
src/rdb.c
14
src/rdb.c
@ -1041,12 +1041,8 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
|
|||||||
server.list_compress_depth);
|
server.list_compress_depth);
|
||||||
|
|
||||||
while (len--) {
|
while (len--) {
|
||||||
if ((ele = rdbLoadStringObject(rdb)) == NULL) return NULL;
|
unsigned char *zl = rdbGenericLoadStringObject(rdb,RDB_LOAD_PLAIN);
|
||||||
/* 'ele' contains a sds of the ziplist, but we need to extract
|
if (zl == NULL) return NULL;
|
||||||
* the actual ziplist for future usage. We must copy the
|
|
||||||
* sds contents to a new buffer. */
|
|
||||||
unsigned char *zl = (unsigned char *)sdsnative(ele->ptr);
|
|
||||||
zfree(ele); /* free robj container since we keep the ziplist */
|
|
||||||
quicklistAppendZiplist(o->ptr, zl);
|
quicklistAppendZiplist(o->ptr, zl);
|
||||||
}
|
}
|
||||||
} else if (rdbtype == REDIS_RDB_TYPE_HASH_ZIPMAP ||
|
} else if (rdbtype == REDIS_RDB_TYPE_HASH_ZIPMAP ||
|
||||||
@ -1055,9 +1051,9 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
|
|||||||
rdbtype == REDIS_RDB_TYPE_ZSET_ZIPLIST ||
|
rdbtype == REDIS_RDB_TYPE_ZSET_ZIPLIST ||
|
||||||
rdbtype == REDIS_RDB_TYPE_HASH_ZIPLIST)
|
rdbtype == REDIS_RDB_TYPE_HASH_ZIPLIST)
|
||||||
{
|
{
|
||||||
o = rdbLoadStringObject(rdb);
|
unsigned char *encoded = rdbGenericLoadStringObject(rdb,RDB_LOAD_PLAIN);
|
||||||
if (o == NULL) return NULL;
|
if (encoded == NULL) return NULL;
|
||||||
o->ptr = sdsnative(o->ptr);
|
o = createObject(REDIS_STRING,encoded); /* Obj type fixed below. */
|
||||||
|
|
||||||
/* Fix the object encoding, and make sure to convert the encoded
|
/* Fix the object encoding, and make sure to convert the encoded
|
||||||
* data type into the base type if accordingly to the current
|
* data type into the base type if accordingly to the current
|
||||||
|
Loading…
x
Reference in New Issue
Block a user