johnyangk commented on a change in pull request #151: [NEMO-267] Consider 
watermark holds in GroupByKeyAndWindowDoFnTransform
URL: https://github.com/apache/incubator-nemo/pull/151#discussion_r231373210
 
 

 ##########
 File path: 
compiler/frontend/beam/src/main/java/org/apache/nemo/compiler/frontend/beam/transform/GroupByKeyAndWindowDoFnTransform.java
 ##########
 @@ -314,4 +345,31 @@ public TimerInternals timerInternalsForKey(final K key) {
       return stateAndTimerForKey.timerInternals;
     }
   }
+
+  /**
+   * This class wraps the output collector to track the watermark hold of each 
key.
+   */
+  final class GBKWOutputCollector implements 
OutputCollector<WindowedValue<KV<K, Iterable<InputT>>>> {
+    private final OutputCollector<WindowedValue<KV<K, Iterable<InputT>>>> 
outputCollector;
+    GBKWOutputCollector(final OutputCollector<WindowedValue<KV<K, 
Iterable<InputT>>>> outputCollector) {
+      this.outputCollector = outputCollector;
+    }
+
+    @Override
+    public void emit(final WindowedValue<KV<K, Iterable<InputT>>> output) {
+      // adds the output timestamp to the watermark hold of each key
+      // +1 to the output timestamp because if the window is [0-5000), the 
timestamp is 4999
+      keyAndWatermarkHoldMap.put(output.getValue().getKey(),
+        new Watermark(output.getTimestamp().getMillis() + 1));
 
 Review comment:
   Can you add a TODO here to check for different triggers?
   https://issues.apache.org/jira/browse/NEMO-270
   
   In the following case
   - W-4 / E-3 / E-2 / E-1 / E-1 --> GBKW
   - All elements are in the window of [1~4)
   
   (1) If triggered at watermark W-4 this works perfectly
   (2) If triggered early at E-1, then the downstream operators will consider 
the following E-1 late.
   
   NEMO-270 can check for the correctness of (2)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to