From ebc43495333436412e977818a2db5993a31a1979 Mon Sep 17 00:00:00 2001 From: happenlee Date: Thu, 25 Aug 2022 00:22:17 +0800 Subject: [PATCH] save hashmap code --- be/src/vec/exec/join/join_op.h | 14 +++++++------- build.sh | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/be/src/vec/exec/join/join_op.h b/be/src/vec/exec/join/join_op.h index caf8e7d3ec8fb3..bfc844a01a273a 100644 --- a/be/src/vec/exec/join/join_op.h +++ b/be/src/vec/exec/join/join_op.h @@ -26,15 +26,16 @@ namespace doris::vectorized { struct RowRef { using SizeT = uint32_t; /// Do not use size_t cause of memory economy - SizeT row_num = 0; uint8_t block_offset; + uint8_t batch_offset = 0; // Use in right join to mark row is visited // TODO: opt the varaible to use it only need bool visited = false; + SizeT row_num = 0; RowRef() {} RowRef(size_t row_num_count, uint8_t block_offset_, bool is_visited = false) - : row_num(row_num_count), block_offset(block_offset_), visited(is_visited) {} + : block_offset(block_offset_), visited(is_visited), row_num(row_num_count) {} }; /// Single linked list of references to rows. Used for ALL JOINs (non-unique JOINs) @@ -43,13 +44,12 @@ struct RowRefList : RowRef { struct Batch { static constexpr size_t MAX_SIZE = 7; /// Adequate values are 3, 7, 15, 31. - SizeT size = 0; /// It's smaller than size_t but keeps align in Arena. - Batch* next; RowRef row_refs[MAX_SIZE]; + Batch* next; Batch(Batch* parent) : next(parent) {} - bool full() const { return size == MAX_SIZE; } + bool full() const { return row_refs[0].batch_offset == MAX_SIZE; } Batch* insert(RowRef&& row_ref, Arena& pool) { if (full()) { @@ -59,7 +59,7 @@ struct RowRefList : RowRef { return batch; } - row_refs[size++] = std::move(row_ref); + row_refs[row_refs[0].batch_offset++] = std::move(row_ref); return this; } }; @@ -94,7 +94,7 @@ struct RowRefList : RowRef { if (batch) { ++position; - if (position >= batch->size) { + if (position >= batch->row_refs[0].batch_offset) { batch = batch->next; position = 0; } diff --git a/build.sh b/build.sh index 661cac059d5f69..10112b6c5ad728 100755 --- a/build.sh +++ b/build.sh @@ -117,7 +117,7 @@ fi eval set -- "${OPTS}" -PARALLEL="$(($(nproc) / 4 + 1))" +PARALLEL="$(($(nproc) / 3 + 1))" BUILD_FE=0 BUILD_BE=0 BUILD_BROKER=0