source: trunk/symbol_table/src/symbol_table.hpp @ 2027

Last change on this file since 2027 was 2027, checked in by ksherdy, 7 years ago

Added GIDFactory class member. Each symbol table maintains a set of GIDs.

File size: 2.8 KB
Line 
1/*
2 * Created on: 18-December-2011
3 * Author: Ken Herdy
4 *
5 * Segment-at-a-time symbol table.
6 *
7 */
8#ifndef SYMBOL_TABLE_HPP
9#define SYMBOL_TABLE_HPP
10
11#include "../lib/bitblock.hpp"
12#include "../lib/byte_pool.hpp"
13#include "gid_factory.hpp"
14#include "hash_table.hpp"
15
16#include <vector>
17#include <iostream>
18using namespace std;
19
20///////////////////////////////////////////////////////////////////////////
21// Symbol Type - Array of gid_type
22///////////////////////////////////////////////////////////////////////////
23
24class Symbol {
25public:
26    Symbol (uint32_t n) {
27        init(n);
28    }
29
30    void init(uint32_t n) {
31        gids.reserve(n);
32        //gids_idx.reserve((n/BLOCK_SIZE) + 1);
33    }
34
35    vector<gid_type> gids;
36    //vector<BitBlock> gids_idx;   // gids index
37};
38
39///////////////////////////////////////////////////////////////////////////
40// GID indexed POD array
41///////////////////////////////////////////////////////////////////////////
42
43template <class SYMBOL> class symbol_table{
44public:
45    void resolve(uint8_t buffer [], Groups groups [],  BitBlock starts [], BitBlock ends_gte_17 [],
46                 BitBlock h0 [], BitBlock h1 [], uint32_t blocks, SYMBOL & symbols /*, const uint32_t symbols*/);
47
48    IDISA_ALWAYS_INLINE uint8_t * get_raw_data(uint32_t idx) const { return gid_data::get_raw_bytes(idx); }
49    IDISA_ALWAYS_INLINE uint32_t get_lgth(uint32_t idx) const { return gid_data::get_bytes_lgth(idx); }
50
51protected:
52    symbol_table() {}
53    ~symbol_table() {}
54
55    GIDFactory gid_factory;
56};
57
58template<class SYMBOL, class HASH_TABLE>
59void do_block(uint32_t blk_offset,
60              HASH_TABLE & h_table,
61              BitBlock ends,
62              uint8_t buffer [], const uint32_t lgth,
63              uint8_t h0 [], uint8_t h1 [], const uint32_t h_lgth, const uint32_t h_block_size,
64              SYMBOL & symbols, GIDFactory & gid_factory);
65
66template<class SYMBOL, class HASH_TABLE>
67void do_block(uint32_t blk_offset,
68              HASH_TABLE & h_table,
69              BitBlock starts [], BitBlock ends [],
70              uint8_t buffer [],
71              uint8_t h0 [], uint8_t h1 [], const uint32_t h_lgth, const uint32_t h_block_size,
72              SYMBOL & symbols, GIDFactory & gid_factory);
73
74#endif // SYMBOL_TABLE_HPP
75
76/*
77template<class SYMBOL, class ALLOCATOR>
78class div2: public symbol_table_strategy<SYMBOL, ALLOCATOR> {
79
80public:
81    div2() {}
82    ~div2() {}
83
84    void resolve(...) {
85        cout << "div2 Strategy" << endl;
86    }
87    //void resolve(uint8_t * segment, uint32_t segment_blocks, BitBlock * starts, BitBlock * ends, SoA_symbol & symbols);
88};
89*/
90
91/*
92template<class SYMBOL, class ALLOCATOR>
93class log2: public symbol_table_strategy<SYMBOL, ALLOCATOR> {
94
95public:
96    log2() {}
97    ~log2() {}
98
99    void resolve(...) {
100        cout << "log2 Strategy" << endl;
101    }
102    //void resolve(uint8_t * segment, uint32_t segment_blocks, BitBlock * starts, BitBlock * ends, SoA_symbol & symbols);
103};
104*/
105
Note: See TracBrowser for help on using the repository browser.