YngwieWang commented on a change in pull request #9150: [FLINK-13227][docs-zh] 
Translate "asyncio" page into Chinese
URL: https://github.com/apache/flink/pull/9150#discussion_r304712136
 
 

 ##########
 File path: docs/dev/stream/operators/asyncio.zh.md
 ##########
 @@ -26,71 +26,55 @@ under the License.
 * ToC
 {:toc}
 
-This page explains the use of Flink's API for asynchronous I/O with external 
data stores.
-For users not familiar with asynchronous or event-driven programming, an 
article about Futures and
-event-driven programming may be useful preparation.
+本文讲解 Flink 用于访问外部数据存储的异步 I/O API。
+对于不熟悉异步或者事件驱动编程的用户,建议先储备一些关于 Future 和事件驱动编程的知识。
 
-Note: Details about the design and implementation of the asynchronous I/O 
utility can be found in the proposal and design document
-[FLIP-12: Asynchronous I/O Design and 
Implementation](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=65870673).
+提示:这篇文档 [FLIP-12: 异步 I/O  
的设计和实现](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=65870673)
 介绍了关于设计和实现异步 I/O 功能的细节。
 
+## 对于异步 I/O 操作的需求
 
-## The need for Asynchronous I/O Operations
+在与外部系统交互(用数据库中的数据扩充流数据)的时候,需要考虑与外部系统的通信延迟对整个流处理应用的影响。
 
-When interacting with external systems (for example when enriching stream 
events with data stored in a database), one needs to take care
-that communication delay with the external system does not dominate the 
streaming application's total work.
+简单地访问外部数据库的数据,比如使用 `MapFunction`,通常意味着**同步**交互:
+`MapFunction` 向数据库发送一个请求然后一直等待,直到收到响应。在许多情况下,等待占据了函数运行的大部分时间。
 
-Naively accessing data in the external database, for example in a 
`MapFunction`, typically means **synchronous** interaction:
-A request is sent to the database and the `MapFunction` waits until the 
response has been received. In many cases, this waiting
-makes up the vast majority of the function's time.
-
-Asynchronous interaction with the database means that a single parallel 
function instance can handle many requests concurrently and
-receive the responses concurrently. That way, the waiting time can be 
overlayed with sending other requests and
-receiving responses. At the very least, the waiting time is amortized over 
multiple requests. This leads in most cased to much higher
-streaming throughput.
+与数据库异步交互是指一个并行函数实例可以并发地处理多个请求和接收多个响应。这样,函数在等待的时间可以发送其他请求和接收其他响应。至少等待的时间可以被多个请求摊分。大多数情况下,异步交互可以大幅度提高流处理的吞吐量。
 
 <img src="{{ site.baseurl }}/fig/async_io.svg" class="center" width="50%" />
 
-*Note:* Improving throughput by just scaling the `MapFunction` to a very high 
parallelism is in some cases possible as well, but usually
-comes at a very high resource cost: Having many more parallel MapFunction 
instances means more tasks, threads, Flink-internal network
-connections, network connections to the database, buffers, and general 
internal bookkeeping overhead.
+*注意:*仅仅提高 `MapFunction` 
的并行度(parallelism)在有些情况下也可以提升吞吐量,但是这样做通常会导致非常高的资源消耗:更多的并行 `MapFunction` 实例意味着更多的 
Task、更多的线程、更多的 Flink 内部网络连接、 更多的与数据库的网络连接、更多的缓冲和更多程序内部协调的开销。
 
 
-## Prerequisites
+## 先决条件
 
-As illustrated in the section above, implementing proper asynchronous I/O to a 
database (or key/value store) requires a client
-to that database that supports asynchronous requests. Many popular databases 
offer such a client.
+如上节所述,正确地实现数据库(或键/值存储)的异步 I/O 交互需要支持异步请求的数据库客户端。许多主流数据库都提供了这样的客户端。
 
-In the absence of such a client, one can try and turn a synchronous client 
into a limited concurrent client by creating
-multiple clients and handling the synchronous calls with a thread pool. 
However, this approach is usually less
-efficient than a proper asynchronous client.
+如果没有这样的客户端,可以通过创建多个客户端并使用线程池处理同步调用的方法,将同步客户端转换为有限并发的客户端。然而,这种方法通常比正规的异步客户端效率低。
 
 
-## Async I/O API
+## 异步 I/O API
 
-Flink's Async I/O API allows users to use asynchronous request clients with 
data streams. The API handles the integration with
-data streams, well as handling order, event time, fault tolerance, etc.
+Flink 的异步 I/O API 允许用户在流处理中使用异步请求客户端。API 处理与数据流的集成、顺序、事件时间和容错等。
 
-Assuming one has an asynchronous client for the target database, three parts 
are needed to implement a stream transformation
-with asynchronous I/O against the database:
+在具备异步数据库客户端的基础上,实现数据流转换操作与数据库的异步 I/O 交互需要以下三部分:
 
-  - An implementation of `AsyncFunction` that dispatches the requests
-  - A *callback* that takes the result of the operation and hands it to the 
`ResultFuture`
-  - Applying the async I/O operation on a DataStream as a transformation
+- 实现分发请求的 `AsyncFunction`
+- 获取数据库交互的结果并发送给 `ResultFuture` 的 *回调* 函数
+- 将异步 I/O 操作应用于 `DataStream` 作为 `DataStream` 的一次转换操作。
 
-The following code example illustrates the basic pattern:
+下面是基本的代码模板:
 
 <div class="codetabs" markdown="1">
 <div data-lang="java" markdown="1">
 {% highlight java %}
-// This example implements the asynchronous request and callback with Futures 
that have the
-// interface of Java 8's futures (which is the same one followed by Flink's 
Future)
+// 这个例子使用 Java 8 的 Future 接口(与 Flink 的 Future 相同)实现了异步请求和回调。
 
 /**
- * An implementation of the 'AsyncFunction' that sends requests and sets the 
callback.
+ * 实现 'AsyncFunction' 用于发送请求和设置回调。
  */
 class AsyncDatabaseRequest extends RichAsyncFunction<String, Tuple2<String, 
String>> {
 
-    /** The database specific client that can issue concurrent requests with 
callbacks */
+    /** 使用回调函数来并发发送请求的数据库客户端 */
 
 Review comment:
   “能够利用回调函数并发发送请求的数据库客户端”可以么?

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


With regards,
Apache Git Services

Reply via email to