From f8956ed6d88fde242de8676dd615019b2c7e734e Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 28 Feb 2011 16:55:34 +0100 Subject: [PATCH] convert the zipmap into hash in rdb loading if the zipmap has too many elements --- src/rdb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rdb.c b/src/rdb.c index 141354804..60a70e01e 100644 --- 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"); } -- GitLab