@@ -209,8 +209,6 @@ void hp_movelink(HASH_INFO *pos, HASH_INFO *next_link, HASH_INFO *newlink)
209209 return ;
210210}
211211
212- #ifndef NEW_HASH_FUNCTION
213-
214212/* Calc hashvalue for a key */
215213
216214ulong hp_hashnr (register HP_KEYDEF * keydef , register const uchar * key )
@@ -350,136 +348,6 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec)
350348 return (nr );
351349}
352350
353- #else
354-
355- /*
356- * Fowler/Noll/Vo hash
357- *
358- * The basis of the hash algorithm was taken from an idea sent by email to the
359- * IEEE Posix P1003.2 mailing list from Phong Vo (kpv@research.att.com) and
360- * Glenn Fowler (gsf@research.att.com). Landon Curt Noll (chongo@toad.com)
361- * later improved on their algorithm.
362- *
363- * The magic is in the interesting relationship between the special prime
364- * 16777619 (2^24 + 403) and 2^32 and 2^8.
365- *
366- * This hash produces the fewest collisions of any function that we've seen so
367- * far, and works well on both numbers and strings.
368- */
369-
370- ulong hp_hashnr (register HP_KEYDEF * keydef , register const uchar * key )
371- {
372- /*
373- Note, if a key consists of a combination of numeric and
374- a text columns, it most likely won't work well.
375- Making text columns work with NEW_HASH_FUNCTION
376- needs also changes in strings/ctype-xxx.c.
377- */
378- ulong nr = 1 , nr2 = 4 ;
379- HA_KEYSEG * seg ,* endseg ;
380-
381- for (seg = keydef -> seg ,endseg = seg + keydef -> keysegs ; seg < endseg ; seg ++ )
382- {
383- uchar * pos = (uchar * ) key ;
384- key += seg -> length ;
385- if (seg -> null_bit )
386- {
387- key ++ ;
388- if (* pos )
389- {
390- nr ^= (nr << 1 ) | 1 ;
391- /* Add key pack length (2) to key for VARCHAR segments */
392- if (seg -> type == HA_KEYTYPE_VARTEXT1 )
393- key += 2 ;
394- continue ;
395- }
396- pos ++ ;
397- }
398- if (seg -> type == HA_KEYTYPE_TEXT )
399- {
400- seg -> charset -> coll -> hash_sort (seg -> charset , pos , ((uchar * )key )- pos ,
401- & nr , & nr2 );
402- }
403- else if (seg -> type == HA_KEYTYPE_VARTEXT1 ) /* Any VARCHAR segments */
404- {
405- uint pack_length = 2 ; /* Key packing is constant */
406- uint length = uint2korr (pos );
407- seg -> charset -> coll -> hash_sort (seg -> charset , pos + pack_length , length ,
408- & nr , & nr2 );
409- key += pack_length ;
410- }
411- else
412- {
413- for ( ; pos < (uchar * ) key ; pos ++ )
414- {
415- nr *=16777619 ;
416- nr ^=(uint ) * pos ;
417- }
418- }
419- }
420- #ifdef ONLY_FOR_HASH_DEBUGGING
421- DBUG_PRINT ("exit" , ("hash: 0x%lx" , nr ));
422- #endif
423- return (nr );
424- }
425-
426- /* Calc hashvalue for a key in a record */
427-
428- ulong hp_rec_hashnr (register HP_KEYDEF * keydef , register const uchar * rec )
429- {
430- ulong nr = 1 , nr2 = 4 ;
431- HA_KEYSEG * seg ,* endseg ;
432-
433- for (seg = keydef -> seg ,endseg = seg + keydef -> keysegs ; seg < endseg ; seg ++ )
434- {
435- uchar * pos = (uchar * ) rec + seg -> start ;
436- if (seg -> null_bit )
437- {
438- if (rec [seg -> null_pos ] & seg -> null_bit )
439- {
440- nr ^= (nr << 1 ) | 1 ;
441- continue ;
442- }
443- }
444- if (seg -> type == HA_KEYTYPE_TEXT )
445- {
446- uint char_length = seg -> length ; /* TODO: fix to use my_charpos() */
447- seg -> charset -> coll -> hash_sort (seg -> charset , pos , char_length ,
448- & nr , & nr2 );
449- }
450- else if (seg -> type == HA_KEYTYPE_VARTEXT1 ) /* Any VARCHAR segments */
451- {
452- uint pack_length = seg -> bit_start ;
453- uint length = (pack_length == 1 ? (uint ) * (uchar * ) pos : uint2korr (pos ));
454- seg -> charset -> coll -> hash_sort (seg -> charset , pos + pack_length ,
455- length , & nr , & nr2 );
456- }
457- else
458- {
459- uchar * end = pos + seg -> length ;
460- if (seg -> type == HA_KEYTYPE_BIT && seg -> bit_length )
461- {
462- uchar bits = get_rec_bits (rec + seg -> bit_pos ,
463- seg -> bit_start , seg -> bit_length );
464- nr *=16777619 ;
465- nr ^=(uint ) bits ;
466- end -- ;
467- }
468- for ( ; pos < end ; pos ++ )
469- {
470- nr *=16777619 ;
471- nr ^=(uint ) * pos ;
472- }
473- }
474- }
475- #ifdef ONLY_FOR_HASH_DEBUGGING
476- DBUG_PRINT ("exit" , ("hash: 0x%lx" , nr ));
477- #endif
478- return (nr );
479- }
480-
481- #endif
482-
483351
484352/*
485353 Compare keys for two records. Returns 0 if they are identical
0 commit comments