Skip to content

Commit

Permalink
save hashmap code
Browse files Browse the repository at this point in the history
  • Loading branch information
HappenLee committed Aug 24, 2022
1 parent b619bb2 commit ebc4349
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions be/src/vec/exec/join/join_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()) {
Expand All @@ -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;
}
};
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ebc4349

Please sign in to comment.