Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 1a9db41

Browse files
committed
Comments
1 parent e739171 commit 1a9db41

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

src/include/codegen/util/hash_table.h

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
#include <cstdint>
1616

17-
#include "libcount/hll.h"
18-
1917
#include "executor/executor_context.h"
2018

2119
namespace peloton {
@@ -71,21 +69,42 @@ class HashTable {
7169
char *Insert(uint64_t hash);
7270

7371
/**
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.
7476
*
77+
* After this call, the hash table will not accept any more insertions. The
78+
* hash-table will be frozen.
7579
*/
7680
void BuildLazy();
7781

7882
/**
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.
7990
*
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.
8294
*/
8395
void ReserveLazy(const executor::ExecutorContext::ThreadStates &thread_states,
8496
uint32_t hash_table_offset);
8597

8698
/**
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.
87104
*
88-
* @param
105+
* This function is called from different threads!
106+
*
107+
* @param The hash table whose contents we will merge into this one..
89108
*/
90109
void MergeLazyUnfinished(const HashTable &other);
91110

@@ -96,6 +115,7 @@ class HashTable {
96115
//////////////////////////////////////////////////////////////////////////////
97116

98117
uint64_t NumElements() const { return num_elems_; }
118+
uint64_t Capacity() const { return capacity_; }
99119

100120
//////////////////////////////////////////////////////////////////////////////
101121
///
@@ -150,13 +170,29 @@ class HashTable {
150170
*/
151171
class EntryBuffer {
152172
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+
*/
153179
EntryBuffer(::peloton::type::AbstractPool &memory, uint32_t entry_size);
154180

181+
/**
182+
* Destructor.
183+
*/
155184
~EntryBuffer();
156185

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+
*/
157192
Entry *NextFree();
158193

159194
private:
195+
// This struct allows us to chain together chunks of memory
160196
struct MemoryBlock {
161197
MemoryBlock *next;
162198
char data[0];
@@ -200,9 +236,6 @@ class HashTable {
200236

201237
// Info about partitions
202238
// ...
203-
204-
// Stats
205-
std::unique_ptr<libcount::HLL> unique_key_estimate_;
206239
};
207240

208241
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)