GENIE
inv_compr_table.h
Go to the documentation of this file.
1 
8 #ifndef GPUGenie_inv_compr_table_h
9 #define GPUGenie_inv_compr_table_h
10 
11 #include <assert.h>
12 #include <map>
13 #include <memory>
14 #include <string>
15 
16 #include <boost/serialization/export.hpp>
17 
19 
20 #include "inv_table.h"
21 
22 namespace genie
23 {
24 namespace table
25 {
26 
28 {
29 protected:
30 
31  bool m_isCompressed; // TODO unused -> remove (Caution: need to generate all the binary inverted tables again!)
32 
33  std::vector<uint32_t> m_comprInv;
34 
35  std::vector<int> m_comprInvPos;
36 
38 
39  uint32_t *m_d_compr_inv_p;
40 
42 
43 public:
44 
49  m_isCompressed(false),
50  m_compression(genie::compression::DEFAULT_COMPRESSION_TYPE),
51  m_d_compr_inv_p(nullptr),
52  m_uncompressedInvListsMaxLength(0)
53  {
54  assert(sizeof(int) == sizeof(uint32_t)); // this is to make sure that virtual function inv() is correct
55  }
56 
60  virtual ~inv_compr_table();
61 
62 
64 
66 
67 
68  /*
69  * Return the equivalent of GPUGenie_Config::posting_list_max_length, indicating what is the maximum length of
70  * a single uncompressed posting lists.
71  * TODO: make this actually return the maximum length of an existing uncompressed inverted list
72  */
74 
75  void setUncompressedPostingListMaxLength(size_t length);
76 
77  /*
78  * Returns compressed version of _inv (posting lists array)
79  * Note that the compressed table, decompression and matching modules all treat the compressed data as uint32_t,
80  * so to avoid casts, use inv_compr_table::compressedInv() convenience function.
81  */
82  virtual std::vector<int>* inv();
83  /*
84  * Returns compressed version of _inv (posting lists array)
85  */
86  std::vector<uint32_t>* compressedInv();
87  /*
88  * Returns uncompressed version of _inv (posting lists array).
89  * This is an alias for inv_table::inv()
90  * Note that inv_compt_table keeps a copy of uncompressed posting lists array.
91  */
92  std::vector<int>* uncompressedInv();
93 
94  /*
95  * Returns compressed version of _inv_pos (starting positions of inverted lists in posting lists array)
96  */
97  virtual std::vector<int>* inv_pos();
98  /*
99  * Returns compressed version of _inv_pos (starting positions of inverted lists in posting lists array)
100  * This is an alias for inv_compr_table::inv_pos()
101  */
102  std::vector<int>* compressedInvPos();
103 
104  /*
105  * Returns uncompressed version of _inv_pos (starting positions of inverted lists in posting lists array)
106  * This is an alias for inv_table::inv_pos()
107  */
108  std::vector<int>* uncompressedInvPos();
109 
110 
111  uint32_t* deviceCompressedInv() const;
112 
116  double getCompressionRatio();
117 
118 
119 
136  virtual void build(size_t max_length, bool use_load_balance);
137 
138 
139 
145  bool cpy_data_to_gpu();
146 
150  void clear_gpu_mem();
151 
152 
153  void clear();
154 
155  template <class Archive>
156  void load(Archive &ar, const unsigned int version);
157 
158  template <class Archive>
159  void save(Archive &ar, const unsigned int version) const;
160 
161  BOOST_SERIALIZATION_SPLIT_MEMBER()
162 
163 private:
165 
166 };
167 
168 } // namespace table
169 } // namespace genie
170 
171 
172 BOOST_CLASS_EXPORT_KEY(genie::table::inv_compr_table)
173 
174 #endif
This is the top-level namespace of the project.
const COMPRESSION_TYPE DEFAULT_COMPRESSION_TYPE
Definition: interface.cc:48
std::vector< int > * compressedInvPos()
void setCompression(genie::compression::COMPRESSION_TYPE compression)
The declaration for class inv_table.
Definition: inv_table.h:41
virtual std::vector< int > * inv()
std::vector< uint32_t > * compressedInv()
genie::compression::COMPRESSION_TYPE getCompression() const
virtual void build(size_t max_length, bool use_load_balance)
Build the inv_table.
friend class boost::serialization::access
virtual std::vector< int > * inv_pos()
void load(Archive &ar, const unsigned int version)
std::vector< int > * uncompressedInvPos()
bool cpy_data_to_gpu()
Copy vector _inv to gpu memory which is referenced by d_inv_p.
inv_compr_table()
Default constructor of the inv_compr_table.
define class inv_table
size_t getUncompressedPostingListMaxLength() const
void save(Archive &ar, const unsigned int version) const
void clear_gpu_mem()
clear the corresponding gpu memory referenced by d_inv_p
std::vector< uint32_t > m_comprInv
genie::compression::COMPRESSION_TYPE m_compression
std::vector< int > * uncompressedInv()
void setUncompressedPostingListMaxLength(size_t length)
std::vector< int > m_comprInvPos
uint32_t * deviceCompressedInv() const