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-35355][State] Internal async aggregating state and corresponding state descriptor #24810

Closed
wants to merge 1 commit into from

Conversation

jectpro7
Copy link
Contributor

This PR defines the V2 AggreatingState and its StateDescriptor. And provides the default InternalAggregatingState implementation which delegates all aycn request to AEC.

What is the purpose of the change

Supporting aggregate functionality regarding to FLIP-424.

Brief change log

  1. Definition of v2 AggregatingState and AggregatingStateDescriptor
  2. Default implementation of v2 AggregatingState

Verifying this change

  1. Added UT for new class and changed code.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

@flinkbot
Copy link
Collaborator

flinkbot commented May 19, 2024

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Copy link
Contributor

@Zakelly Zakelly 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 PR! Overall LGTM % several minor comments.

import java.io.Serializable;

/** Test implementation of Aggregate function */
public class SumAggregator implements AggregateFunction<Integer, Integer, Integer>, Serializable {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest this to be an inner class if only for testing purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it was an inner class, but it is used in both AggregatingStateDescriptorTest and InternalAggregatingStateTest, so I created this class to reuse the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Option 1: This could be a static package-private class within AggregatingStateDescriptorTest reused in both tests. This is common when some test reference the inner static class/variable from another test.
Option 2: Two test inner classes. This makes sense if it is private.

Also, anonymous class is better than inner class.

The reason why I'd suggest make it inner/anonymous is that, typically functional interfaces like this vary in different scenarios, so there's nothing to share. I'd prefer option 2 with anonymous class, since making these tests self contained looks better to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, I made it inner class in latest commit. For AggregatingStateDescriptorTest, I found it doesn't need a real instance, so I mocked it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems flink doesn't encourage the mock, will change it later.

public class InternalAggregatingState<K, IN, ACC, OUT> extends InternalKeyedState<K, ACC>
implements AggregatingState<IN, OUT> {

private final AggregateFunction<IN, ACC, OUT> aggregateFunction;
Copy link
Contributor

Choose a reason for hiding this comment

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

Better be protected since the sub-classes will leverage this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense to me, will fix it in next commit.

@jectpro7
Copy link
Contributor Author

Hi @Zakelly, Thanks for the comments, I have added a commit for addressing it.

@jectpro7 jectpro7 force-pushed the f35355 branch 3 times, most recently from 544cfb5 to a1a0d30 Compare May 22, 2024 17:31
@jectpro7
Copy link
Contributor Author

jectpro7 commented May 23, 2024

Hi @Zakelly, I've addressed comments, please help double review it. Thanks in advance.

Copy link
Contributor

@Zakelly Zakelly 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 update! LGTM

@Zakelly
Copy link
Contributor

Zakelly commented May 23, 2024

@jectpro7 Seems the author of this commit is different from the committer? Do you mind change that? Or I can merge this as it is.

@jectpro7
Copy link
Contributor Author

@Zakelly, It looks weird, seems the git configuration is not correct. I will fix that.

@jectpro7 jectpro7 force-pushed the f35355 branch 2 times, most recently from 9f8b359 to 45fab29 Compare May 23, 2024 12:35
@jectpro7
Copy link
Contributor Author

@Zakelly, looks good now. Thanks for the reminder. 👍

@Zakelly
Copy link
Contributor

Zakelly commented May 24, 2024

@flinkbot run azure

1 similar comment
@jectpro7
Copy link
Contributor Author

@flinkbot run azure

@Zakelly
Copy link
Contributor

Zakelly commented May 24, 2024

CI green, merging....

@Zakelly Zakelly closed this in 467f94f May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants