Changeset 1992 for trunk


Ignore:
Timestamp:
Mar 31, 2012, 8:37:43 PM (7 years ago)
Author:
ksherdy
Message:

Inherited pointer based implementation.

Location:
trunk/symbol_table/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/symbol_table/src/hash_table.hpp

    r1991 r1992  
    101101    }
    102102
    103     IDISA_ALWAYS_INLINE void lookup_or_insert(uint8_t * raw_bytes, const uint32_t idx, const uint32_t raw_byte_lgth, /* IN, IN, IN */
    104                                                   uint8_t * h0, uint8_t * h1, const uint32_t hash_bit_lgth /*IN, IN, IN*/
    105                                                   gid_type & gid, uint8_t & bytes /*OUT, OUT*/) {
     103    IDISA_ALWAYS_INLINE gid_type lookup_or_insert(uint8_t * raw_bytes, const uint32_t idx, const uint32_t raw_byte_lgth,
     104                                                  uint8_t * h0, uint8_t * h1, const uint32_t hash_bit_lgth) {
    106105
    107106        uint64_t bucket = get_bucket(h0,h1,idx,hash_bit_lgth);
     
    122121        }
    123122
    124         /* OUT params (GID, symbol length) */
    125         gid = gid::next();
    126         bytes = raw_data_pool.insert(&raw_bytes[idx],raw_byte_lgth)
     123        /* insert */
     124        gid_type gid = gid::next();
    127125
    128126        uint64_t x0 = bit_slice(h0, idx, hash_bit_lgth);
     
    130128
    131129        insert( bucket,
    132                 bytes,
     130                raw_data_pool.insert(&raw_bytes[idx],raw_byte_lgth),
    133131                raw_byte_lgth,
    134132                raw_data_pool.insert((uint8_t *)&x0, bits2bytes(hash_bit_lgth)),
     
    150148        #endif
    151149
     150        return gid;
    152151    }
    153152
  • trunk/symbol_table/src/id_symbol_table.hpp

    r1991 r1992  
    8181    // Groups & groups
    8282    void resolve(uint8_t buffer [], Groups groups [],  BitBlock starts [], BitBlock ends_gte_17 [],
    83                  BitBlock h0 [], BitBlock h1 [], uint32_t blocks, AoS_symbol aos []/*, const uint32_t symbols*/) {
     83                 BitBlock h0 [], BitBlock h1 [], uint32_t blocks, AoS_symbol ** aos/*, const uint32_t symbols*/) {
     84
    8485
    8586        uint32_t blk_base;
     
    8889
    8990        blk_base = blk*BLOCK_SIZE;
     91
    9092        ///////////////////////////////////////////////////////////////////////////////
    9193        // Byte Space Hash
     
    182184IDISA_ALWAYS_INLINE void do_block(HASH_TABLE & h_table, BitBlock ends, uint8_t buffer [], const uint32_t lgth,
    183185                                  uint8_t h0 [], uint8_t h1 [], const uint32_t h_lgth, const uint32_t h_block_size,
    184                                   AoS_symbol aos [], const uint32_t block_base){
     186                                  AoS_symbol ** aos , const int32_t block_base){
    185187
    186188    int32_t spos;
     
    192194    while(!rscanner.is_done() && (spos >= 0)) {
    193195
    194         h_table.lookup_or_insert(buffer, spos, lgth,
    195                                  h0, h1, h_lgth,
    196                                  aos[block_base+spos].gid, aos[block_base+spos].raw_data);
     196        // Comment out LOOKBACK_SIZE . Nigel's code *should* not produce this case.
     197        aos[LOOKBACK_SIZE + block_base + spos]->gid = h_table.lookup_or_insert(buffer, spos, lgth, h0, h1, h_lgth);
     198        aos[LOOKBACK_SIZE + block_base + spos]->lgth = lgth;
    197199
    198200#ifdef ID_SYMBOL_TABLE_TEMPLATE_HPP_DEBUG
    199201        print_symbol_debug(buffer, spos, rscanner.get_pos(), lgth);
    200         aos[block_base+spos].gid;
    201202#endif
    202203        rscanner.scan_to_next();
     
    204205    }
    205206
    206     if(!rscanner.is_done() && (spos < 0)) { // block boundary case
     207    // Comment out. Nigel's code *should* not produce this case.
     208    if(!rscanner.is_done() && (spos < 0)) { // block boundary case.
    207209
    208210        if(lgth > (LOOKBACK_SIZE)) {
     
    220222        uint8_t * lb_h1 = h1 - ((lgth / BLOCK_SIZE) + 1)*h_block_size;
    221223
    222         h_table.lookup_or_insert(lb_buffer, lb_spos, lgth,
    223                                  lb_h0, lb_h1, h_lgth,
    224                                  aos[block_base+spos].gid, aos[block_base+spos].raw_data);
     224        // Comment out LOOKBACK_SIZE . Nigel's code *should* not produce this case.
     225        aos[LOOKBACK_SIZE + block_base + lb_spos]->gid = h_table.lookup_or_insert(lb_buffer, lb_spos, lgth, lb_h0, lb_h1, h_lgth);
     226        aos[LOOKBACK_SIZE + block_base + lb_spos]->lgth = lgth;
    225227
    226228#ifdef ID_SYMBOL_TABLE_TEMPLATE_HPP_DEBUG
     
    235237IDISA_ALWAYS_INLINE void do_block(HASH_TABLE & h_table, BitBlock starts [], BitBlock ends [], uint8_t buffer [],
    236238                                  uint8_t h0 [], uint8_t h1 [], const uint32_t h_block_size,
    237                                   AoS_symbol aos [], const uint32_t block_base) {
    238 
    239 
     239                                  AoS_symbol ** aos, const uint32_t block_base) {
     240
     241    int32_t spos;
    240242    uint32_t lgth;
    241243    ReverseScanner<BitBlock, scanword_t> ends_rscanner(ends);
     
    245247    starts_rscanner.scan_to_next();
    246248
    247     while(starts_rscanner.get_pos() > ends_rscanner.get_pos()) { // synchronize
     249    while(starts_rscanner.get_pos() > ends_rscanner.get_pos()) { // synchronize, TODO - scan_from_position();
    248250        starts_rscanner.scan_to_next();
    249251    }
    250252
    251253    while((!ends_rscanner.is_done()) && (!starts_rscanner.is_done())) {
    252         lgth = ends_rscanner.get_pos() - starts_rscanner.get_pos();
    253 
    254         h_table.lookup_or_insert(buffer, starts_rscanner.get_pos(), lgth, h0, h1, lgth,aos[block_base+spos].gid, aos[block_base+spos].raw_data);
    255 
    256 #ifdef ID_SYMBOL_TABLE_TEMPLATE_HPP_DEBUG
    257     print_symbol_debug(buffer, starts_rscanner.get_pos(), ends_rscanner.get_pos(), lgth);
     254        spos = starts_rscanner.get_pos();
     255        lgth = ends_rscanner.get_pos() - spos;
     256        // Comment out LOOKBACK_SIZE . Nigel's code *should* not produce this case.
     257        aos[LOOKBACK_SIZE + block_base + spos]->gid = h_table.lookup_or_insert(buffer, spos, lgth, h0, h1, lgth);
     258        aos[LOOKBACK_SIZE + block_base + spos]->lgth = lgth;
     259
     260#ifdef ID_SYMBOL_TABLE_TEMPLATE_HPP_DEBUG
     261    print_symbol_debug(buffer, spos, ends_rscanner.get_pos(), lgth);
    258262#endif
    259263
     
    261265        starts_rscanner.scan_to_next();
    262266
    263         while(starts_rscanner.get_pos() > ends_rscanner.get_pos()) { // synchronize
     267        while(starts_rscanner.get_pos() > ends_rscanner.get_pos()) { // synchronize, TODO - scan_from_position();
    264268            starts_rscanner.scan_to_next();
    265269        }
     
    267271    }
    268272
    269     if((!ends_rscanner.is_done()) && (starts_rscanner.is_done())) { // block boundary case, goto previous block
     273    // TODO - COMMENT OUT. Nigel's code *should* not produce this case.
     274    if((!ends_rscanner.is_done()) && (starts_rscanner.is_done())) { // block boundary case
    270275
    271276        uint32_t lb_blk = 0;
     
    298303        uint8_t * lb_h1 = h1 - ((lgth / BLOCK_SIZE) + 1)*h_block_size;
    299304
    300         h_table.lookup_or_insert(lb_buffer, lb_spos, lgth, lb_h0, lb_h1, lgth,aos[block_base+spos].gid, aos[block_base+spos].raw_data);
     305        // Comment out LOOKBACK_SIZE. Nigel's code *should* not produce this case.
     306        aos[LOOKBACK_SIZE + block_base + lb_spos]->gid = h_table.lookup_or_insert(lb_buffer, lb_spos, lgth, lb_h0, lb_h1, lgth);
     307        aos[LOOKBACK_SIZE + block_base + lb_spos]->lgth = lgth;
     308
     309        if((lb_spos) < 0) {
     310            cerr << "ERROR" << endl;
     311            exit(1);
     312        }
     313
     314        aos[block_base + lb_spos]->lgth = lgth;
    301315
    302316#ifdef ID_SYMBOL_TABLE_TEMPLATE_HPP_DEBUG
  • trunk/symbol_table/src/symbol_table.hpp

    r1991 r1992  
    1717typedef uint32_t gid_type;
    1818
    19 typedef struct AoS_symbol { // Xerces
     19class AoS_symbol { // Xerces
    2020public:
    2121    gid_type gid;
    22     uint8_t * raw_data;
     22    //uint8_t * raw_data;
    2323    uint32_t lgth;
    24 } AoS_symbol;
     24};
    2525
    26 typedef struct SoA_symbol { // Regex
     26class SoA_symbol { // Regex
    2727public:
    2828    gid_type * gids;
    2929    uint8_t * raw_data;
    3030    uint32_t * lgth;
    31 } SoA_symbol;
     31};
    3232
    3333class symbol_table {
    3434public:
    3535    void resolve(uint8_t buffer [], Groups groups [],  BitBlock starts [], BitBlock ends_gte_17 [],
    36                  BitBlock h0 [], BitBlock h1 [], uint32_t blocks, AoS_symbol aos []/*, const uint32_t symbols*/);
     36                 BitBlock h0 [], BitBlock h1 [], uint32_t blocks, AoS_symbol * aos []/*, const uint32_t symbols*/);
    3737
    38     void resolve(uint8_t buffer [], Groups groups [],  BitBlock starts [], BitBlock ends_gte_17 [],
    39                  BitBlock h0 [], BitBlock h1 [], uint32_t blocks, SoA_symbol & soa/*, const uint32_t symbols*/);
     38    //void resolve(uint8_t buffer [], Groups groups [],  BitBlock starts [], BitBlock ends_gte_17 [],
     39//               BitBlock h0 [], BitBlock h1 [], uint32_t blocks, SoA_symbol & soa/*, const uint32_t symbols*/);
    4040
    4141protected:
Note: See TracChangeset for help on using the changeset viewer.