Streams: assign value of 6 to OBJ_STREAM + some refactoring.

This commit is contained in:
antirez 2017-09-05 12:13:16 +02:00
parent 79866a6361
commit 100d43c1ac
3 changed files with 17 additions and 10 deletions

View File

@ -69,8 +69,9 @@
#define RDB_ENC_INT32 2 /* 32 bit signed integer */ #define RDB_ENC_INT32 2 /* 32 bit signed integer */
#define RDB_ENC_LZF 3 /* string compressed with FASTLZ */ #define RDB_ENC_LZF 3 /* string compressed with FASTLZ */
/* Dup object types to RDB object types. Only reason is readability (are we /* Map object types to RDB object types. Macros starting with OBJ_ are for
* dealing with RDB types or with in-memory object types?). */ * 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_STRING 0
#define RDB_TYPE_LIST 1 #define RDB_TYPE_LIST 1
#define RDB_TYPE_SET 2 #define RDB_TYPE_SET 2

View File

@ -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 */ /* A redis object, that is a type able to hold a string / list / set */
/* The actual Redis Object */ /* The actual Redis Object */
#define OBJ_STRING 0 #define OBJ_STRING 0 /* String object. */
#define OBJ_LIST 1 #define OBJ_LIST 1 /* List object. */
#define OBJ_SET 2 #define OBJ_SET 2 /* Set object. */
#define OBJ_ZSET 3 #define OBJ_ZSET 3 /* Sorted set object. */
#define OBJ_HASH 4 #define OBJ_HASH 4 /* Hash object. */
#define OBJ_STREAM 5
/* The "module" object type is a special one that signals that the 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 * 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 * 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 * in order to dispatch the loading to the right module, plus a 10 bits
* encoding version. */ * 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. */ /* Extract encver / signature from a module type ID. */
#define REDISMODULE_TYPE_ENCVER_BITS 10 #define REDISMODULE_TYPE_ENCVER_BITS 10

View File

@ -149,7 +149,13 @@ void streamAppendItem(stream *s, robj **argv, int numfields, streamID *added_id)
memcpy(rax_key,ri.key,sizeof(rax_key)); 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 = lpAppend(lp,(unsigned char*)entry_id,sizeof(entry_id));
lp = lpAppendInteger(lp,numfields); lp = lpAppendInteger(lp,numfields);
for (int i = 0; i < numfields; i++) { for (int i = 0; i < numfields; i++) {