Skip to content

Commit

Permalink
Made heap allocator be an aligned allocator for MinMaxNAccumulator
Browse files Browse the repository at this point in the history
  • Loading branch information
Minhan Cao authored and Minhan Cao committed Mar 13, 2024
1 parent 3bd7ed4 commit 1ae75ee
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions velox/functions/prestosql/aggregates/MinMaxAggregates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,15 @@ std::pair<vector_size_t*, vector_size_t*> rawOffsetAndSizes(
template <typename T, typename Compare>
struct MinMaxNAccumulator {
int64_t n{0};
std::vector<T, StlAllocator<T>> heapValues;
using Allocator = std::conditional_t<
std::is_same_v<int128_t, T>,
AlignedStlAllocator<T, sizeof(int128_t)>,
StlAllocator<T>>;
using Heap = std::vector<T, Allocator>;
Heap heapValues;

explicit MinMaxNAccumulator(HashStringAllocator* allocator)
: heapValues{StlAllocator<T>(allocator)} {}
: heapValues{Allocator(allocator)} {}

int64_t getN() const {
return n;
Expand Down Expand Up @@ -926,7 +931,8 @@ exec::AggregateRegistrationResult registerMinMax(const std::string& name) {
.build());
}

// decimal(p,s), bigint -> row(array(decimal(p,s)), bigint) -> array(decimal(p,s))
// decimal(p,s), bigint -> row(array(decimal(p,s)), bigint) ->
// array(decimal(p,s))
signatures.push_back(
exec::AggregateFunctionSignatureBuilder()
.integerVariable("a_precision")
Expand Down

0 comments on commit 1ae75ee

Please sign in to comment.