YngwieWang commented on a change in pull request #9348: [FLINK-13505][docs-zh] 
Translate "Java Lambda Expressions" page into Chinese
URL: https://github.com/apache/flink/pull/9348#discussion_r312387424
 
 

 ##########
 File path: docs/dev/java_lambdas.zh.md
 ##########
 @@ -22,41 +22,37 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-Java 8 introduced several new language features designed for faster and 
clearer coding. With the most important feature,
-the so-called "Lambda Expressions", it opened the door to functional 
programming. Lambda expressions allow for implementing and
-passing functions in a straightforward way without having to declare 
additional (anonymous) classes.
+Java 8 引入了几种新的语言特性,旨在实现更快、更清晰的编码。 作为最重要的特性,即所谓的“Lambda 
表达式”,它开启了函数式编程的大门。Lambda 表达式允许以简捷的方式实现和传递函数,而无需声明额外的(匿名)类。
 
-<span class="label label-danger">Attention</span> Flink supports the usage of 
lambda expressions for all operators of the Java API, however, whenever a 
lambda expression uses Java generics you need to declare type information 
*explicitly*. 
+<span class="label label-danger">注意</span> Flink 支持对 Java API 的所有算子使用 Lambda 
表达式,但是,当 Lambda 表达式使用 Java 泛型时,你需要*显式*声明类型信息。
 
-This document shows how to use lambda expressions and describes current 
limitations. For a general introduction to the
-Flink API, please refer to the [Programming Guide]({{ site.baseurl 
}}/dev/api_concepts.html)
+本文档介绍了如何使用 Lambda 表达式并描述了其在当前应用中的限制。有关 Flink API 的一般性介绍, 请参阅[编程指南]({{ 
site.baseurl }}/zh/dev/api_concepts.html)。
 
-### Examples and Limitations
+### 示例和限制
 
-The following example illustrates how to implement a simple, inline `map()` 
function that squares its input using a lambda expression.
-The types of input `i` and output parameters of the `map()` function need not 
to be declared as they are inferred by the Java compiler.
+下例演示了如何实现一个简单的行内 `map()` 函数,它使用 Lambda 表达式计算输入的平方。不需要声明 `map()` 函数的输入 `i` 
和输出参数的数据类型,因为 Java 编译器会对它们做出推断。
 
 {% highlight java %}
 env.fromElements(1, 2, 3)
-// returns the squared i
+// 返回 i 的平方
 .map(i -> i*i)
 .print();
 {% endhighlight %}
 
-Flink can automatically extract the result type information from the 
implementation of the method signature `OUT map(IN value)` because `OUT` is not 
generic but `Integer`.
+由于 `OUT` 是 `Integer` 而不是泛型,Flink 可以由方法签名 `OUT map(IN value)` 的实现中自动提取出结果的类型信息。
 
-Unfortunately, functions such as `flatMap()` with a signature `void flatMap(IN 
value, Collector<OUT> out)` are compiled into `void flatMap(IN value, Collector 
out)` by the Java compiler. This makes it impossible for Flink to infer the 
type information for the output type automatically.
+不幸的是,`flatMap()` 这样的函数,它的签名 `void flatMap(IN value, Collector<OUT> out)` 被 
Java 编译器编译为 `void flatMap(IN value, Collector out)`。这样 Flink 就无法自动推断输出的类型信息了。
 
-Flink will most likely throw an exception similar to the following:
+Flink 很可能抛出类似如下的异常:
 
 {% highlight plain%}
 org.apache.flink.api.common.functions.InvalidTypesException: The generic type 
parameters of 'Collector' are missing.
-    In many cases lambda methods don't provide enough information for 
automatic type extraction when Java generics are involved.
+    In many cases Lambda methods don't provide enough information for 
automatic type extraction when Java generics are involved.
 
 Review comment:
   非常感谢,你真细心。因为我翻译的时候统一把“lambda”翻译成“Lambda”,可能是不小心整体替换了,已经修正了。另外你觉得翻译的 lambda 
全部首字母大写是否合适?因为我觉得翻译以后有的大写有的小写不统一的话有可能造成困惑。再次感谢!

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


With regards,
Apache Git Services

Reply via email to