]> git.saurik.com Git - redis.git/blobdiff - src/t_hash.c
some RDB server struct fields renamed.
[redis.git] / src / t_hash.c
index 83ca5b2754c3fce9d9e9bede7e1a1d95e90ba7f2..8ee5485c1ad86f877d6f24e6bce98ca461f7f172 100644 (file)
@@ -55,7 +55,7 @@ int hashTypeGet(robj *o, robj *key, robj **objval, unsigned char **v,
     } else {
         dictEntry *de = dictFind(o->ptr,key);
         if (de == NULL) return -1;
-        *objval = dictGetEntryVal(de);
+        *objval = dictGetVal(de);
     }
     return o->encoding;
 }
@@ -160,7 +160,7 @@ hashTypeIterator *hashTypeInitIterator(robj *subject) {
     } else if (hi->encoding == REDIS_ENCODING_HT) {
         hi->di = dictGetIterator(subject->ptr);
     } else {
-        redisAssert(NULL);
+        redisAssertWithInfo(NULL,subject,0);
     }
     return hi;
 }
@@ -206,9 +206,9 @@ int hashTypeCurrent(hashTypeIterator *hi, int what, robj **objval, unsigned char
         }
     } else {
         if (what & REDIS_HASH_KEY)
-            *objval = dictGetEntryKey(hi->de);
+            *objval = dictGetKey(hi->de);
         else
-            *objval = dictGetEntryVal(hi->de);
+            *objval = dictGetVal(hi->de);
     }
     return hi->encoding;
 }
@@ -250,7 +250,7 @@ void convertToRealHash(robj *o) {
     unsigned int klen, vlen;
     dict *dict = dictCreate(&hashDictType,NULL);
 
-    redisAssert(o->type == REDIS_HASH && o->encoding != REDIS_ENCODING_HT);
+    redisAssertWithInfo(NULL,o,o->type == REDIS_HASH && o->encoding != REDIS_ENCODING_HT);
     p = zipmapRewind(zm);
     while((p = zipmapNext(p,&key,&klen,&val,&vlen)) != NULL) {
         robj *keyobj, *valobj;
@@ -346,6 +346,33 @@ void hincrbyCommand(redisClient *c) {
     server.dirty++;
 }
 
+void hincrbyfloatCommand(redisClient *c) {
+    double long value, incr;
+    robj *o, *current, *new;
+
+    if (getLongDoubleFromObjectOrReply(c,c->argv[3],&incr,NULL) != REDIS_OK) return;
+    if ((o = hashTypeLookupWriteOrCreate(c,c->argv[1])) == NULL) return;
+    if ((current = hashTypeGetObject(o,c->argv[2])) != NULL) {
+        if (getLongDoubleFromObjectOrReply(c,current,&value,
+            "hash value is not a valid float") != REDIS_OK) {
+            decrRefCount(current);
+            return;
+        }
+        decrRefCount(current);
+    } else {
+        value = 0;
+    }
+
+    value += incr;
+    new = createStringObjectFromLongDouble(value);
+    hashTypeTryObjectEncoding(o,&c->argv[2],NULL);
+    hashTypeSet(o,c->argv[2],new);
+    addReplyBulk(c,new);
+    decrRefCount(new);
+    signalModifiedKey(c->db,c->argv[1]);
+    server.dirty++;
+}
+
 void hgetCommand(redisClient *c) {
     robj *o, *value;
     unsigned char *v;