Akumuli
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
invertedindex.h
1 
17 #pragma once
18 #include "akumuli.h"
19 #include "hashfnfamily.h"
20 
21 #include <memory>
22 #include <unordered_map>
23 #include <vector>
24 
25 namespace Akumuli {
26 
28  const int INTERNAL_CARDINALITY_;
29  std::vector<uint64_t> a;
30  std::vector<uint64_t> b;
31  uint64_t prime;
32  uint64_t modulo;
33 
34  TwoUnivHashFnFamily(int cardinality, size_t modulo);
35 
36  uint64_t hash(int ix, uint64_t value) const;
37 };
38 
43 struct Postings {
44  std::unordered_map<aku_ParamId, size_t> counters_;
45 
46  void append(aku_ParamId id);
47 
48  size_t get_count(aku_ParamId id) const;
49 
50  size_t get_size() const;
51 
52  void merge(const Postings& other);
53 };
54 
55 
59 struct InvertedIndex {
60  TwoUnivHashFnFamily table_hash_;
61 
63  const size_t table_size_;
64 
66  std::vector<std::unique_ptr<Postings>> table_;
67 
69  InvertedIndex(const size_t table_size);
70 
72  void append(aku_ParamId id, const char* begin, const char* end);
73 
74  std::vector<std::pair<aku_ParamId, size_t>> get_count(const char* begin, const char* end);
75 };
76 
77 } // namespace
InvertedIndex(const size_t table_size)
C-tor. Argument table_size should be a power of two.
Definition: invertedindex.cpp:79
void append(aku_ParamId id, const char *begin, const char *end)
Add value to index.
Definition: invertedindex.cpp:99
const size_t table_size_
Size of the table.
Definition: invertedindex.h:63
Definition: invertedindex.h:43
Definition: invertedindex.h:59
Definition: invertedindex.h:27
std::vector< std::unique_ptr< Postings > > table_
Hash to postings list mapping.
Definition: invertedindex.h:66