[GitHub] [flink] RocMarshal commented on a change in pull request #13225: [FLINK-18974][docs-zh]Translate the 'User-Defined Functions' page of "Application Development's DataStream API" into Chinese

2020-09-09 Thread GitBox


RocMarshal commented on a change in pull request #13225:
URL: https://github.com/apache/flink/pull/13225#discussion_r486043441



##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -114,30 +119,31 @@ data.reduce { (i1,i2) => i1 + i2 }
 data.reduce { _ + _ }
 {% endhighlight %}
 
+
+
 ## Rich functions
 
-All transformations that take as argument a lambda function can
-instead take as argument a *rich* function. For example, instead of
+所有将 lambda 表达式作为参数的转化操作都可以用 *rich* function 来代替。例如,代替
 
 {% highlight scala %}
 data.map { x => x.toInt }
 {% endhighlight %}
 
-you can write
+你可以写成
 
 {% highlight scala %}
 class MyMapFunction extends RichMapFunction[String, Int] {
   def map(in: String):Int = { in.toInt }
 };
 {% endhighlight %}
 
-and pass the function to a `map` transformation:
+并将函数传递给 `map` transformation:
 
 {% highlight scala %}
 data.map(new MyMapFunction())
 {% endhighlight %}
 
-Rich functions can also be defined as an anonymous class:
+富函数也可以定义成匿名类:

Review comment:
   We need to make some necessary decisions.
   ```function``` or ```函数```?
   ```rich function``` or ```富函数?
   We'd better keep the special nouns and keywords consistent in the 
translation, which  is more rigorous.
   Can you tell me what you think of ?

##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -23,16 +23,16 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-Most operations require a user-defined function. This section lists different
-ways of how they can be specified. We also cover `Accumulators`, which can be
-used to gain insights into your Flink application.
+大多数操作都需要用户自定义函数。本节列出了实现用户自定义函数的不同方式。还会介绍 `Accumulators`(累加器),可用于深入了解你的 Flink 
应用程序。

Review comment:
   ```suggestion
   大多数操作都需要用户自定义函数(function)。本节列出了实现用户自定义函数的不同方式。还会介绍 
