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

GH-36931: [C++] Add cumulative_mean function #36932

Merged
merged 5 commits into from
Aug 9, 2023

Conversation

js8544
Copy link
Collaborator

@js8544 js8544 commented Jul 28, 2023

Rationale for this change

Add cumulative_mean function

What changes are included in this PR?

Implement cumulative_mean function. The current cumulative_* kernel generator can only be based on a simple binary arithmetic op and the state can only be a single value. I refactored it to using of a generic state such that it can handle complex operations such as mean, median, var etc.

Are these changes tested?

Yes

Are there any user-facing changes?

No

@github-actions
Copy link

⚠️ GitHub issue #36931 has been automatically assigned in GitHub to PR creator.

Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

Thanks @js8544 !

cpp/src/arrow/compute/kernels/vector_cumulative_ops.cc Outdated Show resolved Hide resolved
cpp/src/arrow/compute/api_vector.h Show resolved Hide resolved
cpp/src/arrow/compute/kernels/vector_cumulative_ops.cc Outdated Show resolved Hide resolved
docs/source/cpp/compute.rst Outdated Show resolved Hide resolved
@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Aug 9, 2023
@js8544 js8544 requested a review from pitrou August 9, 2023 13:03
Comment on lines +318 to +330
// A kernel factory that forwards to CumulativeBinaryOp<Op, ...> for the given type.
// Need to use a struct because template-using declarations cannot appear in
// function scope.
template <typename Op, typename OptionsType>
struct MakeVectorCumulativeBinaryOpFunction {
template <typename ArgType>
using State = CumulativeBinaryOp<Op, ArgType>;

static void Call(FunctionRegistry* registry, std::string func_name, FunctionDoc doc) {
MakeVectorCumulativeStatefulFunction<State, OptionsType>(
registry, std::move(func_name), std::move(doc));
}
};
Copy link
Member

Choose a reason for hiding this comment

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

@bkietz Can you think of a more straightforward way to do this?

@pitrou
Copy link
Member

pitrou commented Aug 9, 2023

+1

@pitrou pitrou merged commit 6e6e6f0 into apache:main Aug 9, 2023
@pitrou pitrou removed the awaiting committer review Awaiting committer review label Aug 9, 2023
@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit 6e6e6f0.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about possible false positives for unstable benchmarks that are known to sometimes produce them.

loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
### Rationale for this change

Add `cumulative_mean` function

### What changes are included in this PR?

Implement `cumulative_mean` function. The current cumulative_* kernel generator can only be based on a simple binary arithmetic op and the state can only be a single value. I refactored it to using of a generic state such that it can handle complex operations such as `mean`, `median`, `var` etc.

### Are these changes tested?

Yes

### Are there any user-facing changes?
No

* Closes: apache#36931

Lead-authored-by: Jin Shang <[email protected]>
Co-authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[C++][Compute] Add cumulative_mean function
2 participants