summaryrefslogtreecommitdiff
path: root/mysys/lf_hash.c
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2014-12-28 19:42:17 +0400
committerSergey Vojtovich <svoj@mariadb.org>2014-12-28 19:46:18 +0400
commit6dbc48ca79e5fdd8d4022b00b862e08a4198155b (patch)
tree1904e477f09dd958af2b6696d4b7c8dbb0a1772d /mysys/lf_hash.c
parent8883c54ac08a555bc7d9b09395f49893ad4d80b5 (diff)
downloadmariadb-git-6dbc48ca79e5fdd8d4022b00b862e08a4198155b.tar.gz
MDEV-7324 - Lock-free hash for table definition cache
Diffstat (limited to 'mysys/lf_hash.c')
-rw-r--r--mysys/lf_hash.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c
index 782ebc00f24..53860bea49d 100644
--- a/mysys/lf_hash.c
+++ b/mysys/lf_hash.c
@@ -122,7 +122,7 @@ retry:
{
if (unlikely(callback))
{
- if (callback(cursor->curr + 1, (void*)key))
+ if (cur_hashnr & 1 && callback(cursor->curr + 1, (void*)key))
return 1;
}
else if (cur_hashnr >= hashnr)
@@ -467,12 +467,13 @@ int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
NOTE
see lsearch() for pin usage notes
*/
-void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
+void *lf_hash_search_using_hash_value(LF_HASH *hash, LF_PINS *pins,
+ my_hash_value_type hashnr,
+ const void *key, uint keylen)
{
LF_SLIST * volatile *el, *found;
- uint bucket, hashnr= calc_hash(hash, (uchar *)key, keylen);
+ uint bucket= hashnr % hash->size;
- bucket= hashnr % hash->size;
lf_rwlock_by_pins(pins);
el= _lf_dynarray_lvalue(&hash->array, bucket);
if (unlikely(!el))
@@ -521,6 +522,13 @@ int lf_hash_iterate(LF_HASH *hash, LF_PINS *pins,
return res;
}
+void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
+{
+ return lf_hash_search_using_hash_value(hash, pins,
+ calc_hash(hash, (uchar*) key, keylen),
+ key, keylen);
+}
+
static const uchar *dummy_key= (uchar*)"";
/*