Skip to content

Commit 2353166

Browse files
committed
Eliminate WindowedValue.getPane() in preparation for making it a user-facing interface
1 parent 48e5414 commit 2353166

88 files changed

Lines changed: 438 additions & 394 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/java/src/test/java/org/apache/beam/examples/complete/game/LeaderBoardTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void testTeamScoresOnTime() {
9999
.addElements(
100100
event(TestUser.RED_ONE, 1, Duration.standardMinutes(4)),
101101
event(TestUser.BLUE_ONE, 2, Duration.standardSeconds(270)))
102-
// The window should close and emit an ON_TIME pane
102+
// The window should close and emit an ON_TIME paneInfo
103103
.advanceWatermarkToInfinity();
104104

105105
PCollection<KV<String, Integer>> teamScores =
@@ -137,7 +137,8 @@ public void testTeamScoresSpeculative() {
137137
// Some additional time passes and we get a speculative pane for the red team
138138
.advanceProcessingTime(Duration.standardMinutes(12))
139139
.addElements(event(TestUser.BLUE_TWO, 3, Duration.standardSeconds(22)))
140-
// More time passes and a speculative pane containing a refined value for the blue pane
140+
// More time passes and a speculative pane containing a refined value for the blue
141+
// paneInfo
141142
// is
142143
// emitted
143144
.advanceProcessingTime(Duration.standardMinutes(10))
@@ -155,7 +156,7 @@ public void testTeamScoresSpeculative() {
155156
String blueTeam = TestUser.BLUE_ONE.getTeam();
156157
String redTeam = TestUser.RED_ONE.getTeam();
157158
IntervalWindow window = new IntervalWindow(baseTime, TEAM_WINDOW_DURATION);
158-
// The window contains speculative panes alongside the on-time pane
159+
// The window contains speculative panes alongside the on-time paneInfo
159160
PAssert.that(teamScores)
160161
.inWindow(window)
161162
.containsInAnyOrder(
@@ -190,7 +191,7 @@ public void testTeamScoresUnobservablyLate() {
190191
.advanceWatermarkTo(
191192
baseTime.plus(TEAM_WINDOW_DURATION).minus(Duration.standardMinutes(1)))
192193
// These events are late, but the window hasn't closed yet, so the elements are in the
193-
// on-time pane
194+
// on-time paneInfo
194195
.addElements(
195196
event(TestUser.RED_TWO, 2, Duration.ZERO),
196197
event(TestUser.RED_TWO, 5, Duration.standardMinutes(1)),
@@ -235,7 +236,7 @@ public void testTeamScoresObservablyLate() {
235236
event(TestUser.RED_ONE, 4, Duration.standardMinutes(2)),
236237
event(TestUser.BLUE_ONE, 3, Duration.standardMinutes(5)))
237238
.advanceWatermarkTo(firstWindowCloses.minus(Duration.standardMinutes(1)))
238-
// These events are late but should still appear in a late pane
239+
// These events are late but should still appear in a late paneInfo
239240
.addElements(
240241
event(TestUser.RED_TWO, 2, Duration.ZERO),
241242
event(TestUser.RED_TWO, 5, Duration.standardMinutes(1)),
@@ -244,7 +245,7 @@ public void testTeamScoresObservablyLate() {
244245
// has
245246
// not yet closed because the watermark has not advanced
246247
.advanceProcessingTime(Duration.standardMinutes(12))
247-
// These elements should appear in the final pane
248+
// These elements should appear in the final paneInfo
248249
.addElements(
249250
event(TestUser.RED_TWO, 9, Duration.standardMinutes(1)),
250251
event(TestUser.RED_TWO, 1, Duration.standardMinutes(3)))

runners/core-java/src/main/java/org/apache/beam/runners/core/LateDataDroppingDoFnRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public <K, InputT> Iterable<WindowedValue<InputT>> filter(
142142
} else {
143143
nonLateElements.add(
144144
WindowedValues.of(
145-
element.getValue(), element.getTimestamp(), window, element.getPane()));
145+
element.getValue(), element.getTimestamp(), window, element.getPaneInfo()));
146146
}
147147
}
148148
}

runners/core-java/src/main/java/org/apache/beam/runners/core/OutputAndTimeBoundedSplittableProcessElementInvoker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public Instant timestamp() {
380380

381381
@Override
382382
public PaneInfo pane() {
383-
return element.getPane();
383+
return element.getPaneInfo();
384384
}
385385

386386
@Override
@@ -395,7 +395,7 @@ public void output(OutputT output) {
395395

396396
@Override
397397
public void outputWithTimestamp(OutputT value, Instant timestamp) {
398-
outputWindowedValue(value, timestamp, element.getWindows(), element.getPane());
398+
outputWindowedValue(value, timestamp, element.getWindows(), element.getPaneInfo());
399399
}
400400

401401
@Override
@@ -419,7 +419,7 @@ public <T> void output(TupleTag<T> tag, T value) {
419419
@Override
420420
public <T> void outputWithTimestamp(TupleTag<T> tag, T value, Instant timestamp) {
421421
outputReceiver.output(
422-
tag, WindowedValues.of(value, timestamp, element.getWindows(), element.getPane()));
422+
tag, WindowedValues.of(value, timestamp, element.getWindows(), element.getPaneInfo()));
423423
}
424424

425425
@Override

runners/core-java/src/main/java/org/apache/beam/runners/core/PaneInfoTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public PaneInfoTracker(TimerInternals timerInternals) {
4848

4949
@VisibleForTesting
5050
static final StateTag<ValueState<PaneInfo>> PANE_INFO_TAG =
51-
StateTags.makeSystemTagInternal(StateTags.value("pane", PaneInfoCoder.INSTANCE));
51+
StateTags.makeSystemTagInternal(StateTags.value("paneInfo", PaneInfoCoder.INSTANCE));
5252

5353
public void clear(StateAccessor<?> state) {
5454
state.access(PANE_INFO_TAG).clear();

runners/core-java/src/main/java/org/apache/beam/runners/core/ReduceFnContextFactory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public ReduceFn<K, InputT, OutputT, W>.ProcessValueContext forValue(
103103
}
104104

105105
public ReduceFn<K, InputT, OutputT, W>.OnTriggerContext forTrigger(
106-
W window, PaneInfo pane, StateStyle style, OnTriggerCallbacks<OutputT> callbacks) {
107-
return new OnTriggerContextImpl(stateAccessor(window, style), pane, callbacks);
106+
W window, PaneInfo paneInfo, StateStyle style, OnTriggerCallbacks<OutputT> callbacks) {
107+
return new OnTriggerContextImpl(stateAccessor(window, style), paneInfo, callbacks);
108108
}
109109

110110
public ReduceFn<K, InputT, OutputT, W>.OnMergeContext forMerge(
@@ -402,15 +402,15 @@ public Timers timers() {
402402

403403
private class OnTriggerContextImpl extends ReduceFn<K, InputT, OutputT, W>.OnTriggerContext {
404404
private final StateAccessorImpl<K, W> state;
405-
private final PaneInfo pane;
405+
private final PaneInfo paneInfo;
406406
private final OnTriggerCallbacks<OutputT> callbacks;
407407
private final TimersImpl timers;
408408

409409
private OnTriggerContextImpl(
410-
StateAccessorImpl<K, W> state, PaneInfo pane, OnTriggerCallbacks<OutputT> callbacks) {
410+
StateAccessorImpl<K, W> state, PaneInfo paneInfo, OnTriggerCallbacks<OutputT> callbacks) {
411411
reduceFn.super();
412412
this.state = state;
413-
this.pane = pane;
413+
this.paneInfo = paneInfo;
414414
this.callbacks = callbacks;
415415
this.timers = new TimersImpl(state.namespace());
416416
}
@@ -437,7 +437,7 @@ public StateAccessor<K> state() {
437437

438438
@Override
439439
public PaneInfo paneInfo() {
440-
return pane;
440+
return paneInfo;
441441
}
442442

443443
@Override

runners/core-java/src/main/java/org/apache/beam/runners/core/ReduceFnRunner.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,28 +1037,28 @@ private void prefetchOnTrigger(
10371037
}
10381038

10391039
// Calculate the pane info.
1040-
final PaneInfo pane = paneInfoTracker.getNextPaneInfo(directContext, isFinished).read();
1040+
final PaneInfo paneInfo = paneInfoTracker.getNextPaneInfo(directContext, isFinished).read();
10411041

10421042
// Only emit a pane if it has data or empty panes are observable.
1043-
if (needToEmit(isEmpty, isFinished, pane.getTiming())) {
1043+
if (needToEmit(isEmpty, isFinished, paneInfo.getTiming())) {
10441044
// Run reduceFn.onTrigger method.
10451045
final List<W> windows = Collections.singletonList(directContext.window());
10461046
ReduceFn<K, InputT, OutputT, W>.OnTriggerContext renamedTriggerContext =
10471047
contextFactory.forTrigger(
10481048
directContext.window(),
1049-
pane,
1049+
paneInfo,
10501050
StateStyle.RENAMED,
10511051
toOutput -> {
10521052
// We're going to output panes, so commit the (now used) PaneInfo.
10531053
// This is unnecessary if the trigger isFinished since the saved
10541054
// state will be immediately deleted.
10551055
if (!isFinished) {
1056-
paneInfoTracker.storeCurrentPaneInfo(directContext, pane);
1056+
paneInfoTracker.storeCurrentPaneInfo(directContext, paneInfo);
10571057
}
10581058

10591059
// Output the actual value.
10601060
outputter.output(
1061-
WindowedValues.of(KV.of(key, toOutput), outputTimestamp, windows, pane));
1061+
WindowedValues.of(KV.of(key, toOutput), outputTimestamp, windows, paneInfo));
10621062
});
10631063

10641064
reduceFn.onTrigger(renamedTriggerContext);

runners/core-java/src/main/java/org/apache/beam/runners/core/SimpleDoFnRunner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ public <T> T sideInput(PCollectionView<T> view) {
405405

406406
@Override
407407
public PaneInfo pane() {
408-
return elem.getPane();
408+
return elem.getPaneInfo();
409409
}
410410

411411
@Override
@@ -437,7 +437,7 @@ public <T> void output(TupleTag<T> tag, T output) {
437437
public <T> void outputWithTimestamp(TupleTag<T> tag, T output, Instant timestamp) {
438438
checkNotNull(tag, "Tag passed to outputWithTimestamp cannot be null");
439439
checkTimestamp(elem.getTimestamp(), timestamp);
440-
outputWindowedValue(tag, output, timestamp, elem.getWindows(), elem.getPane());
440+
outputWindowedValue(tag, output, timestamp, elem.getWindows(), elem.getPaneInfo());
441441
}
442442

443443
@Override

runners/core-java/src/main/java/org/apache/beam/runners/core/SplittableParDoViaKeyedWorkItems.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public PipelineOptions pipelineOptions() {
431431

432432
@Override
433433
public PaneInfo paneInfo(DoFn<InputT, OutputT> doFn) {
434-
return elementAndRestriction.getKey().getPane();
434+
return elementAndRestriction.getKey().getPaneInfo();
435435
}
436436

437437
@Override
@@ -491,7 +491,7 @@ public PipelineOptions pipelineOptions() {
491491

492492
@Override
493493
public PaneInfo paneInfo(DoFn<InputT, OutputT> doFn) {
494-
return elementAndRestriction.getKey().getPane();
494+
return elementAndRestriction.getKey().getPaneInfo();
495495
}
496496

497497
@Override
@@ -545,7 +545,7 @@ public PipelineOptions pipelineOptions() {
545545

546546
@Override
547547
public PaneInfo paneInfo(DoFn<InputT, OutputT> doFn) {
548-
return elementAndRestriction.getKey().getPane();
548+
return elementAndRestriction.getKey().getPaneInfo();
549549
}
550550

551551
@Override

runners/core-java/src/main/java/org/apache/beam/runners/core/WindowingInternals.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ void outputWindowedValue(
4747
OutputT output,
4848
Instant timestamp,
4949
Collection<? extends BoundedWindow> windows,
50-
PaneInfo pane);
50+
PaneInfo paneInfo);
5151

5252
/** Output the value to a tagged output at the specified timestamp in the listed windows. */
5353
<AdditionalOutputT> void outputWindowedValue(
5454
TupleTag<AdditionalOutputT> tag,
5555
AdditionalOutputT output,
5656
Instant timestamp,
5757
Collection<? extends BoundedWindow> windows,
58-
PaneInfo pane);
58+
PaneInfo paneInfo);
5959

6060
/**
6161
* Return the timer manager provided by the underlying system, or null if Timers need to be
@@ -67,7 +67,7 @@ <AdditionalOutputT> void outputWindowedValue(
6767
Collection<? extends BoundedWindow> windows();
6868

6969
/** Access the pane of the current window(s). */
70-
PaneInfo pane();
70+
PaneInfo paneInfo();
7171

7272
/** Return the value of the side input for a particular side input window. */
7373
<T> T sideInput(PCollectionView<T> view, BoundedWindow sideInputWindow);

0 commit comments

Comments
 (0)