You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/09/24 07:33:02 UTC

[GitHub] [flink] KarmaGYZ commented on a change in pull request #9749: [FLINK-14115][docs-zh] Translate DataStream Code Walkthrough to Chinese

KarmaGYZ commented on a change in pull request #9749: [FLINK-14115][docs-zh] Translate DataStream Code Walkthrough to Chinese
URL: https://github.com/apache/flink/pull/9749#discussion_r327465727
 
 

 ##########
 File path: docs/getting-started/walkthroughs/datastream_api.zh.md
 ##########
 @@ -564,31 +565,31 @@ Below, you can see an example of how you can use a flag state to track potential
 </div>
 </div>
 
-For every transaction, the fraud detector checks the state of the flag for that account.
-Remember, `ValueState` is always scoped to the current key, i.e., account.
-If the flag is non-null, then the last transaction seen for that account was small, and so if the amount for this transaction is large, then the detector outputs a fraud alert.
+对于每笔交易,欺诈检测器都会检查该帐户的标记状态。
+请记住,`ValueState` 的作用域始终限于当前的 key,即信用卡帐户。
+如果标记状态不为空,则该帐户的上一笔交易是小额的,因此,如果当前这笔交易的金额很大,那么检测程序将输出报警信息。
 
-After that check, the flag state is unconditionally cleared.
-Either the current transaction caused a fraud alert, and the pattern is over, or the current transaction did not cause an alert, and the pattern is broken and needs to be restarted.
+在检查之后,不论是什么状态,都需要被清空。
+不管是当前交易触发了欺诈报警而造成模式的结束,还是当前交易没有触发报警而造成模式的中断,都需要重新开始新的模式检测。
 
-Finally, the transaction amount is checked to see if it is small.
-If so, then the flag is set so that it can be checked by the next event.
-Notice that `ValueState<Boolean>` actually has three states, unset ( `null`), `true`, and `false`, because all `ValueState`'s are nullable.
-This job only makes use of unset ( `null`) and `true` to check whether the flag is set or not.
+最后,检查当前交易的金额是否属于小额交易。
+如果是,那么需要设置标记状态,以便可以在下一个事件中对其进行检查。
+注意,`ValueState<Boolean>` 实际上有 3 种状态:unset (`null`),`true`,和 `false`,`ValueState` 是允许空值的。
+我们的程序只使用了 unset (`null`) 和 `true` 两种来判断标记状态被设置了与否。
 
-## Fraud Detector v2: State + Time = &#10084;&#65039;
+## 欺诈检测器 v2:状态 + 时间 = &#10084;&#65039;
 
-Scammers don't wait long to make their large purchase to reduce the chances their test transaction is noticed. 
-For example, suppose you wanted to set a 1 minute timeout to your fraud detector; i.e., in the previous example transactions 3 and 4 would only be considered fraud if they occurred within 1 minute of each other.
-Flink's `KeyedProcessFunction` allows you to set timers which invoke a callback method at some point in time in the future.
+骗子们在小额交易后不会等很久就进行大额消费,这样可以降低小额测试交易被发现的几率。
+比如,假设你为欺诈检测器设置了一分钟的超时,对于上边的例子,交易 3 和 交易 4 只有间隔在一分钟之内才被认为是欺诈交易。
+Flink 中的 `KeyedProcessFunction` 允许您设置计时器,该计时器在将来的某个时间点执行回调函数。
 
-Let's see how we can modify our Job to comply with our new requirements:
+让我们看看如何修改程序以符合我们的新要求:
 
-* Whenever the flag is set to `true`, also set a timer for 1 minute in the future.
-* When the timer fires, reset the flag by clearing its state.
-* If the flag is ever cleared the timer should be canceled.
+* 当标记状态被设置为 `true` 时,设置一个在当前时间一分钟后触发的定时器。
+* 当定时器被触发时,重置标记状态。
+* 当标记状态被重置时,删除定时器。
 
-To cancel a timer, you have to remember what time it is set for, and remembering implies state, so you will begin by creating a timer state along with your flag state.
+要删除一个定时器,你需要记录这个定时器的触发时间,这同样需要状态来实现,所以你需要在标记状态后也创建一个记录定时器时间的状态。
 
 <div class="codetabs" markdown="1">
 <div data-lang="java" markdown="1">
 
 Review comment:
   We may remove the useless indentation in zh version.

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


With regards,
Apache Git Services