summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2000-12-29 16:06:10 +0200
committerunknown <monty@donna.mysql.com>2000-12-29 16:06:10 +0200
commit29fa72526a22c31a79c73a00bf7b1974c44ff9d2 (patch)
tree53ef6da34dcfaf79e0e133177cccfb9bb63a9637 /mysys
parentccf4b2829882f566d5665e4ddf7eabcd6d197872 (diff)
downloadmariadb-git-29fa72526a22c31a79c73a00bf7b1974c44ff9d2.tar.gz
Fixed --no-defaults in mysqltest
BUILD/compile-pentium-debug: Use /usr/local/BerkeleyDB-dbug/ if available BUILD/compile-pentium: Use /usr/local/BerkeleyDB-opt/ if available Docs/internals.texi: Added 'unedited' documentation for mysys functions Docs/manual.texi: Cleanups client/mysql.cc: Added client language to status client/mysqltest.c: Fixed bug with --no-defaults heap/_check.c: Added option to print status. heap/hp_close.c: Update to use new status interface heap/hp_hash.c: Clean up hash function and add new experimental hash heap/hp_test1.c: Update to use new status interface heap/hp_test2.c: Update to use new status interface include/heap.h: Update to use new status interface mysql-test/r/key_diff.result: Cleanup tests that may give rows in random order mysql-test/r/type_blob.result: Removed \r from output as this confused bk mysql-test/t/key_diff.test: Cleanup tests that may give rows in random order BitKeeper/etc/ignore: Added Docs/my_sys.doc to the ignore list mysql-test/t/type_blob.test: Removed \r from output as this confused bk mysys/hash.c: Add new experimental hash function scripts/safe_mysqld.sh: Added --mysqld option sql/ha_innobase.cc: Fixed store_locking sql/mysqld.cc: Cleaned up warning messages
Diffstat (limited to 'mysys')
-rw-r--r--mysys/hash.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/mysys/hash.c b/mysys/hash.c
index 9c6497c7717..b366554272a 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -108,6 +108,8 @@ static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax,
return hash_mask((*hash->calc_hashnr)(key,length),buffmax,maxlength);
}
+#ifndef NEW_HASH_FUNCTION
+
/* Calc hashvalue for a key */
static uint calc_hashnr(const byte *key,uint length)
@@ -134,6 +136,49 @@ static uint calc_hashnr_caseup(const byte *key,uint length)
return((uint) nr);
}
+#else
+
+/*
+ * Fowler/Noll/Vo hash
+ *
+ * The basis of the hash algorithm was taken from an idea sent by email to the
+ * IEEE Posix P1003.2 mailing list from Phong Vo (kpv@research.att.com) and
+ * Glenn Fowler (gsf@research.att.com). Landon Curt Noll (chongo@toad.com)
+ * later improved on their algorithm.
+ *
+ * The magic is in the interesting relationship between the special prime
+ * 16777619 (2^24 + 403) and 2^32 and 2^8.
+ *
+ * This hash produces the fewest collisions of any function that we've seen so
+ * far, and works well on both numbers and strings.
+ */
+
+uint calc_hashnr(const byte *key, uint len)
+{
+ const byte *end=key+len;
+ uint hash;
+ for (hash = 0; key < end; key++)
+ {
+ hash *= 16777619;
+ hash ^= (uint) *(uchar*) key;
+ }
+ return (hash);
+}
+
+uint calc_hashnr_caseup(const byte *key, uint len)
+{
+ const byte *end=key+len;
+ uint hash;
+ for (hash = 0; key < end; key++)
+ {
+ hash *= 16777619;
+ hash ^= (uint) (uchar) toupper(*key);
+ }
+ return (hash);
+}
+
+#endif
+
static inline uint rec_hashnr(HASH *hash,const byte *record)
{