]> git.saurik.com Git - redis.git/blobdiff - src/rdb.c
convert the zipmap into hash in rdb loading if the zipmap has too many elements
[redis.git] / src / rdb.c
index 1413548045a58ef8d66f6a9918fb752f2618a850..60a70e01eb72f35b8d4e40739a2fb51ac56776fb 100644 (file)
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -838,7 +838,12 @@ robj *rdbLoadObject(int type, FILE *fp) {
         o->ptr = zmalloc(sdslen(aux->ptr));
         memcpy(o->ptr,aux->ptr,sdslen(aux->ptr));
         decrRefCount(aux);
-        /* FIXME: conver the object if needed */
+        /* Convert to real hash if the number of items is too large.
+         * We don't check the max item size as this requires an O(N)
+         * scan usually. */
+        if (zipmapLen(o->ptr) > server.hash_max_zipmap_entries) {
+            convertToRealHash(o);
+        }
     } else {
         redisPanic("Unknown object type");
     }