[
https://issues.apache.org/jira/browse/FLINK-3428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15193366#comment-15193366
]
ASF GitHub Bot commented on FLINK-3428:
---------------------------------------
Github user rmetzger commented on a diff in the pull request:
https://github.com/apache/flink/pull/1764#discussion_r56008125
--- Diff:
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/TrailingWatermarkTimestampExtractor.java
---
@@ -0,0 +1,71 @@
+/*
+ * 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.api.functions;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.streaming.api.watermark.Watermark;
+
+/**
+ * This is a {@link AssignerWithPeriodicWatermarks} used to emit
Watermarks that lag behind the element with
+ * the maximum timestamp (in EVENT_TIME) seen so far by a fixed period of
time.
+ * */
+public abstract class TrailingWatermarkTimestampExtractor<T> implements
AssignerWithPeriodicWatermarks<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** The current maximum timestamp seen so far. */
+ private long currentMaxTimestamp = Long.MIN_VALUE;
+
+ /** The trailing period between the maximum seen timestamp and the
watermark to be emitted. */
+ private final long trailingLag;
+
+ public TrailingWatermarkTimestampExtractor(long trailingLag) {
--- End diff --
I wonder if we should use the `Time` class here. This way, users can use
the more expressive static methods: `Time.minutes(5)` ... and so on.
> Add fixed time trailing timestamp/watermark extractor
> -----------------------------------------------------
>
> Key: FLINK-3428
> URL: https://issues.apache.org/jira/browse/FLINK-3428
> Project: Flink
> Issue Type: Improvement
> Reporter: Robert Metzger
> Assignee: Kostas Kloudas
>
> Flink currently provides only one build-in timestamp extractor, which assumes
> strictly ascending timestamps. In real world use cases, timestamps are almost
> never strictly ascending.
> Therefore, I propose to provide an utility watermark extractor which is
> generating watermarks with a fixed-time trailing.
> The implementation should keep track of the highest event-time seen so far
> and subtract a fixed amount of time from that event time.
> This way, users can for example specify that the watermarks should always
> "lag behind" 10 minutes.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)