Permalink
Browse files

Welp, I completely forgot to actually include *loading* the AVL tree …

…from RDB.
  • Loading branch information...
1 parent f114a2f commit bc0a40ab803f4c8e47a350f5a06a1298d9567e09 @hoxworth committed Jun 8, 2012
Showing with 34 additions and 0 deletions.
  1. +34 −0 src/rdb.c
View
@@ -915,6 +915,40 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
/* All pairs should be read by now */
redisAssert(len == 0);
+ } else if (rdbtype == REDIS_RDB_TYPE_ISET) {
+ /* Read list/set value */
+
+ size_t isetlen;
+ avl * tree;
+ size_t maxelelen = 0;
+
+ if ((isetlen = rdbLoadLen(rdb,NULL)) == REDIS_RDB_LENERR) return NULL;
+ o = createIsetObject();
+ tree = o->ptr;
+
+ /* Load every single element of the list/set */
+ while(isetlen--) {
+ robj *ele;
+ double score1;
+ double score2;
+
+ avlNode *inode;
+
+ if ((ele = rdbLoadEncodedStringObject(rdb)) == NULL) return NULL;
+ ele = tryObjectEncoding(ele);
+ if (rdbLoadDoubleValue(rdb,&score1) == -1) return NULL;
+ if (rdbLoadDoubleValue(rdb,&score2) == -1) return NULL;
+
+ /* Don't care about integer-encoded strings. */
+ if (ele->encoding == REDIS_ENCODING_RAW &&
+ sdslen(ele->ptr) > maxelelen)
+ maxelelen = sdslen(ele->ptr);
+
+ inode = avlInsert(tree, score1, score2, ele);
+ dictAdd(tree->dict,ele,&inode->scores);
+ incrRefCount(ele); /* Added to dictionary. */
+ }
+
} else if (rdbtype == REDIS_RDB_TYPE_HASH_ZIPMAP ||
rdbtype == REDIS_RDB_TYPE_LIST_ZIPLIST ||
rdbtype == REDIS_RDB_TYPE_SET_INTSET ||

2 comments on commit bc0a40a

@llimllib
Collaborator

@hoxworth
Owner

I really do like these. Keep them coming.

Please sign in to comment.