`Accumulators`(累加器),可用于深入了解你的 Flink 应用程序。
   ```

##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -62,32 +66,33 @@ data.filter(s -> s.startsWith("http://";));
 data.reduce((i1,i2) -> i1 + i2);
 {% endhighlight %}
 
+
+
 ## Rich functions
 
-All transformations that require a user-defined function can
-instead take as argument a *rich* function. For example, instead of
+所有需要用户自定义函数的转化操作都可以将 *rich* function 作为参数。例如,代替
 
 {% highlight java %}
 class MyMapFunction implements MapFunction {
   public Integer map(String value) { return Integer.parseInt(value); }
 };
 {% endhighlight %}
 
-you can write
+你可以写成

Review comment:
   ```suggestion
   更改后替换为如下内容
   ```

##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -147,95 +153,78 @@ data.map (new RichMapFunction[String, Int] {
 
 
 
-Rich functions provide, in addition to the user-defined function (map,
-reduce, etc), four methods: `open`, `close`, `getRuntimeContext`, and
-`setRuntimeContext`. These are useful for parameterizing the function
-(see [Passing Parameters to Functions]({{ site.baseurl 
}}/dev/batch/index.html#passing-parameters-to-functions)),
-creating and finalizing local state, accessing broadcast variables (see
-[Broadcast Variables]({{ site.baseurl 
}}/dev/batch/index.html#broadcast-variables)), and for accessing runtime
-information such as accumulators and counters (see
-[Accumulators and Counters](#accumulators--counters)), and information
-on iterations (see [Iterations]({{ site.baseurl }}/dev/batch/iterations.html)).
+除了用户自定义的功能(map,reduce 等),Rich functions 
还提供了四个方法:`open`、`close`、`getRuntimeContext` 和
+`setRuntimeContext`。这些方法对于参数化函数
+(参阅 [给函数传递参数]({% link dev/batch/index.zh.md 
%}#passing-parameters-to-functions)),
+创建和最终确定本地状态,访问广播变量(参阅
+[广播变量]({% link dev/batch/index.zh.md %}#broadcast-variables 
)),以及访问运行时信息,例如累加器和计数器(参阅
+[累加器和计数器](#accumulators--counters)),以及迭代器的相关信息(参阅 [迭代器]({% link 
dev/batch/iterations.zh.md %}))
+有很大作用。
 
 {% top %}
 
-## Accumulators & Counters
+
 
-Accumulators are simple constructs with an **add operation** and a **final 
accumulated result**,
-which is available after the job ended.
+## 累加器和计数器
 
-The most straightforward accumulator is a **counter**: You can increment it 
using the
-```Accumulator.add(V value)``` method. At the end of the job Flink will sum up 
(merge) all partial
-results and send the result to the client. Accumulators are useful during 
debugging or if you
-quickly want to find out more about your data.
+累加器是具有**加法运算**和**最终累加结果**的一种简单结构,可在作业结束后使用。
 
-Flink currently has the following **built-in accumulators**. Each of them 
implements the
-{% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/Accumulator.java
 "Accumulator" %}
-interface.
+最简单的累加器就是**计数器**: 你可以使用
+```Accumulator.add(V value)``` 方法将其递增。在作业结束时,Flink 会汇总(合并)所有部分的结果并将其发送给客户端。
+在调试过程中或在你想快速了解有关数据更多信息时,累加器作用很大。
+
+Flink 目前有如下**内置累加器**。每个都实现了
+{% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/Accumulator.java
 "累加器" %}
+接口。
 
 - {% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/IntCount

[GitHub] [flink] RocMarshal commented on a change in pull request #13225: [FLINK-18974][docs-zh]Translate the 'User-Defined Functions' page of "Application Development's DataStream API" into Chinese

2020-09-14 Thread GitBox


RocMarshal commented on a change in pull request #13225:
URL: https://github.com/apache/flink/pull/13225#discussion_r488333064



##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -147,95 +153,78 @@ data.map (new RichMapFunction[String, Int] {
 
 
 
-Rich functions provide, in addition to the user-defined function (map,
-reduce, etc), four methods: `open`, `close`, `getRuntimeContext`, and
-`setRuntimeContext`. These are useful for parameterizing the function
-(see [Passing Parameters to Functions]({{ site.baseurl 
}}/dev/batch/index.html#passing-parameters-to-functions)),
-creating and finalizing local state, accessing broadcast variables (see
-[Broadcast Variables]({{ site.baseurl 
}}/dev/batch/index.html#broadcast-variables)), and for accessing runtime
-information such as accumulators and counters (see
-[Accumulators and Counters](#accumulators--counters)), and information
-on iterations (see [Iterations]({{ site.baseurl }}/dev/batch/iterations.html)).
+除了用户自定义的 function(map,reduce 等),Rich functions 
还提供了四个方法:`open`、`close`、`getRuntimeContext` 和
+`setRuntimeContext`。这些方法对于参数化 function
+(参阅 [给 function 传递参数]({% link dev/batch/index.zh.md 
%}#passing-parameters-to-functions)),

Review comment:
   ```suggestion
   (参阅 [给 function 传递参数]({% link dev/batch/index.zh.md 
%}#passing-parameters-to-functions)),
   ```

##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -147,95 +153,78 @@ data.map (new RichMapFunction[String, Int] {
 
 
 
-Rich functions provide, in addition to the user-defined function (map,
-reduce, etc), four methods: `open`, `close`, `getRuntimeContext`, and
-`setRuntimeContext`. These are useful for parameterizing the function
-(see [Passing Parameters to Functions]({{ site.baseurl 
}}/dev/batch/index.html#passing-parameters-to-functions)),
-creating and finalizing local state, accessing broadcast variables (see
-[Broadcast Variables]({{ site.baseurl 
}}/dev/batch/index.html#broadcast-variables)), and for accessing runtime
-information such as accumulators and counters (see
-[Accumulators and Counters](#accumulators--counters)), and information
-on iterations (see [Iterations]({{ site.baseurl }}/dev/batch/iterations.html)).
+除了用户自定义的 function(map,reduce 等),Rich functions 
还提供了四个方法:`open`、`close`、`getRuntimeContext` 和
+`setRuntimeContext`。这些方法对于参数化 function
+(参阅 [给 function 传递参数]({% link dev/batch/index.zh.md 
%}#passing-parameters-to-functions)),
+创建和最终确定本地状态,访问广播变量(参阅

Review comment:
   ```suggestion
   创建和最终确定本地状态,访问广播变量(参阅
   ```

##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -147,95 +153,78 @@ data.map (new RichMapFunction[String, Int] {
 
 
 
-Rich functions provide, in addition to the user-defined function (map,
-reduce, etc), four methods: `open`, `close`, `getRuntimeContext`, and
-`setRuntimeContext`. These are useful for parameterizing the function
-(see [Passing Parameters to Functions]({{ site.baseurl 
}}/dev/batch/index.html#passing-parameters-to-functions)),
-creating and finalizing local state, accessing broadcast variables (see
-[Broadcast Variables]({{ site.baseurl 
}}/dev/batch/index.html#broadcast-variables)), and for accessing runtime
-information such as accumulators and counters (see
-[Accumulators and Counters](#accumulators--counters)), and information
-on iterations (see [Iterations]({{ site.baseurl }}/dev/batch/iterations.html)).
+除了用户自定义的 function(map,reduce 等),Rich functions 
还提供了四个方法:`open`、`close`、`getRuntimeContext` 和
+`setRuntimeContext`。这些方法对于参数化 function
+(参阅 [给 function 传递参数]({% link dev/batch/index.zh.md 
%}#passing-parameters-to-functions)),
+创建和最终确定本地状态,访问广播变量(参阅
+[广播变量]({% link dev/batch/index.zh.md %}#broadcast-variables 
)),以及访问运行时信息,例如累加器和计数器(参阅
+[累加器和计数器](#accumulators--counters)),以及迭代器的相关信息(参阅 [迭代器]({% link 
dev/batch/iterations.zh.md %}))

Review comment:
   ```suggestion
   [累加器和计数器](#accumulators--counters)),以及迭代器的相关信息(参阅 [迭代器]({% link 
dev/batch/iterations.zh.md %}))
   ```

##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -147,95 +153,78 @@ data.map (new RichMapFunction[String, Int] {
 
 
 
-Rich functions provide, in addition to the user-defined function (map,
-reduce, etc), four methods: `open`, `close`, `getRuntimeContext`, and
-`setRuntimeContext`. These are useful for parameterizing the function
-(see [Passing Parameters to Functions]({{ site.baseurl 
}}/dev/batch/index.html#passing-parameters-to-functions)),
-creating and finalizing local state, accessing broadcast variables (see
-[Broadcast Variables]({{ site.baseurl 
}}/dev/batch/index.html#broadcast-variables)), and for accessing runtime
-information such as accumulators and counters (see
-[Accumulators and Counters](#accumulators--counters)), and information
-on iterations (see [Iterations]({{ site.baseurl }}/dev/batch/iterations.html)).
+除了用户自定义的 function(map,reduce 等),Rich functions 
还提供了四个方法:`open`、`close`、`getRuntimeContext` 和
+`setRuntimeContext`。这些方法对于参数化 function
+(

[GitHub] [flink] RocMarshal commented on a change in pull request #13225: [FLINK-18974][docs-zh]Translate the 'User-Defined Functions' page of "Application Development's DataStream API" into Chinese

2020-08-25 Thread GitBox


RocMarshal commented on a change in pull request #13225:
URL: https://github.com/apache/flink/pull/13225#discussion_r476500930



##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -23,16 +23,14 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-Most operations require a user-defined function. This section lists different
-ways of how they can be specified. We also cover `Accumulators`, which can be
-used to gain insights into your Flink application.
+大多数操作都需要用户自定义函数。本节列出了实现用户自定义函数的不同方式。还会介绍 `Accumulators`(累加器),可用于深入了解你的 Flink 
应用程序。
 
 
 
 
-## Implementing an interface
+## 实现接口

Review comment:
   I think that we should improve on the section-titles in the whole page  
according to the item `4. 标题锚点链接` of [Flink Translation 
Specifications](https://cwiki.apache.org/confluence/display/FLINK/Flink+Translation+Specifications)

##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -147,95 +142,75 @@ data.map (new RichMapFunction[String, Int] {
 
 
 
-Rich functions provide, in addition to the user-defined function (map,
-reduce, etc), four methods: `open`, `close`, `getRuntimeContext`, and
-`setRuntimeContext`. These are useful for parameterizing the function
-(see [Passing Parameters to Functions]({{ site.baseurl 
}}/dev/batch/index.html#passing-parameters-to-functions)),
-creating and finalizing local state, accessing broadcast variables (see
-[Broadcast Variables]({{ site.baseurl 
}}/dev/batch/index.html#broadcast-variables)), and for accessing runtime
-information such as accumulators and counters (see
-[Accumulators and Counters](#accumulators--counters)), and information
-on iterations (see [Iterations]({{ site.baseurl }}/dev/batch/iterations.html)).
+除了用户自定义的功能(map,reduce 等),富函数还提供了四个方法:`open`、`close`、`getRuntimeContext` 和
+`setRuntimeContext`。这些对于参数化功能很有用
+(参阅 [给函数传递参数]({{ site.baseurl 
}}/zh/dev/batch/index.html#passing-parameters-to-functions)),
+创建和最终确定本地状态,访问广播变量(参阅
+[广播变量]({{ site.baseurl 
}}/zh/dev/batch/index.html#broadcast-variables)),以及访问运行时信息,例如累加器和计数器(参阅
+[累加器和计数器](#累加器和计数器)),以及迭代器的相关信息(参阅 [迭代器]({{ site.baseurl 
}}/zh/dev/batch/iterations.html))。
 
 {% top %}
 
-## Accumulators & Counters
+## 累加器和计数器
 
-Accumulators are simple constructs with an **add operation** and a **final 
accumulated result**,
-which is available after the job ended.
+累加器是具有**加法运算**和**最终累加结果**的一种简单结构,可在作业结束后使用。
 
-The most straightforward accumulator is a **counter**: You can increment it 
using the
-```Accumulator.add(V value)``` method. At the end of the job Flink will sum up 
(merge) all partial
-results and send the result to the client. Accumulators are useful during 
debugging or if you
-quickly want to find out more about your data.
+最简单的累加器就是**计数器**: 你可以使用
+```Accumulator.add(V value)``` 方法将其递增。在作业结束时,Flink 会汇总(合并)所有部分的结果并将其发送给客户端。
+在调试过程中或在你想快速了解有关数据更多信息时,累加器作用很大。
 
-Flink currently has the following **built-in accumulators**. Each of them 
implements the
-{% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/Accumulator.java
 "Accumulator" %}
-interface.
+Flink 目前有如下**内置累加器**。每个都实现了
+{% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/Accumulator.java
 "累加器" %}
+接口。
 
 - {% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/IntCounter.java
 "__IntCounter__" %},
   {% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/LongCounter.java
 "__LongCounter__" %}
-  and {% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/DoubleCounter.java
 "__DoubleCounter__" %}:
-  See below for an example using a counter.
-- {% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/Histogram.java
 "__Histogram__" %}:
-  A histogram implementation for a discrete number of bins. Internally it is 
just a map from Integer
-  to Integer. You can use this to compute distributions of values, e.g. the 
distribution of
-  words-per-line for a word count program.
+  和 {% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/DoubleCounter.java
 "__DoubleCounter__" %}:
+  有关使用计数器的示例,请参见下文。
+- {% gh_link 
/flink-core/src/main/java/org/apache/flink/api/common/accumulators/Histogram.java
 "__直方图__" %}:
+  离散数量的柱状直方图实现。 在内部,它只是整形到整形的映射。你可以使用它来计算值的分布,例如,单词计数程序的每行单词的分布情况。
 
-__How to use accumulators:__
+__如何使用累加器:__
 
-First you have to create an accumulator object (here a counter) in the 
user-defined transformation
-function where you want to use it.
+首先,你要在需要使用累加器的用户自定义的转换函数中创建一个累加器对象(此处是计数器) 。
 
 {% highlight java %}
 private IntCounter numLines = new IntCounter();
 {% endhighlight %}
 
-Second you have to register the accumulator object, typically in the 
```open()``` method of the
-*rich* function. Here you also define the name.
+其次,你必须在富函数的```open()```方法中注册累加器对象。也可以在此处定义名称。
 
 {% highlight java %}
 getRuntimeContext().addAccumulator("num-lines", this.numLines);
 {% endhighlight %}
 

[GitHub] [flink] RocMarshal commented on a change in pull request #13225: [FLINK-18974][docs-zh]Translate the 'User-Defined Functions' page of "Application Development's DataStream API" into Chinese

2020-08-26 Thread GitBox


RocMarshal commented on a change in pull request #13225:
URL: https://github.com/apache/flink/pull/13225#discussion_r477897780



##
File path: docs/dev/user_defined_functions.zh.md
##
@@ -147,95 +142,75 @@ data.map (new RichMapFunction[String, Int] {
 
 
 
-Rich functions provide, in addition to the user-defined function (map,
-reduce, etc), four methods: `open`, `close`, `getRuntimeContext`, and
-`setRuntimeContext`. These are useful for parameterizing the function
-(see [Passing Parameters to Functions]({{ site.baseurl 
}}/dev/batch/index.html#passing-parameters-to-functions)),
-creating and finalizing local state, accessing broadcast variables (see
-[Broadcast Variables]({{ site.baseurl 
}}/dev/batch/index.html#broadcast-variables)), and for accessing runtime
-information such as accumulators and counters (see
-[Accumulators and Counters](#accumulators--counters)), and information
-on iterations (see [Iterations]({{ site.baseurl }}/dev/batch/iterations.html)).
+除了用户自定义的功能(map,reduce 等),富函数还提供了四个方法:`open`、`close`、`getRuntimeContext` 和
+`setRuntimeContext`。这些对于参数化功能很有用
+(参阅 [给函数传递参数]({{ site.baseurl 
}}/zh/dev/batch/index.html#passing-parameters-to-functions)),
+创建和最终确定本地状态,访问广播变量(参阅
+[广播变量]({{ site.baseurl 
}}/zh/dev/batch/index.html#broadcast-variables)),以及访问运行时信息,例如累加器和计数器(参阅

Review comment:
   @klion26 What do you think about this?





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