Skip to content

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

Merged
pitrou merged 5 commits into
apache:mainfrom
js8544:jinshang/cum_mean
Aug 9, 2023
Merged

pitrou merged 5 commits into
apache:mainfrom
js8544:jinshang/cum_mean

Conversation

@js8544

@js8544 js8544 commented Jul 28, 2023 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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

@pitrou pitrou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @js8544 !

Comment thread cpp/src/arrow/compute/api_vector.h Resolved
Comment thread docs/source/cpp/compute.rst Resolved
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
Copy Markdown
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

pitrou commented Aug 9, 2023

Copy link
Copy Markdown
Member

+1

@pitrou
pitrou merged commit 6e6e6f0 into apache:main Aug 9, 2023
@conbench-apache-arrow

Copy link
Copy Markdown

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