Skip to content

Commit

Permalink
Fix calculation of hash slots on 32bit env (#3460)
Browse files Browse the repository at this point in the history
  • Loading branch information
acquamarin authored May 8, 2024
1 parent 1961496 commit 0b8170c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ uint64_t nextPowerOfTwo(uint64_t v) {
return v;
}

uint64_t prevPowerOfTwo(uint64_t v) {
return nextPowerOfTwo((v / 2) + 1);
}

bool isLittleEndian() {
// Little endian arch stores the least significant value in the lower bytes.
int testNumber = 1;
Expand Down
1 change: 1 addition & 0 deletions src/include/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class BitmaskUtils {
};

uint64_t nextPowerOfTwo(uint64_t v);
uint64_t prevPowerOfTwo(uint64_t v);

bool isLittleEndian();

Expand Down
2 changes: 1 addition & 1 deletion src/processor/operator/aggregate/aggregate_hash_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void AggregateHashTable::initializeFT(
}

void AggregateHashTable::initializeHashTable(uint64_t numEntriesToAllocate) {
auto numHashSlotsPerBlock = HASH_BLOCK_SIZE / sizeof(HashSlot);
auto numHashSlotsPerBlock = prevPowerOfTwo(HASH_BLOCK_SIZE / sizeof(HashSlot));
setMaxNumHashSlots(nextPowerOfTwo(std::max(numHashSlotsPerBlock, numEntriesToAllocate)));
initSlotConstant(numHashSlotsPerBlock);
auto numDataBlocks =
Expand Down

0 comments on commit 0b8170c

Please sign in to comment.