Move hash_sort and hash_caseup into CHARSET_INFO for all charsets

This commit is contained in:
unknown 2002-10-10 16:52:22 +05:00
parent b9bb3534f1
commit 72174d5b82
16 changed files with 132 additions and 126 deletions

View File

@ -214,18 +214,7 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key)
}
if (seg->type == HA_KEYTYPE_TEXT)
{
if (seg->charset->hash_sort)
seg->charset->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,&nr2);
else
{
register uchar *sort_order=seg->charset->sort_order;
for (; pos < (uchar*) key ; pos++)
{
nr^=(ulong) ((((uint) nr & 63)+nr2) *
((uint) sort_order[(uint) *pos])) + (nr << 8);
nr2+=3;
}
}
seg->charset->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,&nr2);
}
else
{
@ -260,19 +249,7 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec)
}
if (seg->type == HA_KEYTYPE_TEXT)
{
if (seg->charset->hash_sort)
seg->charset->hash_sort(seg->charset,pos,end-pos,&nr,&nr2);
else
{
register uchar *sort_order=seg->charset->sort_order;
for (; pos < end ; pos++)
{
nr^=(ulong) ((((uint) nr & 63)+nr2)*
((uint) sort_order[(uint) *pos]))+ (nr << 8);
nr2+=3;
}
}
seg->charset->hash_sort(seg->charset,pos,end-pos,&nr,&nr2);
}
else
{

View File

@ -126,6 +126,14 @@ extern my_bool init_compiled_charsets(myf flags);
extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, uint);
extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, const uchar *, uint);
extern uint my_hash_caseup_simple(CHARSET_INFO *cs,
const byte *key, uint len);
extern void my_hash_sort_simple(CHARSET_INFO *cs,
const uchar *key, uint len,
ulong *nr1, ulong *nr2);
/* Functions for 8bit */
extern void my_caseup_str_8bit(CHARSET_INFO *, char *);
extern void my_casedn_str_8bit(CHARSET_INFO *, char *);

View File

@ -386,6 +386,8 @@ static CHARSET_INFO *add_charset(CHARSET_INFO *cs, myf flags)
cs->strncasecmp = my_strncasecmp_8bit;
cs->mb_wc = my_mb_wc_8bit;
cs->wc_mb = my_wc_mb_8bit;
cs->hash_caseup = my_hash_caseup_simple;
cs->hash_sort = my_hash_sort_simple;
set_max_sort_char(cs);
create_fromuni(cs);

View File

@ -32,7 +32,6 @@
static uint hash_mask(uint hashnr,uint buffmax,uint maxlength);
static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink);
static uint calc_hashnr(CHARSET_INFO *cs,const byte *key,uint length);
static uint calc_hashnr_caseup(CHARSET_INFO *cs, const byte *key,uint length);
static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length);
@ -60,12 +59,7 @@ _hash_init(HASH *hash,CHARSET_INFO *charset,
hash->flags=flags;
hash->charset=charset;
if (flags & HASH_CASE_INSENSITIVE)
{
if (charset->hash_caseup)
hash->calc_hashnr=charset->hash_caseup;
else
hash->calc_hashnr=calc_hashnr_caseup;
}
hash->calc_hashnr=charset->hash_caseup;
else
hash->calc_hashnr=calc_hashnr;
DBUG_RETURN(0);
@ -132,22 +126,6 @@ static uint calc_hashnr(CHARSET_INFO *cs __attribute__((unused)),
return((uint) nr);
}
/* Calc hashvalue for a key, case indepenently */
static uint calc_hashnr_caseup(CHARSET_INFO *cs, const byte *key,uint length)
{
register uint nr=1, nr2=4;
register uchar *map=cs->to_upper;
while (length--)
{
nr^= (((nr & 63)+nr2)*
((uint) (uchar) map[(uchar)*key++])) + (nr << 8);
nr2+=3;
}
return((uint) nr);
}
#else
/*
@ -175,18 +153,6 @@ uint calc_hashnr(CHARSET_INFO *cs, const byte *key, uint len)
return (hash);
}
uint calc_hashnr_caseup(CHARSET_INFO *cs, const byte *key, uint len)
{
const byte *end=key+len;
uint hash;
for (hash = 0; key < end; key++)
{
hash *= 16777619;
hash ^= (uint) (uchar) my_toupper(cs,*key);
}
return (hash);
}
#endif

View File

@ -6245,8 +6245,8 @@ CHARSET_INFO my_charset_big5 =
NULL, /* tosort */
my_strcasecmp_mb,
my_strncasecmp_mb,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
};

