Commit ccef4cfa authored by Vitaly Arbuzov's avatar Vitaly Arbuzov
Browse files

Use calculateKeySlot instead of getKeySlot in defrag

parent 8a5cf63c
...@@ -679,12 +679,12 @@ void defragKey(redisDb *db, dictEntry *de) { ...@@ -679,12 +679,12 @@ void defragKey(redisDb *db, dictEntry *de) {
/* Try to defrag the key name. */ /* Try to defrag the key name. */
newsds = activeDefragSds(keysds); newsds = activeDefragSds(keysds);
if (newsds) { if (newsds) {
dictSetKey(db->dict[getKeySlot(newsds)], de, newsds); dictSetKey(db->dict[calculateKeySlot(newsds)], de, newsds);
if (dictSize(db->expires)) { if (dictSize(db->expires)) {
/* We can't search in db->expires for that key after we've released /* We can't search in db->expires for that key after we've released
* the pointer it holds, since it won't be able to do the string * the pointer it holds, since it won't be able to do the string
* compare, but we can find the entry using key hash and pointer. */ * compare, but we can find the entry using key hash and pointer. */
uint64_t hash = dictGetHash(db->dict[getKeySlot(newsds)], newsds); uint64_t hash = dictGetHash(db->dict[calculateKeySlot(newsds)], newsds);
dictEntry *expire_de = dictFindEntryByPtrAndHash(db->expires, keysds, hash); dictEntry *expire_de = dictFindEntryByPtrAndHash(db->expires, keysds, hash);
if (expire_de) dictSetKey(db->expires, expire_de, newsds); if (expire_de) dictSetKey(db->expires, expire_de, newsds);
} }
...@@ -693,7 +693,7 @@ void defragKey(redisDb *db, dictEntry *de) { ...@@ -693,7 +693,7 @@ void defragKey(redisDb *db, dictEntry *de) {
/* Try to defrag robj and / or string value. */ /* Try to defrag robj and / or string value. */
ob = dictGetVal(de); ob = dictGetVal(de);
if ((newob = activeDefragStringOb(ob))) { if ((newob = activeDefragStringOb(ob))) {
dictSetVal(db->dict[getKeySlot(newsds)], de, newob); dictSetVal(db->dict[calculateKeySlot(newsds)], de, newob);
ob = newob; ob = newob;
} }
...@@ -851,7 +851,7 @@ int defragLaterStep(redisDb *db, long long endtime) { ...@@ -851,7 +851,7 @@ int defragLaterStep(redisDb *db, long long endtime) {
} }
/* each time we enter this function we need to fetch the key from the dict again (if it still exists) */ /* each time we enter this function we need to fetch the key from the dict again (if it still exists) */
dictEntry *de = dictFind(db->dict[getKeySlot(defrag_later_current_key)], defrag_later_current_key); dictEntry *de = dictFind(db->dict[calculateKeySlot(defrag_later_current_key)], defrag_later_current_key);
key_defragged = server.stat_active_defrag_hits; key_defragged = server.stat_active_defrag_hits;
do { do {
int quit = 0; int quit = 0;
......
...@@ -1340,8 +1340,8 @@ ssize_t rdbSaveDb(rio *rdb, int dbid, int rdbflags, long *key_counter) { ...@@ -1340,8 +1340,8 @@ ssize_t rdbSaveDb(rio *rdb, int dbid, int rdbflags, long *key_counter) {
long long expire; long long expire;
size_t rdb_bytes_before_key = rdb->processed_bytes; size_t rdb_bytes_before_key = rdb->processed_bytes;
initStaticStringObject(key, keystr); initStaticStringObject(key,keystr);
expire = getExpire(db, &key); expire = getExpire(db,&key);
if ((res = rdbSaveKeyValuePair(rdb, &key, o, expire, dbid)) < 0) goto werr; if ((res = rdbSaveKeyValuePair(rdb, &key, o, expire, dbid)) < 0) goto werr;
written += res; written += res;
......
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