mirror of
https://github.com/fluencelabs/redis
synced 2025-03-25 20:01:04 +00:00
HDEL fix, an optimization for comparison of objects in hash table lookups when they are integer encoding
This commit is contained in:
parent
a4c507866c
commit
2a1198b4c4
11
redis.c
11
redis.c
@ -1005,6 +1005,10 @@ static int dictEncObjKeyCompare(void *privdata, const void *key1,
|
|||||||
robj *o1 = (robj*) key1, *o2 = (robj*) key2;
|
robj *o1 = (robj*) key1, *o2 = (robj*) key2;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
|
if (o1->encoding == REDIS_ENCODING_INT &&
|
||||||
|
o2->encoding == REDIS_ENCODING_INT &&
|
||||||
|
o1->ptr == o2->ptr) return 0;
|
||||||
|
|
||||||
o1 = getDecodedObject(o1);
|
o1 = getDecodedObject(o1);
|
||||||
o2 = getDecodedObject(o2);
|
o2 = getDecodedObject(o2);
|
||||||
cmp = sdsDictKeyCompare(privdata,o1->ptr,o2->ptr);
|
cmp = sdsDictKeyCompare(privdata,o1->ptr,o2->ptr);
|
||||||
@ -5943,9 +5947,12 @@ static void hdelCommand(redisClient *c) {
|
|||||||
checkType(c,o,REDIS_HASH)) return;
|
checkType(c,o,REDIS_HASH)) return;
|
||||||
|
|
||||||
if (o->encoding == REDIS_ENCODING_ZIPMAP) {
|
if (o->encoding == REDIS_ENCODING_ZIPMAP) {
|
||||||
|
robj *field = getDecodedObject(c->argv[2]);
|
||||||
|
|
||||||
o->ptr = zipmapDel((unsigned char*) o->ptr,
|
o->ptr = zipmapDel((unsigned char*) o->ptr,
|
||||||
(unsigned char*) c->argv[2]->ptr,
|
(unsigned char*) field->ptr,
|
||||||
sdslen(c->argv[2]->ptr), &deleted);
|
sdslen(field->ptr), &deleted);
|
||||||
|
decrRefCount(field);
|
||||||
} else {
|
} else {
|
||||||
deleted = dictDelete((dict*)o->ptr,c->argv[2]) == DICT_OK;
|
deleted = dictDelete((dict*)o->ptr,c->argv[2]) == DICT_OK;
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,7 @@ proc randomKey {} {
|
|||||||
proc createComplexDataset {r ops} {
|
proc createComplexDataset {r ops} {
|
||||||
for {set j 0} {$j < $ops} {incr j} {
|
for {set j 0} {$j < $ops} {incr j} {
|
||||||
set k [randomKey]
|
set k [randomKey]
|
||||||
|
set f [randomValue]
|
||||||
set v [randomValue]
|
set v [randomValue]
|
||||||
randpath {
|
randpath {
|
||||||
set d [expr {rand()}]
|
set d [expr {rand()}]
|
||||||
@ -150,6 +151,8 @@ proc createComplexDataset {r ops} {
|
|||||||
$r sadd $k $v
|
$r sadd $k $v
|
||||||
} {
|
} {
|
||||||
$r zadd $k $d $v
|
$r zadd $k $d $v
|
||||||
|
} {
|
||||||
|
$r hset $k $f $v
|
||||||
}
|
}
|
||||||
set t [$r type $k]
|
set t [$r type $k]
|
||||||
}
|
}
|
||||||
@ -173,6 +176,10 @@ proc createComplexDataset {r ops} {
|
|||||||
randpath {$r zadd $k $d $v} \
|
randpath {$r zadd $k $d $v} \
|
||||||
{$r zrem $k $v}
|
{$r zrem $k $v}
|
||||||
}
|
}
|
||||||
|
{hash} {
|
||||||
|
randpath {$r hset $k $f $v} \
|
||||||
|
{$r hdel $k $f}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user