diff --git a/src/rdb.h b/src/rdb.h index bf115045..ecb066fb 100644 --- a/src/rdb.h +++ b/src/rdb.h @@ -69,8 +69,9 @@ #define RDB_ENC_INT32 2 /* 32 bit signed integer */ #define RDB_ENC_LZF 3 /* string compressed with FASTLZ */ -/* Dup object types to RDB object types. Only reason is readability (are we - * dealing with RDB types or with in-memory object types?). */ +/* Map object types to RDB object types. Macros starting with OBJ_ are for + * memory storage and may change. Instead RDB types must be fixed because + * we store them on disk. */ #define RDB_TYPE_STRING 0 #define RDB_TYPE_LIST 1 #define RDB_TYPE_SET 2 diff --git a/src/server.h b/src/server.h index 38a76d00..1185d119 100644 --- a/src/server.h +++ b/src/server.h @@ -447,12 +447,11 @@ typedef long long mstime_t; /* millisecond time type. */ /* A redis object, that is a type able to hold a string / list / set */ /* The actual Redis Object */ -#define OBJ_STRING 0 -#define OBJ_LIST 1 -#define OBJ_SET 2 -#define OBJ_ZSET 3 -#define OBJ_HASH 4 -#define OBJ_STREAM 5 +#define OBJ_STRING 0 /* String object. */ +#define OBJ_LIST 1 /* List object. */ +#define OBJ_SET 2 /* Set object. */ +#define OBJ_ZSET 3 /* Sorted set object. */ +#define OBJ_HASH 4 /* Hash object. */ /* The "module" object type is a special one that signals that the object * is one directly managed by a Redis module. In this case the value points @@ -465,7 +464,8 @@ typedef long long mstime_t; /* millisecond time type. */ * by a 64 bit module type ID, which has a 54 bits module-specific signature * in order to dispatch the loading to the right module, plus a 10 bits * encoding version. */ -#define OBJ_MODULE 5 +#define OBJ_MODULE 5 /* Module object. */ +#define OBJ_STREAM 6 /* Stream object. */ /* Extract encver / signature from a module type ID. */ #define REDISMODULE_TYPE_ENCVER_BITS 10 diff --git a/src/t_stream.c b/src/t_stream.c index c64f5059..dcf9fcce 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -149,7 +149,13 @@ void streamAppendItem(stream *s, robj **argv, int numfields, streamID *added_id) memcpy(rax_key,ri.key,sizeof(rax_key)); } - /* Populate the listpack with the new entry. */ + /* Populate the listpack with the new entry. We use the following + * encoding: + * + * +--------+----------+-------+-------+-/-+-------+-------+ + * |entry-id|num-fields|field-1|value-1|...|field-N|value-N| + * +--------+----------+-------+-------+-/-+-------+-------+ + */ lp = lpAppend(lp,(unsigned char*)entry_id,sizeof(entry_id)); lp = lpAppendInteger(lp,numfields); for (int i = 0; i < numfields; i++) {