提交 de983068 编写于 作者: Y youjun2018

65.md 删除文件中英文 by Islotus 20190315

上级 46bbbea5
# Query Configuration
# 查询配置
Table API and SQL queries have the same semantics regardless whether their input is bounded batch input or unbounded stream input. In many cases, continuous queries on streaming input are capable of computing accurate results that are identical to offline computed results. However, this is not possible in general case because continuous queries have to restrict the size of the state they are maintaining in order to avoid to run out of storage and to be able to process unbounded streaming data over a long period of time. As a result, a continuous query might only be able to provide approximated results depending on the characteristics of the input data and the query itself.
无论表达式输入是有界批量输入还是无界流输入,Table API和 SQL 查询都具有相同的语义。在许多情况下,对流输入的连续查询能够计算与离线计算结果相同的准确结果。然而,这在一般情况下是不可能的,因为连续查询必须限制它们维护的状态的大小,以避免耗尽存储并且能够在很长一段时间内处理无界流数据。因此,连续查询可能只能提供近似结果,具体取决于输入数据的特征和查询本身。(这里需要说明的是,状态的本质其实还是存储,所以对于状态的维护,需要不断的清理)
Flink’s Table API and SQL interface provide parameters to tune the accuracy and resource consumption of continuous queries. The parameters are specified via a `QueryConfig` object. The `QueryConfig` can be obtained from the `TableEnvironment` and is passed back when a `Table` is translated, i.e., when it is [transformed into a DataStream](../common.html#convert-a-table-into-a-datastream-or-dataset) or [emitted via a TableSink](../common.html#emit-a-table).
Flink 的 Table API 和 SQ L接口提供参数来调整连续查询的准确性和资源消耗。参数通过 `QueryConfig` 对象指定。`QueryConfig` 可以从 `TableEnvironment` 获得,并在转换 `Table` 时传回,即,当它[转换为DataStream](../common.html#convert-a-table-into-a-datastream-or-dataset)[通过TableSink发出时](../common.html#emit-a-table)
......@@ -70,20 +64,12 @@ val tableEnv = TableEnvironment.getTableEnvironment(env)
In the following we describe the parameters of the `QueryConfig` and how they affect the accuracy and resource consumption of a query.
在下文中,我们将描述 `QueryConfig` 的参数以及它们如何影响查询的准确性和资源消耗。
## Idle State Retention Time
## 空闲状态保留时间
Many queries aggregate or join records on one or more key attributes. When such a query is executed on a stream, the continuous query needs to collect records or maintain partial results per key. If the key domain of the input stream is evolving, i.e., the active key values are changing over time, the continuous query accumulates more and more state as more and more distinct keys are observed. However, often keys become inactive after some time and their corresponding state becomes stale and useless.
许多查询聚合或连接一个或多个键属性上的记录。在流上执行此类查询时,连续查询需要收集记录或维护每个 key 的部分结果。如果输入流的 key 域正在变化,即,active key 随时间变化,则随着越来越多的不同 key,连续查询累积越来越多的状态。但是,经常在一段时间后 key 变为非活动状态,并且它们的相应状态变得陈旧且无用。
For example the following query computes the number of clicks per session.
例如,以下查询计算每个会话(session)的单击次数。
......@@ -94,29 +80,17 @@ SELECT sessionId, COUNT(*) FROM clicks GROUP BY sessionId;
The `sessionId` attribute is used as a grouping key and the continuous query maintains a count for each `sessionId` it observes. The `sessionId` attribute is evolving over time and `sessionId` values are only active until the session ends, i.e., for a limited period of time. However, the continuous query cannot know about this property of `sessionId` and expects that every `sessionId` value can occur at any point of time. It maintains a count for each observed `sessionId` value. Consequently, the total state size of the query is continuously growing as more and more `sessionId` values are observed.
`sessionId` 属性用作分组 key,连续查询维护其观察到的每个 `sessionId` 的计数。`sessionId` 属性随着时间的推移而变化(进化),并且 `sessionId` 值仅在会话(session)结束之前有效,即,在有限的时间段内。但是,连续查询无法知道 `sessionId` 的此属性,并期望每个 `sessionId` 值都可以在任何时间点发生。它维护每个观察到的 `sessionId` 值的计数。因此,随着观察到越来越多的sessionId值,查询的总状态大小不断增长。
The _Idle State Retention Time_ parameters define for how long the state of a key is retained without being updated before it is removed. For the previous example query, the count of a `sessionId` would be removed as soon as it has not been updated for the configured period of time.
_空闲状态保留时间参数(Idle State Retention Time)_ 定义了在删除 key 之前保留 key 状态多长时间而不进行更新。对于前面的示例查询,只要在配置的时间段内没有更新 `sessionId`,就会删除它的计数。
By removing the state of a key, the continuous query completely forgets that it has seen this key before. If a record with a key, whose state has been removed before, is processed, the record will be treated as if it was the first record with the respective key. For the example above this means that the count of a `sessionId` would start again at `0`.
通过删除 key 的状态,连续查询完全忘记它之前已经看过这个key。如果处理了具有其状态已被删除的 key 的记录,则该记录将被视为具有相应 key 的第一个记录。对于上面的示例,这意味着 `sessionId` 的计数将再次从 `0` 开始。
There are two parameters to configure the idle state retention time:
配置空闲状态保留时间有两个参数:
* The _minimum idle state retention time_ defines how long the state of an inactive key is at least kept before it is removed.
* The _maximum idle state retention time_ defines how long the state of an inactive key is at most kept before it is removed.
* _minimum idle state retention time_ 定义了非活动key的状态在被删除之前至少保持多长时间。
* _maximum idle state retention time_ 义了非活动key的状态在被删除之前最多保留多长时间。
The parameters are specified as follows:
参数规定如下:
......@@ -140,6 +114,4 @@ val qConfig: StreamQueryConfig = ???
Cleaning up state requires additional bookkeeping which becomes less expensive for larger differences of `minTime` and `maxTime`. The difference between `minTime` and `maxTime` must be at least 5 minutes.
清理状态需要额外的簿记(bookkeeping),这对于 `minTime``maxTime` 的较大差异而言变得更实用(便宜)。`minTime``maxTime` 之间的差异必须至少为5分钟。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册