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

[FLINK-5968] Add documentation for WindowedStream.aggregate() #4833

Closed

Conversation

aljoscha
Copy link
Contributor

No description provided.

@aljoscha
Copy link
Contributor Author

R: @twalthr you might be interested 😃

Context context,
Iterable<Double> averages,
Collector<Tuple2<String, Double>> out) {
Double average = averags.iterator().next();
Copy link
Contributor

Choose a reason for hiding this comment

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

should be averages, not averags

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! fixing

@aljoscha aljoscha force-pushed the jira-5968-document-window-aggregate branch 2 times, most recently from c4f44b4 to 02681ab Compare October 19, 2017 12:37
@aljoscha
Copy link
Contributor Author

CC: @fhueske You wanted me to cc you for the Table API changes.

Copy link
Contributor

@fhueske fhueske left a comment

Choose a reason for hiding this comment

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

Thanks for the heads up @aljoscha.

I had a look at the flink-table modifications and think we can revert most changes. GeneratedAggregations is just an internal interface and the public UDAGG interface that it calls does not support immutable accumulators (it suffer from the same problem as the DataStream AggregateFunction). I don't want to touch the UDAGG interface before the release.

Thanks, Fabian

@@ -52,11 +52,12 @@ import org.apache.flink.table.dataview.ListViewTypeInfoFactory
* return accum;
* }
*
* public void accumulate(MyAccum accumulator, String id) {
* public MyAccum accumulate(MyAccum accumulator, String id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert these changes.
The accumulate method belongs to a Table API org.apache.flink.table.functions.AggregateFunction and not GeneratedAggregations.

@@ -52,7 +52,7 @@ import org.apache.flink.table.dataview.MapViewTypeInfoFactory
* return accum;
* }
*
* public void accumulate(MyAccum accumulator, String id) {
* public MyAccum accumulate(MyAccum accumulator, String id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert these changes.
The accumulate method belongs to a Table API org.apache.flink.table.functions.AggregateFunction and not GeneratedAggregations.

@@ -67,7 +67,7 @@ abstract class GeneratedAggregations extends Function {
* aggregated results
* @param input input values bundled in a row
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add @returns documentation

Copy link
Contributor

Choose a reason for hiding this comment

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

Please change retract() accordingly to keep the interfaces consistent.

Alternatively, you can also revert the changes on GeneratedAggregations which is only an internal interface. The Table API org.apache.flink.table.functions.AggregateFunction does not support immutable accumulators, so this change has no effect until the public interface is changed. If you revert, we only need to touch AggregateAggFunction and not the code generator.

@aljoscha aljoscha force-pushed the jira-5968-document-window-aggregate branch from 02681ab to 644ed15 Compare October 20, 2017 09:58
@aljoscha aljoscha force-pushed the jira-5968-document-window-aggregate branch 3 times, most recently from 3f16528 to f764184 Compare October 20, 2017 20:26
@aljoscha aljoscha force-pushed the jira-5968-document-window-aggregate branch from f764184 to b4afc52 Compare October 20, 2017 21:25
@aljoscha aljoscha closed this Oct 21, 2017
@aljoscha aljoscha deleted the jira-5968-document-window-aggregate branch October 21, 2017 07:35
Same as with `ReduceFunction`, Flink will incrementally aggregate input elements of a window as they
arrive.

A `AggregateFunction` can be defined and used like this:
Copy link
Member

Choose a reason for hiding this comment

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

An


@Override
public Tuple2<Long, Long> add(
Tuple2<String, Long> value, Tuple2<Long, Long> accumulator) {
Copy link
Member

Choose a reason for hiding this comment

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

shall we keep the method signature in a single line? They can fit into one line, and I usually find it difficult to read method signature in two lines


@Override
public Tuple2<Long, Long> merge(
Tuple2<Long, Long> a, Tuple2<Long, Long> b) {
Copy link
Member

Choose a reason for hiding this comment

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

ditto


@Override
public Tuple2<Long, Long> add(
Tuple2<String, Long> value, Tuple2<Long, Long> accumulator) {
Copy link
Member

Choose a reason for hiding this comment

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

ditto


@Override
public Tuple2<Long, Long> merge(
Tuple2<Long, Long> a, Tuple2<Long, Long> b) {
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@bowenli86
Copy link
Member

I just saw this PR, and sorry for submitting my feedbacks late...

@aljoscha
Copy link
Contributor Author

Thanks, @bowenli86! Your recommendations are good and I'll push a hot fix commit with the fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants