14
14
15
15
#include < cstdint>
16
16
17
- #include " libcount/hll.h"
18
-
19
17
#include " executor/executor_context.h"
20
18
21
19
namespace peloton {
@@ -71,21 +69,42 @@ class HashTable {
71
69
char *Insert (uint64_t hash);
72
70
73
71
/* *
72
+ * This function builds a hash table over all elements that have been lazily
73
+ * inserted into the hash table. It is assumed that this hash table is being
74
+ * used in two-phase mode, i.e., where all insertions are performed first,
75
+ * followed by a series of probes.
74
76
*
77
+ * After this call, the hash table will not accept any more insertions. The
78
+ * hash-table will be frozen.
75
79
*/
76
80
void BuildLazy ();
77
81
78
82
/* *
83
+ * This function inspects the size of each thread-local hash table stored in
84
+ * the thread states argument to perfectly size a 50% loaded hash table.
85
+ *
86
+ * This function is called during parallel hash table builds once each thread
87
+ * has finished constructing its own thread-local hash table. The final phase
88
+ * is to build a global hash table (this one) with pointers into thread-local
89
+ * hash tables.
79
90
*
80
- * @param thread_states
81
- * @param hash_table_offset
91
+ * @param thread_states Where thread-local hash tables are located
92
+ * @param hash_table_offset The offset into each state where the thread-local
93
+ * hash table can be found.
82
94
*/
83
95
void ReserveLazy (const executor::ExecutorContext::ThreadStates &thread_states,
84
96
uint32_t hash_table_offset);
85
97
86
98
/* *
99
+ * This function is called to "merge" the contents of the provided hash table
100
+ * into this table. Each hash table is assumed to have been built lazily
101
+ * constructed and unfinished; that is, each able has not constructed a
102
+ * directory hash table, but has buffered a series of tuples into hash table
103
+ * memory.
87
104
*
88
- * @param
105
+ * This function is called from different threads!
106
+ *
107
+ * @param The hash table whose contents we will merge into this one..
89
108
*/
90
109
void MergeLazyUnfinished (const HashTable &other);
91
110
@@ -96,6 +115,7 @@ class HashTable {
96
115
// ////////////////////////////////////////////////////////////////////////////
97
116
98
117
uint64_t NumElements () const { return num_elems_; }
118
+ uint64_t Capacity () const { return capacity_; }
99
119
100
120
// ////////////////////////////////////////////////////////////////////////////
101
121
// /
@@ -150,13 +170,29 @@ class HashTable {
150
170
*/
151
171
class EntryBuffer {
152
172
public:
173
+ /* *
174
+ * Constructor for a buffer of entries.
175
+ *
176
+ * @param memory The memory pool to source memory for entries from
177
+ * @param entry_size The size of an entry
178
+ */
153
179
EntryBuffer (::peloton::type::AbstractPool &memory, uint32_t entry_size);
154
180
181
+ /* *
182
+ * Destructor.
183
+ */
155
184
~EntryBuffer ();
156
185
186
+ /* *
187
+ * Return a pointer to the next available Entry slot. If insufficient memory
188
+ * is available, memory is taken from the pool.
189
+ *
190
+ * @return A pointer to a free Entry slot.
191
+ */
157
192
Entry *NextFree ();
158
193
159
194
private:
195
+ // This struct allows us to chain together chunks of memory
160
196
struct MemoryBlock {
161
197
MemoryBlock *next;
162
198
char data[0 ];
@@ -200,9 +236,6 @@ class HashTable {
200
236
201
237
// Info about partitions
202
238
// ...
203
-
204
- // Stats
205
- std::unique_ptr<libcount::HLL> unique_key_estimate_;
206
239
};
207
240
208
241
// //////////////////////////////////////////////////////////////////////////////
0 commit comments