Changeset 1772 for trunk/symtab


Ignore:
Timestamp:
Dec 13, 2011, 1:12:54 PM (7 years ago)
Author:
vla24
Message:

Updated symbol table expansion decision.

Location:
trunk/symtab
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/symtab/bitstream_hash_table_impl.h

    r1770 r1772  
    6363    CHAIN* next = m_table[bucket];
    6464    unsigned int chainlgth = chainLength(next);
    65     if (chainlgth == MAX_CHAIN)
     65//    if
     66    if (chainlgth == MAX_CHAIN && m_totalSymbols > m_maxSymbols)
    6667    {
    6768        //current chain length is maximum, expand the table
     
    7778    m_table[bucket] = curr;
    7879
     80    m_totalSymbols++;
     81
    7982#if DEBUG_BHT
    8083    printf ("Given GID: %i | Stored GID: %i\n", gid, m_table[bucket]->GID);
     
    9396    CHAIN* next = m_table[bucket];
    9497    unsigned int chainlgth = chainLength(next);
    95     if (chainlgth == MAX_CHAIN)
     98//    if (chainlgth == MAX_CHAIN)
     99    if (chainlgth == MAX_CHAIN && m_totalSymbols > m_maxSymbols)
    96100    {
    97101        //current chain length is maximum, expand the table
     
    108112    m_table[bucket] = curr;
    109113
     114    m_totalSymbols++;
     115
    110116#if DEBUG_BHT
    111117    printf ("Given GID: %i | Stored GID: %i\n", gid, m_table[bucket]->GID);
     
    150156    m_table = tempTable;
    151157    m_tableSize = tempTableSize;
     158
     159    m_maxSymbols = m_tableSize >> 1 + m_tableSize >> 2;
    152160}
    153161
     
    188196    m_table = tempTable;
    189197    m_tableSize = tempTableSize;
     198
     199    m_maxSymbols = m_tableSize >> 1 + m_tableSize >> 2;
    190200}
    191201
     
    356366#endif
    357367#ifdef XOR_HASHVALUE
    358     return ( longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+4), BYTES_TO_BITS(5), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     368//    return ( longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+4), BYTES_TO_BITS(5), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     369    uint32_t temphashvalue = (*((uint32_t*)name)) ^ (*((uint32_t*)(name+4))) ^ (*((uint32_t*)(name+5)));
     370    return ( longHashFunction<uint32_t>(&temphashvalue, &temphashvalue, 32, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    359371#else
    360372    return longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+4), BYTES_TO_BITS(5), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
     
    369381#endif
    370382#ifdef XOR_HASHVALUE
    371     return ( longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+5), BYTES_TO_BITS(5), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     383//    return ( longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+5), BYTES_TO_BITS(5), BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
     384    uint32_t temphashvalue = (*((uint32_t*)name)) ^ (*((uint32_t*)(name+4))) ^ (*((uint32_t*)(name+6)));
     385    return ( longHashFunction<uint32_t>(&temphashvalue, &temphashvalue, 32, BIT_SIZE(tableSize)) ^ ~hashvalue ) & TABLE_SIZE_MASK(tableSize);
    372386#else
    373387    return longHashFunction<uint64_t>((uint64_t*)name, (uint64_t*)(name+5), BYTES_TO_BITS(5), BIT_SIZE(tableSize)) & TABLE_SIZE_MASK(tableSize);
  • trunk/symtab/bitstream_super_hash_table.h

    r1742 r1772  
    4949    unsigned int nextTableSize();
    5050    unsigned int chainLength(CHAIN* chain);
     51
     52    unsigned int m_maxSymbols;
     53    unsigned int m_totalSymbols;
    5154};
    5255
    5356BitStreamSuperHashTable::BitStreamSuperHashTable()
    5457    :m_tableSize(DEFAULT_TABLE_SIZE)
     58    ,m_totalSymbols(0)
    5559{
    5660    m_table = allocateHashTable(m_tableSize);
     
    5963        printf ("Failed to allocate table!\n");
    6064    }
     65
     66    m_maxSymbols = m_tableSize >> 1 + m_tableSize >> 2;
    6167}
    6268
Note: See TracChangeset for help on using the changeset viewer.