dawidwys commented on a change in pull request #13853:
URL: https://github.com/apache/flink/pull/13853#discussion_r518022227



##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/TimestampsAndWatermarksOperator.java
##########
@@ -64,24 +65,30 @@
        /** The interval (in milliseconds) for periodic watermark probes. 
Initialized during runtime. */
        private transient long watermarkInterval;
 
-       public TimestampsAndWatermarksOperator(
-                       WatermarkStrategy<T> watermarkStrategy) {
+       /** Whether to periodically emit watermarks or only one final watermark 
at the end of input.*/

Review comment:
       It is not only about periodic. I would say `wheter to emit intermediate 
watermarks or only one ...`

##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/translators/TimestampsAndWatermarksTransformationTranslator.java
##########
@@ -0,0 +1,77 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+package org.apache.flink.streaming.runtime.translators;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.streaming.api.graph.TransformationTranslator;
+import org.apache.flink.streaming.api.operators.SimpleOperatorFactory;
+import 
org.apache.flink.streaming.api.transformations.TimestampsAndWatermarksTransformation;
+import 
org.apache.flink.streaming.runtime.operators.TimestampsAndWatermarksOperator;
+
+import java.util.Collection;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * A {@link TransformationTranslator} for the {@link 
TimestampsAndWatermarksTransformation}.
+ *
+ * @param <IN> The type of the elements in the input {@code Transformation} of 
the transformation to translate.
+ */
+@Internal
+public class TimestampsAndWatermarksTransformationTranslator<IN>
+               extends AbstractOneInputTransformationTranslator<IN, IN, 
TimestampsAndWatermarksTransformation<IN>> {
+
+       @Override
+       protected Collection<Integer> translateForBatchInternal(
+                       final TimestampsAndWatermarksTransformation<IN> 
transformation,
+                       final Context context) {
+               return translateInternal(transformation, context, false /* emit 
progressive watermarks */);

Review comment:
       The comments are wrong, right? They are inverted. Moreover how do you 
feel about calling it `intermediate` watermarks? (we would change it both in 
comments and in the flag name). `Progressive` sound kind of strange to me.

##########
File path: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/operators/TimestampsAndWatermarksOperatorTest.java
##########
@@ -87,6 +88,18 @@ public void periodicWatermarksEmitOnPeriodicEmit() throws 
Exception {
 
                assertThat(pollNextStreamRecord(testHarness), streamRecord(4L, 
4L));
                assertThat(pollNextLegacyWatermark(testHarness), 
is(legacyWatermark(3L)));
+
+               testHarness = 
createBatchHarness(WatermarkStrategy.forGenerator((ctx) -> new 
PeriodicWatermarkGenerator())

Review comment:
       Let's extract it to a separate test. It's always better to test a single 
case at a time. I would rename the existing test to:
   `periodicWatermarksEmitOnPeriodicEmitStreamMode` and the batch one 
`periodicWatermarksEmitOnPeriodicEmitBatchMode`. The same for the other test.
   
   Moreover in the batch case you are not advancing the processing time. 
Therefore you are not testing the periodic generator. It passes for `STREAM` 
mode as well.
   
   Lastly could you add tests for the punctuated watermark generator? The 
`PeriodicWatermarkGenerator` emits only in `onPeriodicEmit`, we should test 
that we do not emit from `onEvent` as well.




----------------------------------------------------------------
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]


Reply via email to