Selaa lähdekoodia

docs(zh_CN/extension):translate four files into chinese

ican_do_it 4 vuotta sitten
vanhempi
commit
269dee9b35

+ 22 - 21
docs/zh_CN/extension/function.md

@@ -1,59 +1,60 @@
-# Function Extension
+# 函数扩展
 
-In the Kuiper SQL syntax, [many built-in functions](../sqls/built-in_functions.md) are provided to server for various reusable business logic. However, the users still likely need various reusable business logic which are not covered by the built ins. The function extension is presented to customized the functions.
+在 Kuiper SQL 语法中,向服务器提供了[许多内置函数](../sqls/built-in_functions.md),用于各种可重用的业务逻辑。 但是,用户仍然可能需要其他未被内置插件覆盖的可重用的业务逻辑。 提供函数扩展是为了自定义函数。
 
-## Developing
+## 开发
 
-### Develop a customized function
+### 开发一个定制函数
 
-To develop a function for Kuiper is to implement [api.Function](../../../xstream/api/stream.go) interface and export it as a golang plugin.
+为 Kuiper 开发函数的过程,就是实现 [api.Function](../../../xstream/api/stream.go) 接口并将其导出为 golang 插件。
 
-Before starting the development, you must [setup the environment for golang plugin](overview.md#setup-the-plugin-developing-environment). 
+在开始开发之前,您必须为 [golang 插件设置环境](overview.md#setup-the-plugin-developing-environment)。
 
-To develop a function, the _Validate_ method is firstly to be implemented. This method will be called during SQL validation. In this method, a slice of [xsql.Expr](../../../xsql/ast.go) is passed as the parameter that contains the arguments for this function in the runtime. The developer can do a validation against it to check the argument count and type etc. If validation is successful, return nil. Otherwise, return an error object.
+为了开发函数,首先要实现 _Validate_ 方法。 在 SQL 验证期间将调用此方法。 在此方法中,将传递 [xsql.Expr](../../../xsql/ast.go) 的切片作为参数,该参数包含运行时该函数的参数。 开发人员可以对其进行验证,以检查参数计数和类型等。如果验证成功,则返回 nil。 否则,返回一个错误对象。
 
 ```go
 //The argument is a list of xsql.Expr
 Validate(args []interface{}) error
 ```
-There are 2 types of functions: aggregate function and common function. For aggregate function, if the argument is a column, the received value will always be a slice of the column values in a group. The extended function must distinguish the function type by implement _IsAggregate_ method.
+函数有2种类型:聚合函数和通用函数。 对于聚合函数,如果参数为列,则接收的值将始终是组中列值的一部分。 扩展函数必须通过实施 _IsAggregate_ 方法来区分函数类型。
 
 ```go
 //If this function is an aggregate function. Each parameter of an aggregate function will be a slice
 IsAggregate() bool
 ```
 
-The main task for a Function is to implement _exec_ method. The method will be leverage to calculate the result of the function in the SQL. The argument is a slice of the values for the function parameters. You can use them to do the calculation. If the calculation is successful, return the result and true; otherwise, return nil and false. 
+函数的主要任务是实现 _exec_ 方法。 该方法将用于计算 SQL 中函数的结果。 参数是函数参数值的一部分。 您可以使用它们进行计算。 如果计算成功,则返回结果并返回 true; 否则,返回 nil 和 false。
 
 ```go
-//Execute the function, return the result and if execution is successful.If execution fails, return the error and false. 
+//执行函数,如果执行成功,返回结果,如果执行失败,返回错误和 false。
 Exec(args []interface{}) (interface{}, bool)
-```  
+```
 
-As the function itself is a plugin, it must be in the main package. Given the function struct name is myFunction. At last of the file, the source must be exported as a symbol as below. There are [2 types of exported symbol supported](overview.md#plugin-development). For function extension, if there is no internal state, it is recommended to export a singleton instance.
+由于该函数本身是一个插件,因此必须位于主程序包中。 给定的函数结构名称为 myFunction。 在文件的最后,必须将源文件作为符号导出,如下所示。 有[2种类型的导出符号被支持](overview.md#plugin-development)。 对于函数扩展,如果没有内部状态,建议导出单例实例。
 
 ```go
 var MyFunction myFunction
 ```
 
-The [Echo Function](../../../plugins/functions/echo.go) is a good example.
+[Echo Function](../../../plugins/functions/echo.go) 是一个很好的示例。
 
-### Package the source
-Build the implemented function as a go plugin and make sure the output so file resides in the plugins/functions folder.
+### 源文件打包
+将实现的函数构建为 go 插件,并确保输出 s o文件位于 plugins/functions 文件夹中。
 
 ```bash
 go build --buildmode=plugin -o plugins/functions/MyFunction.so plugins/functions/my_function.go
 ```
 
-### Usage
+### 使用
+
+如果自定义函数遵循以下约定,则可以直接在规则的 SQL 中使用。
 
-The customized function can be directly used in the SQL of a rule if it follows the below convention.
+如果已经开发了函数实现 MyFunction,则应该具有:
 
-If you have developed a function implementation MyFunction, you should have:
-1. In the plugin file, symbol MyFunction is exported.
-2. The compiled MyFunction.so file is located inside _plugins/functions_
+1. 在插件文件中,将导出符号 MyFunction。
+2. 编译的 MyFunction.so 文件位于 _plugins/functions_ 内部
 
-To use it, just call it in the SQL inside a rule definition:
+要使用它,只需在规则定义中的 SQL 中调用它:
 ```json
 {
   "id": "rule1",

+ 7 - 7
docs/zh_CN/extension/overview.md

@@ -1,10 +1,10 @@
 # 扩展
 
-Kuiper允许用户自定义不同类型的扩展。 
+Kuiper 允许用户自定义不同类型的扩展。 
 
-- 源扩展用于扩展不同的流源,例如使用来自其他消息服务器的数据。 Kuiper对 [MQTT消息服务器](../rules/sources/mqtt.md)的内置源提供支持。
-- Sink / Action扩展用于将发布/推送数据扩展到不同的目标,例如数据库,其他消息系统,Web界面或文件系统。 Kuiper中提供内置动作支持,请参阅 [MQTT](../rules/sinks/mqtt.md) & [日志文件](../rules/sinks/logs.md).。
-- 函数扩展允许用户扩展SQL中使用的不同函数。 Kuiper支持内置函数,请参见 [functions](../sqls/built-in_functions.md)。
+- 源扩展用于扩展不同的流源,例如使用来自其他消息服务器的数据。Kuipe r对 [MQTT 消息服务器](../rules/sources/mqtt.md)的内置源提供支持。
+- Sink/Action 扩展用于将发布/推送数据扩展到不同的目标,例如数据库,其他消息系统,Web 界面或文件系统。Kuiper 中提供内置动作支持,请参阅  [MQTT](../rules/sinks/mqtt.md)  & [日志文件](../rules/sinks/logs.md).。
+- 函数扩展允许用户扩展 SQL 中使用的不同函数。 Kuiper支持内置函数,请参见 [functions](../sqls/built-in_functions.md)。
 
 请阅读以下内容,了解如何实现不同的扩展。
 
@@ -14,11 +14,11 @@ Kuiper允许用户自定义不同类型的扩展。
 
 ### 状态存储
 
-Kuiper扩展通过context参数暴露了一个基于键值对的状态存储接口,可用于所有类型的扩展,包括Source,Sink和Function扩展.
+Kuiper扩展通过context参数暴露了一个基于键值对的状态存储接口,可用于所有类型的扩展,包括 Source,Sink  Function 扩展.
 
-状态为键值对,其中键为string类型而值为任意数据。键的作用域仅为当前扩展的实例。
+状态为键值对,其中键为 string 类型而值为任意数据。键的作用域仅为当前扩展的实例。
 
-用户可通过context对象访问状态存储。状态相关方法包括putState, getState, incrCounter, getCounter and deleteState。
+用户可通过 context 对象访问状态存储。状态相关方法包括 putState, getState, incrCounter, getCounter and deleteState。
 
 以下代码为函数扩展访问状态的实例。该函数将计算传入的单词数,并将累积数目保存在状态中。
 

+ 25 - 23
docs/zh_CN/extension/sink.md

@@ -1,41 +1,42 @@
-# Sink Extension
+# Sink (目标) 扩展
 
-Sink feed data from Kuiper into external systems. Kuiper has built-in sink support for [MQTT broker](../rules/sinks/mqtt.md) and [log sink](../rules/sinks/logs.md). There are still needs to publish data to various external systems include messaging systems and database etc. Sink extension is presented to meet this requirement.
+Kuiper 可以将数据接收到外部系统。 Kuiper具有对  [MQTT 消息服务器](../rules/sinks/mqtt.md) 和 [日志目标](../rules/sinks/logs.md)的内置接收器支持。然而, 仍然需要将数据发布到各种外部系统,包括消息传递系统和数据库等。Sink (目标)扩展正是为了满足这一要求。
 
-## Developing
+## 开发
 
-### Develop a sink
+### 开发 Sink (目标)
 
-To develop a sink for Kuiper is to implement [api.Sink](../../../xstream/api/stream.go) interface and export it as a golang plugin.
+为 Kuiper 开发 Sink (目标),是实现 [api.Sink](../../../xstream/api/stream.go) 接口并将其导出为 golang 插件。
 
-Before starting the development, you must [setup the environment for golang plugin](overview.md#setup-the-plugin-developing-environment). 
+在开始开发之前,您必须为 [golang 插件设置环境](overview.md#setup-the-plugin-developing-environment)。
 
-To develop a sink, the _Configure_ method must be implemented. This method will be called once the sink is initialized. In this method, a map that contains the configuration in the [rule actions definition](../rules/overview.md#actions) is passed in. Typically, there will be information such as host, port, user and password of the external system. You can use this map to initialize this sink.
+要开发 Sink (目标),必须实现 _Configure_ 方法。 接收器初始化后,将调用此方法。 在此方法中,将传入包含 [规则操作定义](../rules/overview.md#actions)中的配置映射,通常,将包含诸如外部系统的主机、端口、用户和密码之类的信息。您可以使用此映射来初始化此 Sink (目标)。
 
 ```go
 //Called during initialization. Configure the sink with the properties from action definition 
 Configure(props map[string]interface{}) error
 ```
-The next task is to implement _open_ method. The implementation should be synchronized to create a connection to the external system. A context parameter is provided to retrieve the context information, logger and rule meta information.
+下一个任务是实现 _open_ 方法。 该实现应和创建到外部系统的连接同步。 提供了上下文参数以检索上下文信息、日志和规则元信息。
+
 ```go
 //Should be sync function for normal case. The container will run it in go func
 Open(ctx StreamContext) error
-```  
+```
 
-The main task for a Sink is to implement _collect_ method. The function will be invoked when Kuiper feed any data into the sink. As an infinite stream, this function will be invoked continuously. The task of this function is to publish data to the external system. The first parameter is the context, and the second parameter is the data received from Kuiper.
+Sink (目标)的主要任务是实现 _collect_ 方法。 当 Kuiper 将任何数据输入 Sink (目标)时,将调用该函数。 作为无限流,此函数将被连续调用。 此功能的任务是将数据发布到外部系统。 第一个参数是上下文,第二个参数是从 Kuiper 接收的数据。
 
 ```go
 //Called when each row of data has transferred to this sink
 Collect(ctx StreamContext, data interface{}) error
-```  
+```
 
-The last method to implement is _Close_ which literally close the connection. It is called when the stream is about to terminate. You could also do any clean up work in this function.
+最后要实现的方法是 _Close_ ,它实际上关闭了连接。 当流即将终止时调用它。 您也可以在此函数中执行任何清理工作。
 
 ```go
 Close(ctx StreamContext) error
 ```
 
-As the sink itself is a plugin, it must be in the main package. Given the sink struct name is mySink. At last of the file, the sink must be exported as a symbol as below. There are [2 types of exported symbol supported](overview.md#plugin-development). For sink extension, states are usually needed, so it is recommended to export a constructor function.
+由于 Sink (目标)本身是一个插件,因此它必须位于主程序包中。 给定 Sink (目标)结构名称为 mySink。 在文件的最后,必须将 Sink (目标)导出为以下符号。 共有 [2种类型的导出符号](overview.md#plugin-development)。 对于 Sink (目标)扩展,通常需要状态,因此建议导出构造函数。
 
 ```go
 func MySink() api.Sink {
@@ -43,24 +44,25 @@ func MySink() api.Sink {
 }
 ```
 
-The [Memory Sink](../../../plugins/sinks/memory.go) is a good example.
+[Memory Sink](../../../plugins/sinks/memory.go) 是一个很好的示例。
 
-### Package the sink
-Build the implemented sink as a go plugin and make sure the output so file resides in the plugins/sinks folder.
+### 将 Sink (目标)打包
+将实现的 Sink (目标)构建为 go 插件,并确保输出的 so 文件位于 plugins/sinks 文件夹中。
 
 ```bash
 go build --buildmode=plugin -o plugins/sinks/MySink.so plugins/sinks/my_sink.go
 ```
 
-### Usage
+### 使用
+
+自定义 Sink (目标)在 [动作定义](../rules/overview.md#actions)规定。 它的名称用作操作的键, 配置就是值。
 
-The customized sink is specified in a [actions definition](../rules/overview.md#actions). Its name is used as the key of the action. The configuration is the value.
+如果您开发了 Sink (目标)实现 MySink,则应该具有:
+1. 在插件文件中,将导出符号 MySink。
+2. 编译的 MySink.so 文件位于 _plugins/sinks_ 内部
 
-If you have developed a sink implementation MySink, you should have:
-1. In the plugin file, symbol MySink is exported.
-2. The compiled MySink.so file is located inside _plugins/sinks_
+要使用它,请在规则定义内定义动作 mySink:
 
-To use it, define the action mySink inside a rule definition:
 ```json
 {
   "id": "rule1",
@@ -75,4 +77,4 @@ To use it, define the action mySink inside a rule definition:
   ]
 }
 ```
-Whereas, _mySink_ is a key of the actions. The value of mySink is the properties for that sink.
+而 _mySink_ 是动作的键。 mySink 的值是该 Sink (目标)的属性。

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 38 - 38
docs/zh_CN/extension/source.md