[ 
https://issues.apache.org/jira/browse/BEAM-11952?focusedWorklogId=564108&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-564108
 ]

ASF GitHub Bot logged work on BEAM-11952:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Mar/21 22:24
            Start Date: 10/Mar/21 22:24
    Worklog Time Spent: 10m 
      Work Description: boyuanzz commented on a change in pull request #14182:
URL: https://github.com/apache/beam/pull/14182#discussion_r591916291



##########
File path: 
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/WindowMergingFnRunner.java
##########
@@ -151,10 +151,12 @@ public void merge(Collection<W> toBeMerged, W 
mergeResult) throws Exception {
         KV<T, Iterable<W>> windowsToMerge) throws Exception {
       currentWindows = Sets.newHashSet(windowsToMerge.getValue());
       windowFn.mergeWindows((MergeContext) mergeContext);

Review comment:
       We can do `mergedWindows.clear();` before we invoke 
`windowFn.mergeWindows` instead of making a copy, right?

##########
File path: 
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/WindowMergingFnRunner.java
##########
@@ -151,10 +151,12 @@ public void merge(Collection<W> toBeMerged, W 
mergeResult) throws Exception {
         KV<T, Iterable<W>> windowsToMerge) throws Exception {
       currentWindows = Sets.newHashSet(windowsToMerge.getValue());
       windowFn.mergeWindows((MergeContext) mergeContext);
+      ArrayList mergedWindowsCopy = new ArrayList<>(mergedWindows);
       for (KV<W, Collection<W>> mergedWindow : mergedWindows) {
         currentWindows.removeAll(mergedWindow.getValue());
       }
-      return KV.of(windowsToMerge.getKey(), KV.of(currentWindows, (Iterable) 
mergedWindows));
+      mergedWindows.clear();

Review comment:
       It seems like it's a bug which can result in wrong results before this 
change, right? If it's not too complicated, can we add a unit test like 
FnApiDoFnRunnerTest to guard this cleanup logic?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 564108)
    Time Spent: 0.5h  (was: 20m)

> WindowMergingFnRunner unnecessarily keeps previous merged results
> -----------------------------------------------------------------
>
>                 Key: BEAM-11952
>                 URL: https://issues.apache.org/jira/browse/BEAM-11952
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-harness
>            Reporter: Yichi Zhang
>            Priority: P2
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to