From fba96f7ccdd6661caa90ed345c3df2fe35ffdebd Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 14 Jan 2011 11:37:23 +0100 Subject: [PATCH] Added to Aria better hash for packed numeric data for unique handling. This was needed as the old code caused us to have LOTS of duplicate hash values when used by optimizer. include/m_ctype.h: Made my_hash_sort_bin() exernal storage/maria/ma_unique.c: Better hash for packed numeric data for unique handling. This was needed as the old code caused us to have LOTS of duplicate hash values when used by optimizer. --- include/m_ctype.h | 3 +++ storage/maria/ma_unique.c | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/m_ctype.h b/include/m_ctype.h index c2551b5d309..aea560e0740 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -357,6 +357,9 @@ extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, size_t, extern void my_hash_sort_simple(CHARSET_INFO *cs, const uchar *key, size_t len, ulong *nr1, ulong *nr2); +extern void my_hash_sort_bin(CHARSET_INFO *cs, + const uchar *key, size_t len, ulong *nr1, + ulong *nr2); extern size_t my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, size_t length); diff --git a/storage/maria/ma_unique.c b/storage/maria/ma_unique.c index a90578c2162..0c7a2a3cbcf 100644 --- a/storage/maria/ma_unique.c +++ b/storage/maria/ma_unique.c @@ -134,13 +134,14 @@ ha_checksum _ma_unique_hash(MARIA_UNIQUEDEF *def, const uchar *record) keyseg->charset->coll->hash_sort(keyseg->charset, (const uchar*) pos, length, &seed1, &seed2); - crc^= seed1; + crc+= seed1; } else - while (pos != end) - crc=((crc << 8) + - (((uchar) *pos++))) + - (crc >> (8*sizeof(ha_checksum)-8)); + { + my_hash_sort_bin((CHARSET_INFO*) 0, pos, (size_t) (end-pos), + &seed1, &seed2); + crc+= seed1; + } } return crc; }