klion26 commented on a change in pull request #12665:
URL: https://github.com/apache/flink/pull/12665#discussion_r460654064



##########
File path: docs/dev/event_timestamp_extractors.zh.md
##########
@@ -25,83 +25,51 @@ under the License.
 * toc
 {:toc}
 
-As described in [timestamps and watermark handling]({{ site.baseurl 
}}/dev/event_timestamps_watermarks.html),
-Flink provides abstractions that allow the programmer to assign their own 
timestamps and emit their own watermarks. More specifically,
-one can do so by implementing one of the `AssignerWithPeriodicWatermarks` and 
`AssignerWithPunctuatedWatermarks` interfaces, depending
-on the use case. In a nutshell, the first will emit watermarks periodically, 
while the second does so based on some property of
-the incoming records, e.g. whenever a special element is encountered in the 
stream.
+如[生成 Watermark]({%link dev/event_timestamps_watermarks.zh.md %}) 小节中所述,Flink 
提供的抽象方法可以允许用户自己去定义时间戳分配方式和 watermark 生成的方式。你可以通过实现 `WatermarkGenerator` 
接口来实现上述功能。
 
-In order to further ease the programming effort for such tasks, Flink comes 
with some pre-implemented timestamp assigners.
-This section provides a list of them. Apart from their out-of-the-box 
functionality, their implementation can serve as an example
-for custom implementations.
+为了进一步简化此类任务的编程工作,Flink 框架预设了一些时间戳分配器。本节后续内容有举例。除了开箱即用的已有实现外,其还可以作为自定义实现的示例以供参考。
 
-### **Assigners with ascending timestamps**
+<a name="monotonously-increasing-timestamps"></a>
 
-The simplest special case for *periodic* watermark generation is the case 
where timestamps seen by a given source task
-occur in ascending order. In that case, the current timestamp can always act 
as a watermark, because no earlier timestamps will
-arrive.
+## 单调递增时间戳分配器
 
-Note that it is only necessary that timestamps are ascending *per parallel 
data source task*. For example, if
-in a specific setup one Kafka partition is read by one parallel data source 
instance, then it is only necessary that
-timestamps are ascending within each Kafka partition. Flink's watermark 
merging mechanism will generate correct
-watermarks whenever parallel streams are shuffled, unioned, connected, or 
merged.
+*周期性* watermark 生成方式的一个最简单特例就是你给定的数据源中数据的时间戳升序出现。在这种情况下,当前时间戳就可以充当 
watermark,因为后续到达数据的时间戳不会比当前的小。
+
+注意:在 Flink 应用程序中,如果是并行数据源,则只要求并行数据源中的每个*单分区数据源任务*时间戳递增。例如,设置每一个并行数据源实例都只读取一个 
Kafka 分区,则时间戳只需在每个 Kafka 分区内递增即可。Flink 的 watermark 
合并机制会在并行数据流进行分发(shuffle)、联合(union)、连接(connect)或合并(merge)时生成正确的 watermark。
 
 <div class="codetabs" markdown="1">
 <div data-lang="java" markdown="1">
 {% highlight java %}
-DataStream<MyEvent> stream = ...
-
-DataStream<MyEvent> withTimestampsAndWatermarks =
-    stream.assignTimestampsAndWatermarks(new 
AscendingTimestampExtractor<MyEvent>() {
-
-        @Override
-        public long extractAscendingTimestamp(MyEvent element) {
-            return element.getCreationTime();
-        }
-});
+WatermarkStrategies

Review comment:
       英文版的这个代码看上去是 
   ```
   WatermarkStrategy.forMonotonousTimestamps();
   ```

##########
File path: docs/dev/event_timestamps_watermarks.zh.md
##########
@@ -175,200 +140,250 @@ withTimestampsAndWatermarks
 </div>
 </div>
 
+使用 `WatermarkStrategy` 去获取流并生成带有时间戳的元素和 watermark 的新流时,如果原始流已经具有时间戳或 
watermark,则新指定的时间戳分配器将覆盖原有的时间戳和 watermark。
 
-#### **With Periodic Watermarks**
+<a name="dealing-with-idle-sources"></a>
 
-`AssignerWithPeriodicWatermarks` assigns timestamps and generates watermarks 
periodically (possibly depending
-on the stream elements, or purely based on processing time).
+## 处理空闲数据源
 
-The interval (every *n* milliseconds) in which the watermark will be generated 
is defined via
-`ExecutionConfig.setAutoWatermarkInterval(...)`. The assigner's 
`getCurrentWatermark()` method will be
-called each time, and a new watermark will be emitted if the returned 
watermark is non-null and larger than the previous
-watermark.
+如果数据源中的某一个分区/分片在一段时间内未发送事件数据,则意味着 `WatermarkGenerator` 也不会获得任何新数据去生成 
watermark。我们称这类数据源为*空闲输入*或*空闲源*。在这种情况下,当某些其他分区仍然发送事件数据的时候就会出现问题。由于下游算子 
watermark 的计算方式是取所有不同的上游并行数据源 watermark 的最小值,则其 watermark 将不会发生变化。
 
-Here we show two simple examples of timestamp assigners that use periodic 
watermark generation. Note that Flink ships with a 
`BoundedOutOfOrdernessTimestampExtractor` similar to the 
`BoundedOutOfOrdernessGenerator` shown below, which you can read about 
[here]({{ site.baseurl 
}}/dev/event_timestamp_extractors.html#assigners-allowing-a-fixed-amount-of-lateness).
+为了解决这个问题,你可以使用 `WatermarkStrategy` 来检测空闲输入并将其标记为空闲状态。`WatermarkStrategies` 
为此提供了一个工具接口:

Review comment:
       看上去 FLINK-18011(https://github.com/apache/flink/pull/12412) 删掉了 
`WatermarkStrategies` 相关的内容了,这个地方还要麻烦再修改一下(这个文档中其他相关的也修改一下),不好意思之前没有发现这个问题。




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to