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

Commit 848c835

Browse files
committed
Cleaned up util::Sorter::SortParallel(...) by adding clarity comments to describe algorithm. Added comments to util::HashTable w.r.t. lazy vs. normal mode.
1 parent 5243395 commit 848c835

File tree

10 files changed

+276
-138
lines changed

10 files changed

+276
-138
lines changed

src/catalog/layout_catalog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "executor/logical_tile.h"
1919
#include "storage/data_table.h"
2020
#include "storage/layout.h"
21+
#include "type/value_factory.h"
2122

2223
namespace peloton {
2324
namespace catalog {

src/codegen/query.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void Query::Execute(executor::ExecutorContext &executor_context,
5151
func_args->consumer_arg = consumer.GetConsumerState();
5252

5353
// Timer
54-
Timer<std::ratio<1, 1000>> timer;
54+
Timer<std::milli> timer;
5555
timer.Start();
5656

5757
// Call init

src/codegen/runtime_functions.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ void RuntimeFunctions::GetTileGroupLayout(const storage::TileGroup *tile_group,
147147

148148
void RuntimeFunctions::ExecuteTableScan(
149149
void *query_state, executor::ExecutorContext::ThreadStates &thread_states,
150-
uint32_t db_oid, uint32_t table_oid, void *f) {
150+
uint32_t db_oid, uint32_t table_oid, void *func) {
151151
// void (*scanner)(void *, void *, uint64_t, uint64_t)) {
152152
using ScanFunc = void (*)(void *, void *, uint64_t, uint64_t);
153-
auto *scanner = reinterpret_cast<ScanFunc>(f);
153+
auto *scanner = reinterpret_cast<ScanFunc>(func);
154154

155155
// The worker pool
156156
auto &worker_pool = threadpool::MonoQueuePool::GetExecutionInstance();
@@ -179,11 +179,11 @@ void RuntimeFunctions::ExecuteTableScan(
179179
last_task ? num_tilegroups : tilegroup_start + num_tilegroups_per_task;
180180
auto work = [&query_state, &thread_states, &scanner, &latch, task_id,
181181
tilegroup_start, tilegroup_stop]() {
182-
LOG_INFO("Task-%u scanning tile groups [%u-%u)", task_id, tilegroup_start,
183-
tilegroup_stop);
182+
LOG_DEBUG("Task-%u scanning tile groups [%u-%u)", task_id,
183+
tilegroup_start, tilegroup_stop);
184184

185185
// Time this
186-
Timer<std::ratio<1, 1000>> timer;
186+
Timer<std::milli> timer;
187187
timer.Start();
188188

189189
// Pull out this task's thread state
@@ -197,8 +197,8 @@ void RuntimeFunctions::ExecuteTableScan(
197197

198198
// Log stuff
199199
timer.Stop();
200-
LOG_INFO("Task-%u done scanning (%.2lf ms) ...", task_id,
201-
timer.GetDuration());
200+
LOG_DEBUG("Task-%u done scanning (%.2lf ms) ...", task_id,
201+
timer.GetDuration());
202202
};
203203
worker_pool.SubmitTask(work);
204204
}
@@ -222,10 +222,10 @@ void RuntimeFunctions::ExecutePerState(
222222
for (uint32_t tid = 0; tid < num_tasks; tid++) {
223223
worker_pool.SubmitTask(
224224
[&query_state, &work_func, &thread_states, &latch, tid]() {
225-
LOG_INFO("Processing thread state %u ...", tid);
225+
LOG_DEBUG("Processing thread state %u ...", tid);
226226

227227
// Time this
228-
Timer<std::ratio<1, 1000>> timer;
228+
Timer<std::milli> timer;
229229
timer.Start();
230230

231231
// Pull out the thread state
@@ -238,8 +238,8 @@ void RuntimeFunctions::ExecutePerState(
238238
latch.CountDown();
239239

240240
timer.Stop();
241-
LOG_INFO("Finished processing thread state %u (%.2lf ms) ...", tid,
242-
timer.GetDuration());
241+
LOG_DEBUG("Finished processing thread state %u (%.2lf ms) ...", tid,
242+
timer.GetDuration());
243243
});
244244
}
245245

src/codegen/util/hash_table.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ void HashTable::EntryBuffer::TransferMemoryBlocks(
106106
///
107107
////////////////////////////////////////////////////////////////////////////////
108108

109-
/**
110-
* This hash-table uses an open-addressing probing scheme
111-
*
112-
*/
113-
114109
HashTable::HashTable(::peloton::type::AbstractPool &memory, uint32_t key_size,
115110
uint32_t value_size)
116111
: memory_(memory),
@@ -157,8 +152,11 @@ char *HashTable::InsertLazy(uint64_t hash) {
157152

158153
// Insert the entry into the linked list in the first directory slot
159154
if (directory_[0] == nullptr) {
160-
// This is the first entry
161-
directory_[0] = directory_[1] = entry;
155+
// This is the first entry. The first slot in the directory is the head of
156+
// the linked list of entries. All other's link their tail to the second
157+
// element in the directory.
158+
directory_[0] = entry;
159+
directory_[1] = entry;
162160
} else {
163161
PELOTON_ASSERT(directory_[1] != nullptr);
164162
directory_[1]->next = entry;
@@ -251,7 +249,6 @@ void HashTable::ReserveLazy(
251249
void HashTable::MergeLazyUnfinished(HashTable &other) {
252250
// Begin with the head of the linked list of entries, stored in the first
253251
// directory entry
254-
PELOTON_ASSERT(other.directory_[0] != nullptr);
255252
auto *head = other.directory_[0];
256253

257254
while (head != nullptr) {
@@ -274,6 +271,7 @@ void HashTable::MergeLazyUnfinished(HashTable &other) {
274271
::peloton::atomic_add(&num_elems_, other.NumElements());
275272

276273
// Transfer all allocated memory blocks in the other table into this one
274+
PELOTON_ASSERT(&memory_ == &other.memory_);
277275
other.num_elems_ = other.capacity_ = 0;
278276
other.entry_buffer_.TransferMemoryBlocks(entry_buffer_);
279277
}

0 commit comments

Comments
 (0)