GENIE
inv_table.h
Go to the documentation of this file.
1 
9 #ifndef GPUGenie_inv_table_h
10 #define GPUGenie_inv_table_h
11 
12 #include <vector>
13 #include <map>
14 #include <unordered_map>
15 #include "inv_list.h"
16 
17 #include <boost/serialization/access.hpp>
18 #include <boost/serialization/split_member.hpp>
19 
23 typedef unsigned long long u64;
24 
25 
26 namespace genie
27 {
28 namespace table
29 {
30 
31 class inv_compr_table;
32 
41 class inv_table
42 {
43 public:
44 
48  enum status
49  {
51  };
55  int *d_inv_p = NULL;
56 
61  static int max_inv_size;
62 
71 
76 
77 
78 
79 private:
80 
87  int table_index;
88 
95  int total_num_of_table;
96 
97 
98 
104  status _build_status;
105 
110  int _shifter;
111 
115  int _size;
116 
120  int _dim_size;
121 
125  std::vector<inv_list> _inv_lists;
126 
131  //vector<vector<int> > distinct_value;
132  std::vector<std::unordered_map<int, int> > _distinct_map;
133 
134 
138  std::vector<int> inv_list_upperbound;
139 
143  std::vector<int> inv_list_lowerbound;
144 
149  std::vector<std::vector<int> > posting_list_size;
150 
151 
152 
156  std::vector<int> _ck;
157 
164  std::vector<int> _inv;
165 
169  std::unordered_map<size_t, int> _inv_index_map;
170 
174  std::vector<int> _inv_pos;
175 
181  unsigned int shift_bits_subsequence;
182 
186  int min_value_sequence;
187 
188 
194  int max_value_sequence;
195 
199  int gram_length_sequence;
200 
201 
202 public:
203 
210  inv_table():is_stored_in_gpu(false),shift_bits_sequence(0),
211  table_index(0),total_num_of_table(1),
212  _build_status(not_builded), _shifter(16),_size(-1),_dim_size(0),
213  shift_bits_subsequence(0),
214  min_value_sequence(0), max_value_sequence(0), gram_length_sequence(1)
215  {
216  }
217 
221  virtual ~inv_table();
222 
223 
230  std::unordered_map<int, int>* get_distinct_map(int dim);
231 
239 
246  void
247  set_table_index(int attr_index);
248 
255  void
256  set_total_num_of_table(int num);
257 
263  int
264  get_table_index() const;
265 
271  int
272  get_total_num_of_table() const;
273 
274 
280  bool
281  cpy_data_to_gpu();
282 
286  void
287  clear_gpu_mem();
288 
296  void
297  clear();
298 
308  bool
309  empty();
310 
315  int
316  m_size();
317 
322  int
323  i_size();
324 
328  int
329  shifter();
330 
335  unsigned int
337 
348  void
349  append(inv_list& inv);
350 
362  void
363  append(inv_list* inv);
364 
369  status
370  build_status();
371 
376  std::vector<inv_list>*
377  inv_lists();
378 
383  virtual std::vector<int>*
384  ck();
385 
390  virtual std::vector<int>*
391  inv();
392 
397  std::unordered_map<size_t, int>*
398  inv_index_map();
399 
404  virtual std::vector<int>*
405  inv_pos();
406 
407 
414  int
415  get_upperbound_of_list(int attr_index);
416 
423  int
424  get_lowerbound_of_list(int attr_index);
425 
426 
427 
428 
445  void
446  virtual build(size_t max_length, bool use_load_balance);
447 
448 
459  int
460  get_posting_list_size(int attr_index, int value);
461 
470  bool
471  list_contain(int attr_index, int value);
472 
478  void
479  set_min_value_sequence(int min_value);
480 
486  int
488 
494  void
495  set_max_value_sequence(int max_value);
496 
502  int
504 
511  void
512  set_gram_length_sequence(int gram_length);
513 
521  int
523 
524 
525  template <class Archive>
526  void load(Archive &ar, const unsigned int version);
527 
528  template <class Archive>
529  void save(Archive &ar, const unsigned int version) const;
530 
531  BOOST_SERIALIZATION_SPLIT_MEMBER()
532 
533 private:
535 
536 };
537 
538 } // namespace table
539 } // namespace genie
540 
541 #endif
int get_gram_length_sequence()
Get the gram length.
Definition: inv_table.cu:385
bool cpy_data_to_gpu()
Copy vector _inv to gpu memory which is referenced by d_inv_p.
Definition: inv_table.cu:30
std::unordered_map< size_t, int > * inv_index_map()
Definition: inv_table.cu:255
This is the top-level namespace of the project.
void set_gram_length_sequence(int gram_length)
Set length of each gram.
Definition: inv_table.cu:378
virtual std::vector< int > * inv_pos()
Definition: inv_table.cu:261
void clear_gpu_mem()
clear the corresponding gpu memory referenced by d_inv_p
Definition: inv_table.cu:69
static int max_inv_size
Definition: inv_table.h:61
int * d_inv_p
d_inv_p points to the start location for posting list array in GPU memory.
Definition: inv_table.h:55
virtual ~inv_table()
The Destructor of the inv_table. It will also clear the related gpu memory.
Definition: inv_table.cu:55
int get_upperbound_of_list(int attr_index)
Definition: inv_table.cu:184
The declaration for class inv_table.
Definition: inv_table.h:41
status
This enum var defines two statuses for a inv_table object, which is either builded or not_builded...
Definition: inv_table.h:48
int get_total_num_of_table() const
return the total_num_of_table.
Definition: inv_table.cu:225
std::unordered_map< int, int > * get_distinct_map(int dim)
Definition: inv_table.cu:102
int get_table_index() const
return the index of this inv_table.
Definition: inv_table.cu:219
virtual std::vector< int > * ck()
Definition: inv_table.cu:242
void append(inv_list &inv)
Append an inv_list to the inv_table.
Definition: inv_table.cu:107
int get_min_value_sequence()
Get the min value for sequences&#39; elements in this inv_table.
Definition: inv_table.cu:359
virtual void build(size_t max_length, bool use_load_balance)
Build the inv_table.
Definition: inv_table.cu:268
void clear()
Clear the inv_table.
Definition: inv_table.cu:47
int shift_bits_sequence
This variable is used to tell the number of bits shifted for recording gram in different position...
Definition: inv_table.h:75
int get_lowerbound_of_list(int attr_index)
Definition: inv_table.cu:193
unsigned int _shift_bits_subsequence()
Definition: inv_table.cu:202
friend class boost::serialization::access
Definition: inv_table.h:534
int get_posting_list_size(int attr_index, int value)
Definition: inv_table.cu:164
virtual std::vector< int > * inv()
Definition: inv_table.cu:248
bool is_stored_in_gpu
is_stored_in_gpu tell whether inverted index structure is pre-stored inside gpu memory ...
Definition: inv_table.h:70
void set_table_index(int attr_index)
Set the table_index to &#39;index&#39;.
Definition: inv_table.cu:208
void load(Archive &ar, const unsigned int version)
unsigned long long u64
Definition: inv_table.h:23
void set_min_value_sequence(int min_value)
Used in sequence search. To set the min_value for all sequences&#39; element.
Definition: inv_table.cu:353
void set_total_num_of_table(int num)
Set the total_num_of_table to &#39;num&#39;.
Definition: inv_table.cu:213
void save(Archive &ar, const unsigned int version) const
Declaration of inv_list class.
inv_table()
Default constructor of the inv_table.
Definition: inv_table.h:210
This class manages one inverted list.
Definition: inv_list.h:23
bool empty()
Check whether the inv_table is empty.
Definition: inv_table.cu:81
int get_max_value_sequence()
Get the max value.
Definition: inv_table.cu:371
bool list_contain(int attr_index, int value)
Test whether a value is possible for an specific attribute.
Definition: inv_table.cu:173
std::vector< inv_list > * inv_lists()
Definition: inv_table.cu:236
void set_max_value_sequence(int max_value)
Set the max value for all sequence. Compare to set_min_value_sequence()
Definition: inv_table.cu:365
void append_sequence(inv_list &inv)
append inv_list for sequence search
Definition: inv_table.cu:130