Changeset 1789


Ignore:
Timestamp:
Dec 17, 2011, 2:47:13 PM (7 years ago)
Author:
vla24
Message:

updated hash function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/symtab/bitstream_hash_table_impl.h

    r1773 r1789  
    281281#endif
    282282#ifdef XOR_HASHVALUE
     283    return (longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)name, BYTES_TO_BITS(4), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    283284//    return ( longHashFunction<uint16_t>((uint16_t*)name, (uint16_t*)name+2, 16, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    284     uint16_t temphashvalue = ( (*((uint16_t*)name)) ^ (*((uint16_t*)(name+2))) );
    285     return ( longHashFunction<uint16_t>(&temphashvalue, &temphashvalue, 16, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     285//    uint16_t temphashvalue = ( (*((uint16_t*)name)) ^ (*((uint16_t*)(name+2))) );
     286//    return ( longHashFunction<uint16_t>(&temphashvalue, &temphashvalue, 16, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    286287#else
    287288    return longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)name, BYTES_TO_BITS(4), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     
    297298#ifdef XOR_HASHVALUE
    298299//    return ( longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+2), BYTES_TO_BITS(3), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    299     uint16_t temphashvalue = ( (*((uint16_t*)name)) ^ (*((uint16_t*)(name+2))) ^ (* ((uint16_t*)(name+3)) ) );
    300     return ( longHashFunction<uint16_t>(&temphashvalue, &temphashvalue, 16, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     300    uint32_t temphashvalue = ( (*((uint32_t*)name)) ^ (*((uint32_t*)(name+1))) );
     301    return ( longHashFunction<uint32_t>(&temphashvalue, &temphashvalue, 32, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    301302#else
    302303    return longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+2), BYTES_TO_BITS(3), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     
    312313#ifdef XOR_HASHVALUE
    313314//    return ( longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+3), BYTES_TO_BITS(3), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    314     uint16_t temphashvalue = ( (*((uint16_t*)name)) ^ (*((uint16_t*)(name+2))) ^ (*((uint16_t*)(name+4))) );
    315     return ( longHashFunction<uint16_t>(&temphashvalue, &temphashvalue, 16, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     315
     316    uint32_t temphashvalue = ( (*((uint32_t*)name)) ^ (*((uint32_t*)(name+2))));
     317    return ( longHashFunction<uint32_t>(&temphashvalue, &temphashvalue, 32, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    316318#else
    317319    return longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+3), BYTES_TO_BITS(3), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     
    379381}
    380382
     383template <>
     384    inline unsigned int BitStreamHashTableImpl<11>::getBucket(const char* name, const int hashvalue, unsigned int tableSize)
     385{
     386#if DEBUG_BHT
     387    printf ("%s_%i | hashvalue: %i | ", __FUNCTION__, 11, hashvalue);
     388#endif
     389#ifdef XOR_HASHVALUE
     390//    return ( longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+4), BYTES_TO_BITS(5), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     391    uint32_t temphashvalue = (*((uint32_t*)name)) ^ (*((uint32_t*)(name+4))) ^ (*((uint32_t*)(name+7)));
     392    return ( longHashFunction<uint32_t>(&temphashvalue, &temphashvalue, 32, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     393#else
     394    return longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+4), BYTES_TO_BITS(5), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     395#endif
     396}
     397
     398template <>
     399    inline unsigned int BitStreamHashTableImpl<12>::getBucket(const char* name, const int hashvalue, unsigned int tableSize)
     400{
     401#if DEBUG_BHT
     402    printf ("%s_%i | hashvalue: %i | ", __FUNCTION__, 12, hashvalue);
     403#endif
     404#ifdef XOR_HASHVALUE
     405//    return ( longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+5), BYTES_TO_BITS(5), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     406    uint32_t temphashvalue = (*((uint32_t*)name)) ^ (*((uint32_t*)(name+4))) ^ (*((uint32_t*)(name+8)));
     407    return ( longHashFunction<uint32_t>(&temphashvalue, &temphashvalue, 32, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     408#else
     409    return longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+5), BYTES_TO_BITS(5), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     410#endif
     411}
     412
    381413//#endif // BITSTREAM_HASH_TABLE_IMPL_H
Note: See TracChangeset for help on using the changeset viewer.