Commit 2a1198b4 authored by antirez's avatar antirez
Browse files

HDEL fix, an optimization for comparison of objects in hash table lookups when...

HDEL fix, an optimization for comparison of objects in hash table lookups when they are integer encoding
parent a4c50786
......@@ -1005,6 +1005,10 @@ static int dictEncObjKeyCompare(void *privdata, const void *key1,
robj *o1 = (robj*) key1, *o2 = (robj*) key2;
int cmp;
if (o1->encoding == REDIS_ENCODING_INT &&
o2->encoding == REDIS_ENCODING_INT &&
o1->ptr == o2->ptr) return 0;
o1 = getDecodedObject(o1);
o2 = getDecodedObject(o2);
cmp = sdsDictKeyCompare(privdata,o1->ptr,o2->ptr);
......@@ -5943,9 +5947,12 @@ static void hdelCommand(redisClient *c) {
checkType(c,o,REDIS_HASH)) return;
if (o->encoding == REDIS_ENCODING_ZIPMAP) {
robj *field = getDecodedObject(c->argv[2]);
o->ptr = zipmapDel((unsigned char*) o->ptr,
(unsigned char*) c->argv[2]->ptr,
sdslen(c->argv[2]->ptr), &deleted);
(unsigned char*) field->ptr,
sdslen(field->ptr), &deleted);
decrRefCount(field);
} else {
deleted = dictDelete((dict*)o->ptr,c->argv[2]) == DICT_OK;
}
......
......@@ -125,6 +125,7 @@ proc randomKey {} {
proc createComplexDataset {r ops} {
for {set j 0} {$j < $ops} {incr j} {
set k [randomKey]
set f [randomValue]
set v [randomValue]
randpath {
set d [expr {rand()}]
......@@ -150,6 +151,8 @@ proc createComplexDataset {r ops} {
$r sadd $k $v
} {
$r zadd $k $d $v
} {
$r hset $k $f $v
}
set t [$r type $k]
}
......@@ -173,6 +176,10 @@ proc createComplexDataset {r ops} {
randpath {$r zadd $k $d $v} \
{$r zrem $k $v}
}
{hash} {
randpath {$r hset $k $f $v} \
{$r hdel $k $f}
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment