GENIE
query.h
Go to the documentation of this file.
1 
8 #ifndef GPUGenie_query_h
9 #define GPUGenie_query_h
10 
11 #include <genie/table/inv_list.h>
12 #include <genie/table/inv_table.h>
13 #include <genie/configure.h>
14 
15 #include <vector>
16 
17 namespace genie
18 {
19 namespace query
20 {
21 
24 typedef unsigned int u32;
27 typedef unsigned long long u64;
28 
29 
34 class Query
35 {
36 public:
43  struct range
44  {
45  int query;
46  int order;
47  int dim;
48  int low;
49  int up;
50  float weight;
52  int up_offset;
53  float selectivity;
54  };
59  struct dim
60  {
61  int query;
62  int order;
63  int start_pos;
64  int end_pos;
65  float weight;
66  dim() = default;
67  dim(int query, int order, int start_pos, int end_pos, float weight);
68  };
69 private:
75  genie::table::inv_table* _ref_table;
76 
84  std::map<int, std::vector<range> > _attr_map;
85 
92  std::map<int, std::vector<dim> > _dim_map;
93 
97  int _topk;
98 
105  float _selectivity;
106 
110  int _index;
111 
115  int _count;
116 
117 public:
126 
130  std::vector<dim> _dims;
131 
139 
147 
151  Query();
152 
158  ref_table();
159 
169  void
170  attr(int index, int low, int up, float weight, int order);
180  void
181  attr(int index, int value, float weight, float selectivity, int order);
192  void
193  attr(int index, int low, int up, float weight, float selectivity, int order);
194 
200  void
201  clear_dim(int index);
202 
208  void
209  selectivity(float s);
210 
216  float
217  selectivity();
218 
226  void
228 
238  void
239  build_and_apply_load_balance(int max_load);
240 
241  #ifdef GENIE_COMPR
242  void
243  build_compressed(int max_load);
244  #endif
245 
251  void
252  topk(int k);
253 
259  int
260  topk();
261 
265  void
266  build();
267 
268  void
269  build(std::vector<dim> &);
270 
271 
281  int
282  dump(std::vector<dim>& vout);
283 
284  int
285  dump(std::vector<range>& ranges);
286 
292  void
293  print(int limit);
294 
298  int
299  index();
300 
305  int
306  count_ranges();
307 
312  void
313  build_sequence();
314 };
315 
316 } // namespace query
317 } // namespace genie
318 
319 #endif
void build_and_apply_load_balance(int max_load)
The function would construct query in the setting where load balance feature is on.
Definition: query.cc:141
This is the top-level namespace of the project.
The declaration for class inv_table.
Definition: inv_table.h:41
void build_sequence()
build query dim for sequence search
Definition: query.cc:378
int topk()
Get top k matches.
Definition: query.cc:268
void print(int limit)
Print out the information of all dims.
Definition: query.cc:589
unsigned long long u64
Definition: query.h:27
genie::table::inv_table * ref_table()
The refrenced table&#39;s pointer.
Definition: query.cc:71
int dump(std::vector< dim > &vout)
std::vector< dim > _dims
Collection of dims of all queries.
Definition: query.h:130
void apply_adaptive_query_range()
Construct query in adaptice range mode.
Definition: query.cc:196
Query class includes the functions for processing queries based on user&#39;s input.
int count_ranges()
Get value of _ count.
Definition: query.cc:584
define class inv_table
The first-step struct for processing queries.
Definition: query.h:43
void clear_dim(int index)
Delete the dim at index.
Definition: query.cc:116
void attr(int index, int low, int up, float weight, int order)
Modify the matching range and weight of an attribute.
Definition: query.cc:76
The second-step struct for processing queries.
Definition: query.h:59
int index()
Get index of the query.
Definition: query.cc:579
Declaration of inv_list class.
bool is_load_balanced
Whether this query set has been applied load balance feature.
Definition: query.h:121
unsigned int u32
Definition: query.h:24
bool use_load_balance
Whether this query set is to use load balance.
Definition: query.h:125
void build()
Construct the query based on a normal table.
Definition: query.cc:273