Changeset 1770


Ignore:
Timestamp:
Dec 13, 2011, 1:30:57 AM (8 years ago)
Author:
vla24
Message:

Updated symbol table hashing function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/symtab/bitstream_hash_table_impl.h

    r1742 r1770  
    232232#endif
    233233    int tempHashVal = hashvalue << L;
    234     return longHashFunction<uint32_t>((uint32_t*)(&hashvalue), (uint32_t*)(&tempHashVal), L<<1, BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     234    return (longHashFunction<uint32_t>((uint32_t*)(&hashvalue), (uint32_t*)(&tempHashVal), L<<1, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    235235}
    236236
     
    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);
     283//    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);
    284286#else
    285287    return longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)name, BYTES_TO_BITS(4), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     
    294296#endif
    295297#ifdef XOR_HASHVALUE
    296     return ( longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+2), BYTES_TO_BITS(3), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     298//    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);
    297301#else
    298302    return longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+2), BYTES_TO_BITS(3), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     
    307311#endif
    308312#ifdef XOR_HASHVALUE
    309     return ( longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+3), BYTES_TO_BITS(3), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     313//    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);
    310316#else
    311317    return longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+3), BYTES_TO_BITS(3), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     
    320326#endif
    321327#ifdef XOR_HASHVALUE
    322     return ( longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+3), BYTES_TO_BITS(4), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     328//    return ( longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+3), BYTES_TO_BITS(4), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     329    uint32_t temphashvalue = (*((uint32_t*)name)) ^ (*((uint32_t*)(name+3)));
     330    return ( longHashFunction<uint32_t>(&temphashvalue, &temphashvalue, 32, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    323331#else
    324332    return longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+3), BYTES_TO_BITS(4), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     
    333341#endif
    334342#ifdef XOR_HASHVALUE
    335     return ( longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+4), BYTES_TO_BITS(4), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     343//    return ( longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+4), BYTES_TO_BITS(4), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     344    uint32_t temphashvalue = (*((uint32_t*)name)) ^ (*((uint32_t*)(name+4)));
     345    return ( longHashFunction<uint32_t>(&temphashvalue, &temphashvalue, 32, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    336346#else
    337347    return longHashFunction<uint32_t>((uint32_t*)name, (uint32_t*)(name+4), BYTES_TO_BITS(4), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     
    365375}
    366376
    367 template <>
    368     inline unsigned int BitStreamHashTableImpl<11>::getBucket(const char* name, const int hashvalue, unsigned int tableSize)
    369 {
    370 #if DEBUG_BHT
    371     printf ("%s_%i | hashvalue: %i | ", __FUNCTION__, 11, hashvalue);
    372 #endif
    373 #ifdef XOR_HASHVALUE
    374     return ( longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+5), BYTES_TO_BITS(6), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    375 #else
    376     return longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+5), BYTES_TO_BITS(6), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
    377 #endif
    378 }
    379 
    380 template <>
    381     inline unsigned int BitStreamHashTableImpl<12>::getBucket(const char* name, const int hashvalue, unsigned int tableSize)
    382 {
    383 #if DEBUG_BHT
    384     printf ("%s_%i | hashvalue: %i | ", __FUNCTION__, 12, hashvalue);
    385 #endif
    386 #ifdef XOR_HASHVALUE
    387     return ( longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+6), BYTES_TO_BITS(6), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    388 #else
    389     return longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+6), BYTES_TO_BITS(6), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
    390 #endif
    391 }
    392377//#endif // BITSTREAM_HASH_TABLE_IMPL_H
Note: See TracChangeset for help on using the changeset viewer.