- keyobj = createStringObject((char*)key,klen);
- valobj = createStringObject((char*)val,vlen);
- keyobj = tryObjectEncoding(keyobj);
- valobj = tryObjectEncoding(valobj);
- dictAdd(dict,keyobj,valobj);
+ } else if (enc == REDIS_ENCODING_HT) {
+ hashTypeIterator *hi;
+ dict *dict;
+ int ret;
+
+ hi = hashTypeInitIterator(o);
+ dict = dictCreate(&hashDictType, NULL);
+
+ while (hashTypeNext(hi) != REDIS_ERR) {
+ robj *field, *value;
+
+ field = hashTypeCurrentObject(hi, REDIS_HASH_KEY);
+ field = tryObjectEncoding(field);
+ value = hashTypeCurrentObject(hi, REDIS_HASH_VALUE);
+ value = tryObjectEncoding(value);
+ ret = dictAdd(dict, field, value);
+ redisAssert(ret == DICT_OK);
+ }
+
+ hashTypeReleaseIterator(hi);
+ zfree(o->ptr);
+
+ o->encoding = REDIS_ENCODING_HT;
+ o->ptr = dict;
+
+ } else {
+ redisPanic("Unknown hash encoding");
+ }
+}
+
+void hashTypeConvert(robj *o, int enc) {
+ if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ hashTypeConvertZiplist(o, enc);
+ } else if (o->encoding == REDIS_ENCODING_HT) {
+ redisPanic("Not implemented");
+ } else {
+ redisPanic("Unknown hash encoding");