mirror of
https://github.com/fluencelabs/redis
synced 2025-06-12 16:51:22 +00:00
Streams: RDB saving.
This commit is contained in:
22
src/rdb.c
22
src/rdb.c
@ -31,6 +31,7 @@
|
||||
#include "lzf.h" /* LZF compression library */
|
||||
#include "zipmap.h"
|
||||
#include "endianconv.h"
|
||||
#include "stream.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <sys/types.h>
|
||||
@ -622,6 +623,8 @@ int rdbSaveObjectType(rio *rdb, robj *o) {
|
||||
return rdbSaveType(rdb,RDB_TYPE_HASH);
|
||||
else
|
||||
serverPanic("Unknown hash encoding");
|
||||
case OBJ_STREAM:
|
||||
return rdbSaveType(rdb,RDB_TYPE_STREAM_LISTPACKS);
|
||||
case OBJ_MODULE:
|
||||
return rdbSaveType(rdb,RDB_TYPE_MODULE_2);
|
||||
default:
|
||||
@ -762,7 +765,26 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
|
||||
} else {
|
||||
serverPanic("Unknown hash encoding");
|
||||
}
|
||||
} else if (o->type == OBJ_STREAM) {
|
||||
/* Store how many listpacks we have inside the radix tree. */
|
||||
stream *s = o->ptr;
|
||||
rax *rax = s->rax;
|
||||
if ((n = rdbSaveLen(rdb,raxSize(rax))) == -1) return -1;
|
||||
nwritten += n;
|
||||
|
||||
/* Serialize all the listpacks inside the radix tree as they are,
|
||||
* when loading back, we'll use the first entry of each listpack
|
||||
* to insert it back into the radix tree. */
|
||||
raxIterator ri;
|
||||
raxStart(&ri,rax);
|
||||
raxSeek(&ri,"^",NULL,0);
|
||||
while (raxNext(&ri)) {
|
||||
unsigned char *lp = ri.data;
|
||||
size_t lp_bytes = lpBytes(lp);
|
||||
if ((n = rdbSaveRawString(rdb,lp,lp_bytes)) == -1) return -1;
|
||||
nwritten += n;
|
||||
}
|
||||
raxStop(&ri);
|
||||
} else if (o->type == OBJ_MODULE) {
|
||||
/* Save a module-specific value. */
|
||||
RedisModuleIO io;
|
||||
|
Reference in New Issue
Block a user