@@ -33,16 +33,18 @@ typedef struct st_hash_info {
3333 uchar * data ; /* data for current entry */
3434} HASH_LINK ;
3535
36- static uint my_hash_mask (size_t hashnr , size_t buffmax , size_t maxlength );
36+ static uint my_hash_mask (my_hash_value_type hashnr ,
37+ size_t buffmax , size_t maxlength );
3738static void movelink (HASH_LINK * array ,uint pos ,uint next_link ,uint newlink );
3839static int hashcmp (const HASH * hash , HASH_LINK * pos , const uchar * key ,
3940 size_t length );
4041
41- static uint calc_hash (const HASH * hash , const uchar * key , size_t length )
42+ static my_hash_value_type calc_hash (const HASH * hash ,
43+ const uchar * key , size_t length )
4244{
4345 ulong nr1 = 1 , nr2 = 4 ;
4446 hash -> charset -> coll -> hash_sort (hash -> charset ,(uchar * ) key ,length ,& nr1 ,& nr2 );
45- return nr1 ;
47+ return ( my_hash_value_type ) nr1 ;
4648}
4749
4850/**
@@ -179,7 +181,8 @@ my_hash_key(const HASH *hash, const uchar *record, size_t *length,
179181
180182 /* Calculate pos according to keys */
181183
182- static uint my_hash_mask (size_t hashnr , size_t buffmax , size_t maxlength )
184+ static uint my_hash_mask (my_hash_value_type hashnr , size_t buffmax ,
185+ size_t maxlength )
183186{
184187 if ((hashnr & (buffmax - 1 )) < maxlength ) return (hashnr & (buffmax - 1 ));
185188 return (hashnr & ((buffmax >> 1 ) - 1 ));
@@ -200,7 +203,7 @@ static
200203#if !defined(__USLC__ ) && !defined(__sgi )
201204inline
202205#endif
203- unsigned int rec_hashnr (HASH * hash ,const uchar * record )
206+ my_hash_value_type rec_hashnr (HASH * hash ,const uchar * record )
204207{
205208 size_t length ;
206209 uchar * key = (uchar * ) my_hash_key (hash , record , & length , 0 );
@@ -214,6 +217,21 @@ uchar* my_hash_search(const HASH *hash, const uchar *key, size_t length)
214217 return my_hash_first (hash , key , length , & state );
215218}
216219
220+ uchar * my_hash_search_using_hash_value (const HASH * hash ,
221+ my_hash_value_type hash_value ,
222+ const uchar * key ,
223+ size_t length )
224+ {
225+ HASH_SEARCH_STATE state ;
226+ return my_hash_first_from_hash_value (hash , hash_value ,
227+ key , length , & state );
228+ }
229+
230+ my_hash_value_type my_calc_hash (const HASH * hash ,
231+ const uchar * key , size_t length )
232+ {
233+ return calc_hash (hash , key , length ? length : hash -> key_length );
234+ }
217235/*
218236 Search after a record based on a key
219237
@@ -223,15 +241,26 @@ uchar* my_hash_search(const HASH *hash, const uchar *key, size_t length)
223241
224242uchar * my_hash_first (const HASH * hash , const uchar * key , size_t length ,
225243 HASH_SEARCH_STATE * current_record )
244+ {
245+ return my_hash_first_from_hash_value (hash ,
246+ calc_hash (hash , key , length ? length : hash -> key_length ),
247+ key , length , current_record );
248+ }
249+
250+ uchar * my_hash_first_from_hash_value (const HASH * hash ,
251+ my_hash_value_type hash_value ,
252+ const uchar * key ,
253+ size_t length ,
254+ HASH_SEARCH_STATE * current_record )
226255{
227256 HASH_LINK * pos ;
228257 uint flag ,idx ;
229- DBUG_ENTER ("my_hash_first " );
258+ DBUG_ENTER ("my_hash_first_from_hash_value " );
230259
231260 flag = 1 ;
232261 if (hash -> records )
233262 {
234- idx = my_hash_mask (calc_hash ( hash , key , length ? length : hash -> key_length ) ,
263+ idx = my_hash_mask (hash_value ,
235264 hash -> blength , hash -> records );
236265 do
237266 {
@@ -331,7 +360,8 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key,
331360my_bool my_hash_insert (HASH * info , const uchar * record )
332361{
333362 int flag ;
334- size_t idx ,halfbuff ,hash_nr ,first_index ;
363+ size_t idx ,halfbuff ,first_index ;
364+ my_hash_value_type hash_nr ;
335365 uchar * UNINIT_VAR (ptr_to_rec ),* UNINIT_VAR (ptr_to_rec2 );
336366 HASH_LINK * data ,* empty ,* UNINIT_VAR (gpos ),* UNINIT_VAR (gpos2 ),* pos ;
337367
@@ -467,7 +497,8 @@ my_bool my_hash_insert(HASH *info, const uchar *record)
467497
468498my_bool my_hash_delete (HASH * hash , uchar * record )
469499{
470- uint blength ,pos2 ,pos_hashnr ,lastpos_hashnr ,idx ,empty_index ;
500+ uint blength ,pos2 ,idx ,empty_index ;
501+ my_hash_value_type pos_hashnr , lastpos_hashnr ;
471502 HASH_LINK * data ,* lastpos ,* gpos ,* pos ,* pos3 ,* empty ;
472503 DBUG_ENTER ("my_hash_delete" );
473504 if (!hash -> records )
0 commit comments