summaryrefslogtreecommitdiff
path: root/include/hash.h
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2014-03-06 16:19:12 +0400
committerSergey Vojtovich <svoj@mariadb.org>2014-03-06 16:19:12 +0400
commitb95c8ce530cbbd92b232324dc2c4376615bd1b5d (patch)
tree60222ef1542c97949e24dcbc4474f5484b86119b /include/hash.h
parentae87e63184a451cd0c9cf95f11f51b78bb40fbc3 (diff)
downloadmariadb-git-b95c8ce530cbbd92b232324dc2c4376615bd1b5d.tar.gz
MDEV-5675 - Performance: my_hash_sort_bin is called too often
Reduced number of my_hash_sort_bin() calls from 4 to 1 per query. Reduced number of memory accesses done by my_hash_sort_bin(). Details: - let MDL subsystem use pre-calculated hash value for hash inserts and deletes - let table cache use pre-calculated MDL hash value - MDL namespace is excluded from hash value calculation, so that hash value can be used by table cache as is - hash value for MDL is calculated as resulting hash value + MDL namespace - extended hash implementation to accept user defined hash function
Diffstat (limited to 'include/hash.h')
-rw-r--r--include/hash.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/hash.h b/include/hash.h
index f014c44c7ec..ba36df23f58 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -44,6 +44,8 @@ extern "C" {
typedef uint my_hash_value_type;
typedef uchar *(*my_hash_get_key)(const uchar *,size_t*,my_bool);
+typedef my_hash_value_type (*my_hash_function)(const CHARSET_INFO *,
+ const uchar *, size_t);
typedef void (*my_hash_free_key)(void *);
typedef my_bool (*my_hash_walk_action)(void *,void *);
@@ -54,6 +56,7 @@ typedef struct st_hash {
uint flags;
DYNAMIC_ARRAY array; /* Place for hash_keys */
my_hash_get_key get_key;
+ my_hash_function hash_function;
void (*free)(void *);
CHARSET_INFO *charset;
} HASH;
@@ -61,10 +64,11 @@ typedef struct st_hash {
/* A search iterator state */
typedef uint HASH_SEARCH_STATE;
-#define my_hash_init(A,B,C,D,E,F,G,H) my_hash_init2(A,0,B,C,D,E,F,G,H)
+#define my_hash_init(A,B,C,D,E,F,G,H) my_hash_init2(A,0,B,C,D,E,F,0,G,H)
my_bool my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
ulong default_array_elements, size_t key_offset,
size_t key_length, my_hash_get_key get_key,
+ my_hash_function hash_function,
void (*free_element)(void*),
uint flags);
void my_hash_free(HASH *tree);
@@ -74,8 +78,9 @@ uchar *my_hash_search(const HASH *info, const uchar *key, size_t length);
uchar *my_hash_search_using_hash_value(const HASH *info,
my_hash_value_type hash_value,
const uchar *key, size_t length);
-my_hash_value_type my_calc_hash(const HASH *info,
+my_hash_value_type my_hash_sort(const CHARSET_INFO *cs,
const uchar *key, size_t length);
+#define my_calc_hash(A, B, C) my_hash_sort((A)->charset, B, C)
uchar *my_hash_first(const HASH *info, const uchar *key, size_t length,
HASH_SEARCH_STATE *state);
uchar *my_hash_first_from_hash_value(const HASH *info,