Skip to content

Conversation

@ttnghia
Copy link
Contributor

@ttnghia ttnghia commented Jan 16, 2026

This PR removes the simple_aggregations_collector and aggregation_finalizer visitor-pattern classes and replaces them with template functors specialized only for aggregation types requiring special handling.

Changes

  • Removed simple_aggregations_collector and aggregation_finalizer base classes
  • Removed get_simple_aggregations() and finalize() virtual methods from all aggregation classes
  • Added template functors with explicit specializations:
    • simple_aggregation_collector_fn – decomposes compound aggregations (MEAN→SUM+COUNT, etc.)
    • hash_compound_agg_finalizer_fn – postprocesses compound aggregation results
    • rolling_preprocessor_fn / rolling_postprocessor_fn – rolling window aggregation operators
  • Refactored aggregation dispatch to use cudf::detail::aggregation_dispatcher() with these functors

Benefits

  • Reduced boilerplate: no more no-op virtual method overrides in every aggregation class
  • Localized logic: special handling co-located in functor specializations
  • Easier to extend: new aggregations only need specializations if special handling is required

Closes #21059.

@ttnghia ttnghia self-assigned this Jan 16, 2026
Copilot AI review requested due to automatic review settings January 16, 2026 04:34
@ttnghia ttnghia added the 3 - Ready for Review Ready for review by team label Jan 16, 2026
@ttnghia ttnghia requested a review from a team as a code owner January 16, 2026 04:34
@ttnghia ttnghia added libcudf Affects libcudf (C++/CUDA) code. improvement Improvement / enhancement to an existing function labels Jan 16, 2026
@ttnghia ttnghia requested review from mythrocks and vuule January 16, 2026 04:34
@ttnghia ttnghia added the non-breaking Non-breaking change label Jan 16, 2026
@ttnghia ttnghia added this to libcudf Jan 16, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the groupby aggregation system by removing visitor pattern base classes (simple_aggregations_collector and aggregation_finalizer) and replacing them with template functors that use explicit specializations. This eliminates boilerplate code from aggregation class definitions and localizes special handling logic.

Changes:

  • Removed visitor pattern infrastructure and virtual methods from aggregation classes
  • Introduced template functors with specializations for preprocessing and finalizing aggregations
  • Replaced visitor dispatch with cudf::detail::aggregation_dispatcher() calls

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
cpp/src/rolling/detail/rolling.cuh Refactored rolling window preprocessing/postprocessing from visitor classes to template functors with specializations
cpp/src/groupby/hash/hash_compound_agg_finalizer.hpp Changed from visitor class to context struct plus template functor with specialization declarations
cpp/src/groupby/hash/hash_compound_agg_finalizer.cu Implemented template functor specializations for compound aggregation finalization
cpp/src/groupby/hash/extract_single_pass_aggs.cpp Replaced visitor class with template functor for collecting simple aggregations
cpp/src/groupby/hash/compute_groupby.cu Updated to use new functor-based dispatch instead of visitor pattern
cpp/src/aggregation/aggregation.cpp Removed visitor pattern base class implementations (400+ lines of boilerplate)
cpp/include/cudf/detail/aggregation/aggregation.hpp Removed visitor base class declarations and virtual method declarations from aggregation classes
cpp/include/cudf/aggregation.hpp Removed forward declarations of visitor classes and virtual method declarations from base aggregation class

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Nghia Truong <[email protected]>
Signed-off-by: Nghia Truong <[email protected]>
Signed-off-by: Nghia Truong <[email protected]>
@ttnghia ttnghia force-pushed the refactor_agregations branch from 9bd8fc5 to 923bc25 Compare January 16, 2026 04:44
@rapidsai rapidsai deleted a comment from copy-pr-bot bot Jan 16, 2026
Comment on lines +124 to +135
/**
* @brief No-parameter constructor.
*
* This constructor is never called anywhere, and should never be called at all. However, it
* cannot be be declared as deleted due to the usage of CRTP (Curiously Recurring Template
* Pattern) helper to automatically implement `clone()` method for derived aggregation classes. As
* such, definition of this constructor is just to satisfy the compiler requirements.
*/
aggregation() : kind{static_cast<Kind>(-1)}
{
CUDF_FAIL("No-parameter aggregation constructor should never be called");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not an issue before, until this PR that removes all virtual function implementation from the most derived classes. Now, only the middle base class (derive_from) has virtual function implementation, causing the compiler to require a default constructor for it, which in turn requires to call into the default constructor of aggregation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 - Ready for Review Ready for review by team improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[FEA] Remove simple_aggregations_collector and aggregation_finalizer classes in groupby aggregation

1 participant