diff --git a/velox/docs/develop/aggregate-functions.rst b/velox/docs/develop/aggregate-functions.rst index a64ce58be8e4..06e819a73274 100644 --- a/velox/docs/develop/aggregate-functions.rst +++ b/velox/docs/develop/aggregate-functions.rst @@ -255,7 +255,7 @@ For aggregaiton functions of default-null behavior, the author defines an static constexpr bool use_external_memory_ = true; // Optional. Default is false. - static constexpr bool aligned_accumulator_ = true; + static constexpr bool is_aligned_ = true; explicit AccumulatorType(HashStringAllocator* allocator); @@ -278,7 +278,7 @@ every accumulator takes fixed amount of memory. This flag is true by default. Next, the author defines another optional flag `use_external_memory_` indicating whether the accumulator uses memory that is not tracked by Velox. This flag is false by default. Then, the author can define an optional flag -`aligned_accumulator_` indicating whether the accumulator requires aligned +`is_aligned_` indicating whether the accumulator requires aligned access. This flag is false by default. The author defines a constructor that takes a single argument of @@ -351,7 +351,7 @@ For aggregaiton functions of non-default-null behavior, the author defines an static constexpr bool use_external_memory_ = true; // Optional. Default is false. - static constexpr bool aligned_accumulator_ = true; + static constexpr bool is_aligned_ = true; explicit AccumulatorType(HashStringAllocator* allocator); @@ -370,7 +370,7 @@ For aggregaiton functions of non-default-null behavior, the author defines an }; The definition of `is_fixed_size_`, `use_external_memory_`, -`aligned_accumulator_`, the constructor, and the `destroy` method are exactly +`is_aligned_`, the constructor, and the `destroy` method are exactly the same as those for default-null behavior. On the other hand, the C++ function signatures of `addInput`, `combine`, diff --git a/velox/exec/SimpleAggregateAdapter.h b/velox/exec/SimpleAggregateAdapter.h index 4d642aefd934..b32fd7400fea 100644 --- a/velox/exec/SimpleAggregateAdapter.h +++ b/velox/exec/SimpleAggregateAdapter.h @@ -151,11 +151,11 @@ class SimpleAggregateAdapter : public Aggregate { // Otherwise, SimpleAggregateAdapter::accumulatorAlignmentSize() returns // Aggregate::accumulatorAlignmentSize(), with a default value of 1. template - struct aligned_accumulator : std::false_type {}; + struct accumulator_is_aligned : std::false_type {}; template - struct aligned_accumulator> - : std::integral_constant {}; + struct accumulator_is_aligned> + : std::integral_constant {}; static constexpr bool aggregate_default_null_behavior_ = aggregate_default_null_behavior::value; @@ -172,7 +172,8 @@ class SimpleAggregateAdapter : public Aggregate { static constexpr bool support_to_intermediate_ = support_to_intermediate::value; - static constexpr bool aligned_accumulator_ = aligned_accumulator::value; + static constexpr bool accumulator_is_aligned_ = + accumulator_is_aligned::value; bool isFixedSize() const override { return accumulator_is_fixed_size_; @@ -187,7 +188,7 @@ class SimpleAggregateAdapter : public Aggregate { } int32_t accumulatorAlignmentSize() const override { - if constexpr (aligned_accumulator_) { + if constexpr (accumulator_is_aligned_) { return alignof(typename FUNC::AccumulatorType); } return Aggregate::accumulatorAlignmentSize(); diff --git a/velox/functions/sparksql/aggregates/DecimalSumAggregate.h b/velox/functions/sparksql/aggregates/DecimalSumAggregate.h index 638f78753367..5019ae1a2ca1 100644 --- a/velox/functions/sparksql/aggregates/DecimalSumAggregate.h +++ b/velox/functions/sparksql/aggregates/DecimalSumAggregate.h @@ -43,8 +43,6 @@ class DecimalSumAggregate { /// default-null behavior is disabled. static constexpr bool default_null_behavior_ = false; - static constexpr bool aligned_accumulator_ = true; - static bool toIntermediate( exec::out_type>& out, exec::optional_arg_type in) { @@ -68,6 +66,8 @@ class DecimalSumAggregate { int64_t overflow{0}; bool isEmpty{true}; + static constexpr bool is_aligned_ = true; + AccumulatorType() = delete; explicit AccumulatorType(HashStringAllocator* /*allocator*/) {}