View File

@ -623,8 +623,8 @@ CHARSET_INFO my_charset_czech =
NULL, /* tosort */
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
};

View File

@ -8662,8 +8662,8 @@ CHARSET_INFO my_charset_euc_kr =
my_tosort_8bit,
my_strcasecmp_mb,
my_strncasecmp_mb,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
};

View File

@ -5712,8 +5712,8 @@ CHARSET_INFO my_charset_gb2312 =
my_tosort_8bit,
my_strcasecmp_mb,
my_strncasecmp_mb,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
};

View File

@ -9900,8 +9900,8 @@ CHARSET_INFO my_charset_gbk =
NULL, /* tosort */
my_strcasecmp_mb,
my_strncasecmp_mb,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
};

View File

@ -441,8 +441,8 @@ CHARSET_INFO my_charset_latin1_de =
NULL, /* tosort */
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
};

View File

@ -118,3 +118,56 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc,
}
return MY_CS_ILUNI;
}
#ifndef NEW_HASH_FUNCTION
/* Calc hashvalue for a key, case indepenently */
uint my_hash_caseup_simple(CHARSET_INFO *cs, const byte *key, uint length)
{
register uint nr=1, nr2=4;
register uchar *map=cs->to_upper;
while (length--)
{
nr^= (((nr & 63)+nr2)*
((uint) (uchar) map[(uchar)*key++])) + (nr << 8);
nr2+=3;
}
return((uint) nr);
}
#else
uint my_hash_caseup_simple(CHARSET_INFO *cs, const byte *key, uint len)
{
const byte *end=key+len;
uint hash;
for (hash = 0; key < end; key++)
{
hash *= 16777619;
hash ^= (uint) (uchar) my_toupper(cs,*key);
}
return (hash);
}
#endif
void my_hash_sort_simple(CHARSET_INFO *cs,
const uchar *key, uint len,
ulong *nr1, ulong *nr2)
{
register uchar *sort_order=cs->sort_order;
const uchar *pos = key;
key+= len;
for (; pos < (uchar*) key ; pos++)
{
nr1[0]^=(ulong) ((((uint) nr1[0] & 63)+nr2[0]) *
((uint) sort_order[(uint) *pos])) + (nr1[0] << 8);
nr2[0]+=3;
}
}

View File

@ -4487,8 +4487,8 @@ CHARSET_INFO my_charset_sjis =
NULL, /* tosort */
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
};

View File

@ -715,8 +715,8 @@ CHARSET_INFO my_charset_tis620 =
NULL, /* tosort */
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
};

View File

@ -8456,8 +8456,8 @@ CHARSET_INFO my_charset_ujis =
my_tosort_8bit,
my_strcasecmp_mb,
my_strncasecmp_mb,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
};

View File

@ -649,8 +649,8 @@ CHARSET_INFO my_charset_win1250ch =
NULL, /* tosort */
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
};

View File

@ -2832,8 +2832,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -2868,8 +2868,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -2903,8 +2903,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -2938,8 +2938,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -2974,8 +2974,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3009,8 +3009,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3044,8 +3044,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3079,8 +3079,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3115,8 +3115,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3150,8 +3150,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3185,8 +3185,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3220,8 +3220,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3255,8 +3255,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3290,8 +3290,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3325,8 +3325,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3361,8 +3361,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3396,8 +3396,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3432,8 +3432,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3468,8 +3468,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3503,8 +3503,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3538,8 +3538,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_strcasecmp_8bit,
my_tosort_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3573,8 +3573,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif
@ -3608,8 +3608,8 @@ static CHARSET_INFO compiled_charsets[] = {
my_tosort_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
NULL, /* hash_sort */
my_hash_caseup_simple,
my_hash_sort_simple,
0
},
#endif