Disable combiner lifting only for count triggers#37715
Disable combiner lifting only for count triggers#37715reuvenlax wants to merge 4 commits intoapache:masterfrom
Conversation
Summary of ChangesHello @reuvenlax, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the conditions under which combiner lifting is applied in the Dataflow runner. By introducing a dedicated method for triggers to declare their compatibility, the system can now more accurately enable this optimization for a broader range of triggers, while correctly disabling it for count-based triggers where it is not appropriate due to loss of element-count information. This change improves the flexibility and efficiency of pipeline execution without compromising correctness. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the logic for enabling combiner lifting in streaming Dataflow jobs. It replaces a hardcoded check for DefaultTrigger with a more flexible approach by introducing a new method isCompatibleWithCombinerLifting() on the Trigger interface. This allows each trigger implementation to declare its compatibility. The changes are well-structured and correctly implement this for most trigger types. However, I've identified a potential NullPointerException in the implementation for AfterWatermark.AfterWatermarkEarlyAndLate that should be addressed.
| public boolean isCompatibleWithCombinerLifting() { | ||
| return earlyTrigger.isCompatibleWithCombinerLifting() | ||
| && lateTrigger.isCompatibleWithCombinerLifting(); | ||
| } |
There was a problem hiding this comment.
This implementation can cause a NullPointerException because lateTrigger can be null. A more robust and concise approach, consistent with other composite triggers, is to check all subTriggers.
public boolean isCompatibleWithCombinerLifting() {
return subTriggers.stream().allMatch(Trigger::isCompatibleWithCombinerLifting);
}|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request correctly relaxes the restrictions on combiner lifting for the Dataflow runner by introducing a new method, isCompatibleWithCombinerLifting(), into the Trigger hierarchy. This is a clean and effective solution. The implementations across the various trigger types are logical, properly identifying count-based triggers as incompatible. The change in DataflowPipelineTranslator to adopt this new method is also well-executed. I have a couple of minor suggestions to enhance consistency in the new method's implementation across different composite triggers.
| @Override | ||
| public boolean isCompatibleWithCombinerLifting() { | ||
| return earlyTrigger.isCompatibleWithCombinerLifting() | ||
| && (lateTrigger == null || lateTrigger.isCompatibleWithCombinerLifting()); | ||
| } |
There was a problem hiding this comment.
For consistency with other composite triggers like AfterAll and AfterFirst, consider using a stream over subTriggers to check for compatibility. This would make the implementation more uniform across different trigger types.
| @Override | |
| public boolean isCompatibleWithCombinerLifting() { | |
| return earlyTrigger.isCompatibleWithCombinerLifting() | |
| && (lateTrigger == null || lateTrigger.isCompatibleWithCombinerLifting()); | |
| } | |
| @Override | |
| public boolean isCompatibleWithCombinerLifting() { | |
| return subTriggers.stream().allMatch(Trigger::isCompatibleWithCombinerLifting); | |
| } | |
| @Override | ||
| public boolean isCompatibleWithCombinerLifting() { | ||
| return subTriggers.get(ACTUAL).isCompatibleWithCombinerLifting() | ||
| && subTriggers.get(UNTIL).isCompatibleWithCombinerLifting(); | ||
| } |
There was a problem hiding this comment.
For consistency with other composite triggers, you could use a stream over subTriggers here as well. This would make the code more uniform and align with the pattern used in AfterAll, AfterFirst, and AfterEach.
| @Override | |
| public boolean isCompatibleWithCombinerLifting() { | |
| return subTriggers.get(ACTUAL).isCompatibleWithCombinerLifting() | |
| && subTriggers.get(UNTIL).isCompatibleWithCombinerLifting(); | |
| } | |
| @Override | |
| public boolean isCompatibleWithCombinerLifting() { | |
| return subTriggers.stream().allMatch(Trigger::isCompatibleWithCombinerLifting); | |
| } | |
The runner currently only allows combiner lifting for DefaultTrigger. This is an overly-strict restriction - in reality combiner lifting is supported for everything except count triggers (since element-count information is lost when combining). This PR sharpens that restriction to be less conservative.