GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Only remove window from active window set if it is still active · mfgteg/DataflowJavaSDK@122f885

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • sdk/src/main/java/com/google/cloud/dataflow/sdk/util
    • MergingActiveWindowSet.java
    • ReduceFnRunner.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎sdk/src/main/java/com/google/cloud/dataflow/sdk/util/MergingActiveWindowSet.java‎

Copy file name to clipboardExpand all lines: sdk/src/main/java/com/google/cloud/dataflow/sdk/util/MergingActiveWindowSet.java
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@
7272
*/
7373
public class MergingActiveWindowSet<W extends BoundedWindow> implements ActiveWindowSet<W> {
7474
private final WindowFn<Object, W> windowFn;
75-
76-
@Nullable
77-
private Map<W, Set<W>> activeWindowToStateAddressWindows;
75+
private final Map<W, Set<W>> activeWindowToStateAddressWindows;
7876

7977
/**
8078
* As above, but only for EPHEMERAL windows. Does not need to be persisted.
@@ -94,16 +92,14 @@ public class MergingActiveWindowSet<W extends BoundedWindow> implements ActiveWi
9492
* MERGED. Otherwise W1 is EPHEMERAL.
9593
* </ul>
9694
*/
97-
@Nullable
98-
private Map<W, W> windowToActiveWindow;
95+
private final Map<W, W> windowToActiveWindow;
9996

10097
/**
10198
* Deep clone of {@link #activeWindowToStateAddressWindows} as of last commit.
10299
*
103100
* <p>Used to avoid writing to state if no changes have been made during the work unit.
104101
*/
105-
@Nullable
106-
private Map<W, Set<W>> originalActiveWindowToStateAddressWindows;
102+
private final Map<W, Set<W>> originalActiveWindowToStateAddressWindows;
107103

108104
/**
109105
* Handle representing our state in the backend.
@@ -195,6 +191,7 @@ public void addActive(W window) {
195191

196192
@Override
197193
public void remove(W window) {
194+
Preconditions.checkState(isActive(window), "Window %s is not active", window);
198195
for (W stateAddressWindow : activeWindowToStateAddressWindows.get(window)) {
199196
windowToActiveWindow.remove(stateAddressWindow);
200197
}
@@ -522,7 +519,7 @@ private static <W> Map<W, Set<W>> emptyIfNull(@Nullable Map<W, Set<W>> multimap)
522519
private static <W> Map<W, Set<W>> deepCopy(Map<W, Set<W>> multimap) {
523520
Map<W, Set<W>> newMultimap = new HashMap<>();
524521
for (Map.Entry<W, Set<W>> entry : multimap.entrySet()) {
525-
newMultimap.put(entry.getKey(), new LinkedHashSet<W>(entry.getValue()));
522+
newMultimap.put(entry.getKey(), new LinkedHashSet<>(entry.getValue()));
526523
}
527524
return newMultimap;
528525
}
Collapse file

‎sdk/src/main/java/com/google/cloud/dataflow/sdk/util/ReduceFnRunner.java‎

Copy file name to clipboardExpand all lines: sdk/src/main/java/com/google/cloud/dataflow/sdk/util/ReduceFnRunner.java
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ public void onTimer(TimerData timer) throws Exception {
523523
// - The trigger may implement isClosed as constant false.
524524
// - If the window function does not support windowing then all windows will be considered
525525
// active.
526-
// So we must combine the above.
526+
// So we must take conjunction of activeWindows and triggerRunner state.
527527
boolean windowIsActive =
528528
activeWindows.isActive(window) && !triggerRunner.isClosed(directContext.state());
529529

@@ -602,7 +602,7 @@ private void clearAllState(
602602
boolean windowIsActive)
603603
throws Exception {
604604
if (windowIsActive) {
605-
// Since window is still active the trigger has not closed.
605+
// Since window was still active the trigger may not have closed.
606606
reduceFn.clearState(renamedContext);
607607
watermarkHold.clearHolds(renamedContext);
608608
nonEmptyPanes.clearPane(renamedContext.state());
@@ -622,7 +622,10 @@ private void clearAllState(
622622
}
623623
}
624624
paneInfoTracker.clear(directContext.state());
625-
activeWindows.remove(directContext.window());
625+
if (activeWindows.isActive(directContext.window())) {
626+
// Don't need to track address state windows anymore
627+
activeWindows.remove(directContext.window());
628+
}
626629
// We'll never need to test for the trigger being closed again.
627630
triggerRunner.clearFinished(directContext.state());
628631
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.