Changeset 2040 for trunk/symbol_table


Ignore:
Timestamp:
Apr 21, 2012, 7:14:33 PM (7 years ago)
Author:
ksherdy
Message:

Fixed table resize.

Location:
trunk/symbol_table/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/symbol_table/src/Makefile

    r2034 r2040  
    1616
    1717all: basis_bits.hpp buffer.hpp byte_pool.hpp  hash_strms.hpp  hash_table.hpp  id_group_strms.hpp  id_symbol_table.hpp  main.cpp  Makefile  marker_strms.hpp  symbol_table.hpp  transpose.hpp
    18         $(CC) -o main main.cpp $(AFLAGS) -DID_SYMBOL_TABLE_TEMPLATE_HPP_DEBUG #-DHASH_TABLE_HPP_DEBUG # -DBUFFER_PROFILING
     18        $(CC) -o main main.cpp $(AFLAGS) #-DID_SYMBOL_TABLE_TEMPLATE_HPP_DEBUG #-DHASH_TABLE_HPP_DEBUG # -DBUFFER_PROFILING
    1919
    2020test: main
  • trunk/symbol_table/src/buffer.hpp

    r2031 r2040  
    99#define LOOKBACK_BLOCKS 1
    1010#define LOOKBACK_SIZE BLOCK_SIZE * LOOKBACK_BLOCKS
    11 #define SEGMENT_BLOCKS 10000                                                    // No COPY BACK for test, starts within segment
     11#define SEGMENT_BLOCKS 10000                                            // No COPY BACK for test, starts within segment
    1212#define SEGMENT_SIZE BLOCK_SIZE * (SEGMENT_BLOCKS)      // (bytes) a multiple of BLOCK_SIZE
    1313#define SEGMENT_ALLOC_SIZE (LOOKBACK_SIZE + SEGMENT_SIZE + PADDING_SIZE) / sizeof(BitBlock) // (bytes)
  • trunk/symbol_table/src/hash_table.hpp

    r2031 r2040  
    5151public:
    5252
    53     hash_table(const uint32_t table_size=1024, const uint32_t load_factor=2) {
     53    hash_table(const uint32_t table_size=1024, const uint32_t resize_chain_lgth=2) {
    5454        #ifdef HASH_TABLE_HPP_DEBUG
    5555            lookups = 0;
     
    5858            table_expansions = 0;
    5959        #endif
    60         init(table_size,load_factor);
     60        init(table_size,resize_chain_lgth);
    6161    }
    6262
     
    134134            #endif
    135135
    136             expand();
     136             expand();
    137137        }
    138138
     
    210210    uint32_t table_size;            // power of 2
    211211    uint32_t hash_size;             // maximum number of bits hashed on
    212     uint32_t resize_chain_lgth;     // maximum chain length
     212    uint32_t resize_chain_lgth; // maximum chain length
    213213
    214214    node ** table;
     
    235235    void init(const uint32_t size, const uint32_t chain_lgth) {
    236236
    237         hash_size = MIN((log2msb(size)),hash_strategy.max_hashsize());
     237        hash_size = MIN((log2msb(size)), hash_strategy.max_hashsize());
    238238        table_size = pow(2.0, (double)hash_size);
    239239        table = (node**) calloc(table_size, sizeof(node*));
     
    280280                &&  (table_size < MAX_TABLE_SIZE))
    281281        {
    282 
    283282            return true;
    284283        }
     
    301300
    302301            while(crt != NULL) {
     302
     303
    303304                bucket = this->get_bucket(crt->h0,
    304305                                          crt->h1,
     
    310311                             crt->h0,
    311312                             crt->h1,
    312                             crt->hash_bit_lgth,
     313                                crt->hash_bit_lgth,
    313314                             crt->gid);
    314315
     
    325326            }
    326327        }
     328
    327329    }
    328330
  • trunk/symbol_table/src/id_symbol_table.hpp

    r2036 r2040  
    6565        hash_table_7.print_diagnostics();
    6666        hash_table_8.print_diagnostics();
    67 
    6867        hash_table_9.print_diagnostics();
    6968        hash_table_10.print_diagnostics();
     
    122121                        #define BIT_HASH(LENGTH_GROUP, COMPARISON_TYPE) \
    123122                                if(bitblock::any(groups.ends_##LENGTH_GROUP)) { \
    124                                         do_block<SYMBOL, hash_table <identity_strategy_t<COMPARISON_TYPE, LENGTH_GROUP>, hash_strategy_d, ALLOCATOR> > \
     123                                        do_block<SYMBOL, hash_table <identity_strategy_t<COMPARISON_TYPE, LENGTH_GROUP>, hash_strategy_t<LENGTH_GROUP>, ALLOCATOR> > \
    125124                                                (blk_offset, \
    126125                                                 hash_table_##LENGTH_GROUP, \
     
    168167        // Bit Space Hash
    169168        ///////////////////////////////////////////////////////////////////////////////
    170         hash_table<identity_strategy_t<uint64_t,8>, hash_strategy_d, ALLOCATOR> hash_table_8;
    171         hash_table<identity_strategy_t<uint64_t,9>, hash_strategy_d, ALLOCATOR> hash_table_9;
    172         hash_table<identity_strategy_t<uint64_t,10>, hash_strategy_d, ALLOCATOR> hash_table_10;
    173         hash_table<identity_strategy_t<uint64_t,11>, hash_strategy_d, ALLOCATOR> hash_table_11;
    174         hash_table<identity_strategy_t<uint64_t,12>, hash_strategy_d, ALLOCATOR> hash_table_12;
    175         hash_table<identity_strategy_t<uint64_t,13>, hash_strategy_d, ALLOCATOR> hash_table_13;
    176         hash_table<identity_strategy_t<uint64_t,14>, hash_strategy_d, ALLOCATOR> hash_table_14;
    177         hash_table<identity_strategy_t<uint64_t,15>, hash_strategy_d, ALLOCATOR> hash_table_15;
    178         hash_table<identity_strategy_t<BitBlock,16>, hash_strategy_d, ALLOCATOR> hash_table_16;
     169        hash_table<identity_strategy_t<uint64_t,8>, hash_strategy_t<8>, ALLOCATOR> hash_table_8;
     170        hash_table<identity_strategy_t<uint64_t,9>, hash_strategy_t<9>, ALLOCATOR> hash_table_9;
     171        hash_table<identity_strategy_t<uint64_t,10>, hash_strategy_t<10>, ALLOCATOR> hash_table_10;
     172        hash_table<identity_strategy_t<uint64_t,11>, hash_strategy_t<11>, ALLOCATOR> hash_table_11;
     173        hash_table<identity_strategy_t<uint64_t,12>, hash_strategy_t<12>, ALLOCATOR> hash_table_12;
     174        hash_table<identity_strategy_t<uint64_t,13>, hash_strategy_t<13>, ALLOCATOR> hash_table_13;
     175        hash_table<identity_strategy_t<uint64_t,14>, hash_strategy_t<14>, ALLOCATOR> hash_table_14;
     176        hash_table<identity_strategy_t<uint64_t,15>, hash_strategy_t<15>, ALLOCATOR> hash_table_15;
     177        hash_table<identity_strategy_t<BitBlock,16>, hash_strategy_t<16>, ALLOCATOR> hash_table_16;
    179178        hash_table<identity_strategy_d, hash_strategy_d, ALLOCATOR> hash_table_gte_17;
    180179};
Note: See TracChangeset for help on using the changeset viewer.