Skip to content

Commit

Permalink
Fix distinct hash table resizing (#3348)
Browse files Browse the repository at this point in the history
  • Loading branch information
acquamarin committed Apr 23, 2024
1 parent 46efbc1 commit 15a648f
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/processor/operator/aggregate/aggregate_hash_table.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "processor/operator/aggregate/aggregate_hash_table.h"

#include "common/utils.h"
#include "function/hash/vector_hash_functions.h"

using namespace kuzu::common;
using namespace kuzu::function;
Expand Down Expand Up @@ -49,23 +48,11 @@ bool AggregateHashTable::isAggregateValueDistinctForGroupByKeys(
distinctKeyVectors[i] = groupByFlatKeyVectors[i];
}
distinctKeyVectors[groupByFlatKeyVectors.size()] = aggregateVector;
if (groupByFlatKeyVectors.empty()) {
VectorHashFunction::computeHash(aggregateVector, hashVector.get());
} else {
VectorHashFunction::computeHash(groupByFlatKeyVectors[0], hashVector.get());
computeAndCombineVecHash(groupByFlatKeyVectors, 1 /* startVecIdx */);
auto tmpHashResultVector =
std::make_unique<ValueVector>(LogicalTypeID::INT64, &memoryManager);
auto tmpHashCombineResultVector =
std::make_unique<ValueVector>(LogicalTypeID::INT64, &memoryManager);
VectorHashFunction::computeHash(aggregateVector, tmpHashResultVector.get());
VectorHashFunction::combineHash(hashVector.get(), tmpHashResultVector.get(),
tmpHashCombineResultVector.get());
hashVector = std::move(tmpHashResultVector);
}
computeVectorHashes(distinctKeyVectors, std::vector<ValueVector*>() /* unFlatKeyVectors */);
hash_t hash = hashVector->getValue<hash_t>(hashVector->state->selVector->selectedPositions[0]);
auto distinctHTEntry = findEntryInDistinctHT(distinctKeyVectors, hash);
if (distinctHTEntry == nullptr) {
resizeHashTableIfNecessary(1);
createEntryInDistinctHT(distinctKeyVectors, hash);
return true;
}
Expand Down

0 comments on commit 15a648f

Please sign in to comment.