@@ -75,15 +75,13 @@ private PTransform<PBegin, PCollection<KV<Integer, Integer>>> createStreamingSou
7575 return CreateStream .of (coder , batchDuration )
7676 .emptyBatch ()
7777 .advanceWatermarkForNextBatch (instant )
78- .nextBatch (
79- TimestampedValue .of (KV .of (1 , 10 ), instant ),
80- TimestampedValue .of (KV .of (1 , 10 ), instant ),
81- TimestampedValue .of (KV .of (1 , 10 ), instant ))
78+ .nextBatch (TimestampedValue .of (KV .of (1 , 1 ), instant ))
79+ .nextBatch (TimestampedValue .of (KV .of (1 , 2 ), instant ))
80+ .nextBatch (TimestampedValue .of (KV .of (1 , 3 ), instant ))
8281 .advanceWatermarkForNextBatch (instant .plus (Duration .standardSeconds (1L )))
83- .nextBatch (
84- TimestampedValue .of (KV .of (2 , 20 ), instant .plus (Duration .standardSeconds (1L ))),
85- TimestampedValue .of (KV .of (2 , 20 ), instant .plus (Duration .standardSeconds (1L ))),
86- TimestampedValue .of (KV .of (2 , 20 ), instant .plus (Duration .standardSeconds (1L ))))
82+ .nextBatch (TimestampedValue .of (KV .of (2 , 4 ), instant .plus (Duration .standardSeconds (1L ))))
83+ .nextBatch (TimestampedValue .of (KV .of (2 , 5 ), instant .plus (Duration .standardSeconds (1L ))))
84+ .nextBatch (TimestampedValue .of (KV .of (2 , 6 ), instant .plus (Duration .standardSeconds (1L ))))
8785 .advanceNextBatchWatermarkToInfinity ();
8886 }
8987
@@ -96,21 +94,22 @@ private PTransform<PBegin, PCollection<KV<Integer, Integer>>> createStreamingSou
9694 CreateStream <KV <Integer , Integer >> createStream =
9795 CreateStream .of (coder , batchDuration ).emptyBatch ().advanceWatermarkForNextBatch (instant );
9896
97+ int value = 1 ;
9998 for (int i = 0 ; i < iterCount ; i ++) {
10099 createStream =
101- createStream . nextBatch (
102- TimestampedValue .of (KV .of (1 , 10 ), instant ),
103- TimestampedValue .of (KV .of (1 , 10 ), instant ),
104- TimestampedValue .of (KV .of (1 , 10 ), instant ));
100+ createStream
101+ . nextBatch ( TimestampedValue .of (KV .of (1 , value ++ ), instant ))
102+ . nextBatch ( TimestampedValue .of (KV .of (1 , value ++ ), instant ))
103+ . nextBatch ( TimestampedValue .of (KV .of (1 , value ++ ), instant ));
105104
106105 instant = instant .plus (Duration .standardSeconds (1L ));
107106 createStream = createStream .advanceWatermarkForNextBatch (instant );
108107
109108 createStream =
110- createStream . nextBatch (
111- TimestampedValue .of (KV .of (2 , 20 ), instant ),
112- TimestampedValue .of (KV .of (2 , 20 ), instant ),
113- TimestampedValue .of (KV .of (2 , 20 ), instant ));
109+ createStream
110+ . nextBatch ( TimestampedValue .of (KV .of (2 , value ++ ), instant ))
111+ . nextBatch ( TimestampedValue .of (KV .of (2 , value ++ ), instant ))
112+ . nextBatch ( TimestampedValue .of (KV .of (2 , value ++ ), instant ));
114113
115114 instant = instant .plus (Duration .standardSeconds (1L ));
116115 createStream = createStream .advanceWatermarkForNextBatch (instant );
@@ -310,13 +309,13 @@ public void shouldProcessGlobalWidowStatefulParDo() {
310309 PAssert .that (result )
311310 .containsInAnyOrder (
312311 // key 1
313- KV .of (1 , 10 ), // 10
314- KV .of (1 , 20 ), // 10 + 10
315- KV .of (1 , 30 ), // 20 + 10
312+ KV .of (1 , 1 ), // 1
313+ KV .of (1 , 3 ), // 1 + 2
314+ KV .of (1 , 6 ), // 3 + 3
316315 // key 2
317- KV .of (2 , 20 ), // 20
318- KV .of (2 , 40 ), // 20 + 20
319- KV .of (2 , 60 )); // 40 + 20
316+ KV .of (2 , 4 ), // 4
317+ KV .of (2 , 9 ), // 4 + 5
318+ KV .of (2 , 15 )); // 9 + 6
320319
321320 p .run ().waitUntilFinish ();
322321 }
@@ -331,25 +330,25 @@ public void shouldProcessWindowedStatefulParDo() {
331330
332331 PAssert .that (result )
333332 .containsInAnyOrder (
334- // Windowed Key 1 (Window 1)
335- KV .of (1 , 10 ), // 10
336- KV .of (1 , 20 ), // 10 + 10
337- KV .of (1 , 30 ), // 20 + 10
338-
339- // Windowed Key 2 (Window 1)
340- KV .of (2 , 20 ), // 20
341- KV .of (2 , 40 ), // 20 + 20
342- KV .of (2 , 60 ), // 40 + 20
343-
344- // Windowed Key 1 (Window 2)
345- KV .of (1 , 10 ), // 10
346- KV .of (1 , 20 ), // 10 + 10
347- KV .of (1 , 30 ), // 20 + 10
348-
349- // Windowed Key 2 (Window 2)
350- KV .of (2 , 20 ), // 20
351- KV .of (2 , 40 ), // 20 + 20
352- KV .of (2 , 60 ) // 40 + 20
333+ // Windowed Key 1
334+ KV .of (1 , 1 ), // 1
335+ KV .of (1 , 3 ), // 1 + 2
336+ KV .of (1 , 6 ), // 3 + 3
337+
338+ // Windowed Key 2
339+ KV .of (2 , 4 ), // 4
340+ KV .of (2 , 9 ), // 4 + 5
341+ KV .of (2 , 15 ), // 9 + 6
342+
343+ // Windowed Key 1
344+ KV .of (1 , 7 ), // 7
345+ KV .of (1 , 15 ), // 7 + 8
346+ KV .of (1 , 24 ), // 15 + 9
347+
348+ // Windowed Key 2
349+ KV .of (2 , 10 ), // 10
350+ KV .of (2 , 21 ), // 10 + 11
351+ KV .of (2 , 33 ) // 21 + 12
353352 );
354353
355354 p .run ().waitUntilFinish ();
0 commit comments