Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: improve GroupsAccumulator docs #12501

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion datafusion/expr-common/src/groups_accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,32 @@ impl EmitTo {
}
}

/// `GroupAccumulator` implements a single aggregate (e.g. AVG) and
/// `GroupsAccumulator` implements a single aggregate (e.g. AVG) and
/// stores the state for *all* groups internally.
///
/// Logically, a [`GroupsAccumulator`] stores a mapping from each group index to
/// the state of the aggregate for that group. For example an implementation for
/// `min` might look like
///
/// ```text
/// ┌─────┐
/// │ 0 │───────────▶ 100
/// ├─────┤
/// │ 1 │───────────▶ 200
/// └─────┘
/// ... ...
/// ┌─────┐
/// │ N-2 │───────────▶ 50
/// ├─────┤
/// │ N-1 │───────────▶ 200
/// └─────┘
///
///
/// Logical group Current Min
/// number value for that
/// group
/// ```
///
/// # Notes on Implementing `GroupAccumulator`
///
/// All aggregates must first implement the simpler [`Accumulator`] trait, which
Expand Down