提交 667fa491 编写于 作者: W wizardforcel

2019-02-23 23:10:49

上级 e5f74f04
此差异已折叠。
...@@ -167,12 +167,12 @@ Python API在Windows / Linux / OSX系统上进行了测试。 ...@@ -167,12 +167,12 @@ Python API在Windows / Linux / OSX系统上进行了测试。
本节简要概述了可用的转换。该[转换文档](dataset_transformations.html)与示例全部转换的完整描述。 本节简要概述了可用的转换。该[转换文档](dataset_transformations.html)与示例全部转换的完整描述。
| 转换 | 描述 | ---
| --- | --- |
| **Map** 转换:**Map** PythonDataStream→PythonDataStream
PythonDataStream→PythonDataStream | 采用一个数据元并生成一个数据元。
描述:采用一个数据元并生成一个数据元。
<figure class="highlight">
``` ```
class Doubler(MapFunction): class Doubler(MapFunction):
...@@ -182,13 +182,14 @@ class Doubler(MapFunction): ...@@ -182,13 +182,14 @@ class Doubler(MapFunction):
data_stream.map(Doubler()) data_stream.map(Doubler())
``` ```
</figure>
|
| **FlatMap**
PythonDataStream→PythonDataStream | 采用一个数据元并生成零个,一个或多个数据元。
<figure class="highlight"> ---
转换:**FlatMap** PythonDataStream→PythonDataStream
描述:采用一个数据元并生成零个,一个或多个数据元。
``` ```
class Tokenizer(FlatMapFunction): class Tokenizer(FlatMapFunction):
...@@ -198,13 +199,14 @@ class Tokenizer(FlatMapFunction): ...@@ -198,13 +199,14 @@ class Tokenizer(FlatMapFunction):
data_stream.flat_map(Tokenizer()) data_stream.flat_map(Tokenizer())
``` ```
</figure>
|
| **Filter**
PythonDataStream→PythonDataStream | 计算每个数据元的布尔函数,并保存函数返回true的数据元。
<figure class="highlight"> ---
转换:**Filter** PythonDataStream→PythonDataStream
描述:计算每个数据元的布尔函数,并保存函数返回true的数据元。
``` ```
class GreaterThen1000(FilterFunction): class GreaterThen1000(FilterFunction):
...@@ -214,13 +216,14 @@ class GreaterThen1000(FilterFunction): ...@@ -214,13 +216,14 @@ class GreaterThen1000(FilterFunction):
data_stream.filter(GreaterThen1000()) data_stream.filter(GreaterThen1000())
``` ```
</figure>
|
| **KeyBy**
PythonDataStream→PythonKeyedStream | 逻辑上将流分区为不相交的分区,每个分区包含相同Keys的数据元。在内部,这是通过散列分区实现的。见[](/dev/api_concepts#specifying-keys)如何指定键。此转换返回PythonKeyedDataStream。
<figure class="highlight"> ---
转换:**KeyBy** PythonDataStream→PythonKeyedStream
描述:逻辑上将流分区为不相交的分区,每个分区包含相同Keys的数据元。在内部,这是通过散列分区实现的。见[键](/dev/api_concepts#specifying-keys)如何指定键。此转换返回PythonKeyedDataStream。
``` ```
class Selector(KeySelector): class Selector(KeySelector):
...@@ -230,13 +233,14 @@ class Selector(KeySelector): ...@@ -230,13 +233,14 @@ class Selector(KeySelector):
data_stream.key_by(Selector()) // Key by field "someKey" data_stream.key_by(Selector()) // Key by field "someKey"
``` ```
</figure>
|
| **Reduce**
PythonKeyedStream→PythonDataStream | 被Keys化数据流上的“滚动”Reduce。将当前数据元与最后一个Reduce的值组合并发出新值。
<figure class="highlight"> ---
转换:**Reduce** PythonKeyedStream→PythonDataStream
描述:被Keys化数据流上的“滚动”Reduce。将当前数据元与最后一个Reduce的值组合并发出新值。
``` ```
class Sum(ReduceFunction): class Sum(ReduceFunction):
...@@ -248,13 +252,14 @@ class Sum(ReduceFunction): ...@@ -248,13 +252,14 @@ class Sum(ReduceFunction):
data.reduce(Sum()) data.reduce(Sum())
``` ```
</figure>
|
| **Window**
PythonKeyedStream→PythonWindowedStream | 可以在已经分区的KeyedStream上定义Windows。Windows根据某些特征(例如,在最后5秒内到达的数据)对每个Keys中的数据进行分组。有关[窗口](windows.html)的完整说明,请参见windows。
<figure class="highlight"> ---
转换:**Window** PythonKeyedStream→PythonWindowedStream
描述:可以在已经分区的KeyedStream上定义Windows。Windows根据某些特征(例如,在最后5秒内到达的数据)对每个Keys中的数据进行分组。有关[窗口](windows.html)的完整说明,请参见windows。
``` ```
keyed_stream.count_window(10, 5) # Last 10 elements, sliding (jumping) by 5 elements keyed_stream.count_window(10, 5) # Last 10 elements, sliding (jumping) by 5 elements
...@@ -264,13 +269,14 @@ keyed_stream.time_window(milliseconds(30)) # Last 30 milliseconds of data ...@@ -264,13 +269,14 @@ keyed_stream.time_window(milliseconds(30)) # Last 30 milliseconds of data
keted_stream.time_window(milliseconds(100), milliseconds(20)) # Last 100 milliseconds of data, sliding (jumping) by 20 milliseconds keted_stream.time_window(milliseconds(100), milliseconds(20)) # Last 100 milliseconds of data, sliding (jumping) by 20 milliseconds
``` ```
</figure>
|
| **Window Apply**
PythonWindowedStream→PythonDataStream | 将一般函数应用于整个窗口。下面是一个手动求和窗口数据元的函数。
<figure class="highlight"> ---
转换:**Window Apply** PythonWindowedStream→PythonDataStream
描述:将一般函数应用于整个窗口。下面是一个手动求和窗口数据元的函数。
``` ```
class WindowSum(WindowFunction): class WindowSum(WindowFunction):
...@@ -283,13 +289,14 @@ class WindowSum(WindowFunction): ...@@ -283,13 +289,14 @@ class WindowSum(WindowFunction):
windowed_stream.apply(WindowSum()) windowed_stream.apply(WindowSum())
``` ```
</figure>
|
| **Window Reduce**
PythonWindowedStream→PythonDataStream | 将函数缩减函数应用于窗口并返回缩小的值。
<figure class="highlight"> ---
转换:**Window Reduce** PythonWindowedStream→PythonDataStream
描述:将函数缩减函数应用于窗口并返回缩小的值。
``` ```
class Sum(ReduceFunction): class Sum(ReduceFunction):
...@@ -301,25 +308,27 @@ class Sum(ReduceFunction): ...@@ -301,25 +308,27 @@ class Sum(ReduceFunction):
windowed_stream.reduce(Sum()) windowed_stream.reduce(Sum())
``` ```
</figure>
|
| **Union**
PythonDataStream *→PythonDataStream | 两个或多个数据流的联合,创建包含来自所有流的所有数据元的新流。注意:如果将数据流与自身联合,则会在结果流中获取两次数据元。
<figure class="highlight"> ---
转换:**Union** PythonDataStream *→PythonDataStream
描述:两个或多个数据流的联合,创建包含来自所有流的所有数据元的新流。注意:如果将数据流与自身联合,则会在结果流中获取两次数据元。
``` ```
data_stream.union(other_stream1, other_stream2, ...); data_stream.union(other_stream1, other_stream2, ...);
``` ```
</figure>
|
| **Split**
PythonDataStream→PythonSplitStream | 根据某些标准将流拆分为两个或更多个流。
<figure class="highlight"> ---
转换:**Split** PythonDataStream→PythonSplitStream
描述:根据某些标准将流拆分为两个或更多个流。
``` ```
class StreamSelector(OutputSelector): class StreamSelector(OutputSelector):
...@@ -329,13 +338,14 @@ class StreamSelector(OutputSelector): ...@@ -329,13 +338,14 @@ class StreamSelector(OutputSelector):
splited_stream = data_stream.split(StreamSelector()) splited_stream = data_stream.split(StreamSelector())
``` ```
</figure>
|
| **Select**
SplitStream→DataStream | 从拆分流中选择一个或多个流。
<figure class="highlight"> ---
转换:**Select** SplitStream→DataStream
描述:从拆分流中选择一个或多个流。
``` ```
even_data_stream = splited_stream.select("even") even_data_stream = splited_stream.select("even")
...@@ -343,13 +353,14 @@ odd_data_stream = splited_stream.select("odd") ...@@ -343,13 +353,14 @@ odd_data_stream = splited_stream.select("odd")
all_data_stream = splited_stream.select("even", "odd") all_data_stream = splited_stream.select("even", "odd")
``` ```
</figure>
|
| **Iterate**
PythonDataStream→PythonIterativeStream→PythonDataStream | 通过将一个 算子的输出重定向到某个先前的 算子,在流中创建“反馈”循环。这对于定义不断更新模型的算法特别有用。以下代码以流开头并连续应用迭代体。大于0的数据元将被发送回反馈通道,其余数据元将向下游转发。有关完整说明,请参阅[迭代](#iterations)
<figure class="highlight"> ---
转换:**Iterate** PythonDataStream→PythonIterativeStream→PythonDataStream
描述:通过将一个 算子的输出重定向到某个先前的 算子,在流中创建“反馈”循环。这对于定义不断更新模型的算法特别有用。以下代码以流开头并连续应用迭代体。大于0的数据元将被发送回反馈通道,其余数据元将向下游转发。有关完整说明,请参阅[迭代](#iterations)
``` ```
class MinusOne(MapFunction): class MinusOne(MapFunction):
...@@ -371,9 +382,8 @@ iteration.close_with(feedback) ...@@ -371,9 +382,8 @@ iteration.close_with(feedback)
output = iteration_body.filter(LessEquelToZero()) output = iteration_body.filter(LessEquelToZero())
``` ```
</figure>
|
## 将函数传递给Flink ## 将函数传递给Flink
......
此差异已折叠。
...@@ -17,24 +17,11 @@ Flink程序通过定义**步进函数**并将其嵌入到特殊的迭代 算子 ...@@ -17,24 +17,11 @@ Flink程序通过定义**步进函数**并将其嵌入到特殊的迭代 算子
| --- | --- | --- | | --- | --- | --- |
| **迭代输入** | **部分解决方案** | **工作集****解决方案集** | | **迭代输入** | **部分解决方案** | **工作集****解决方案集** |
| **步函数** | 任意数据流 | | **步函数** | 任意数据流 |
| **状态更新** | 下**一部分解决方案** | | **状态更新** | 下**一部分解决方案** | 下一个工作集 |
| | | **对解决方案集的更改** |
* 下一个工作集
* **对解决方案集的更改**
|
| **迭代结果** | 最后部分解决方案 | 上次迭代后的解决方案设置状态 | | **迭代结果** | 最后部分解决方案 | 上次迭代后的解决方案设置状态 |
| **终止** | | **终止** | **最大迭代次数**(默认) | **最大迭代次数或空工作集**(默认) |
| | 自定义聚合器收敛 | 自定义聚合器收敛 |
* **最大迭代次数**(默认)
* 自定义聚合器收敛
|
* **最大迭代次数或空工作集**(默认)
* 自定义聚合器收敛
|
## 迭代 算子 ## 迭代 算子
......
...@@ -123,69 +123,81 @@ Python API在安装了Python 2.7或3.4的Linux / Windows系统上进行了测试 ...@@ -123,69 +123,81 @@ Python API在安装了Python 2.7或3.4的Linux / Windows系统上进行了测试
本节简要概述了可用的转换。该[转换文档](dataset_transformations.html)与示例全部转换的完整描述。 本节简要概述了可用的转换。该[转换文档](dataset_transformations.html)与示例全部转换的完整描述。
</ tr> </ tr>
| 转型 | 描述 |
| --- | --- |
| **Map** | 采用一个数据元并生成一个数据元。
&lt;figure class="highlight"&gt;
---
转换:**Map**
描述:采用一个数据元并生成一个数据元。
``` ```
data.map(lambda x: x * 2) data.map(lambda x: x * 2)
``` ```
&lt;/figure&gt;
|
| **FlatMap** | 采用一个数据元并生成零个,一个或多个数据元。
&lt;figure class="highlight"&gt; ---
转换:**FlatMap**
描述:采用一个数据元并生成零个,一个或多个数据元。
``` ```
data.flat_map( data.flat_map(
lambda x,c: [(1,word) for word in line.lower().split() for line in x]) lambda x,c: [(1,word) for word in line.lower().split() for line in x])
``` ```
&lt;/figure&gt;
|
| **MapPartition** | 在单个函数调用中转换并行分区。该函数将分区作为“迭代器”,并可以生成任意数量的结果值。每个分区中的数据元数量取决于并行度和先前的 算子操作。
&lt;figure class="highlight"&gt; ---
转换:**MapPartition**
描述:在单个函数调用中转换并行分区。该函数将分区作为“迭代器”,并可以生成任意数量的结果值。每个分区中的数据元数量取决于并行度和先前的 算子操作。
``` ```
data.map_partition(lambda x,c: [value * 2 for value in x]) data.map_partition(lambda x,c: [value * 2 for value in x])
``` ```
&lt;/figure&gt;
|
| **Filter** | 计算每个数据元的布尔函数,并保存函数返回true的数据元。
&lt;figure class="highlight"&gt; ---
转换:**Filter**
描述:计算每个数据元的布尔函数,并保存函数返回true的数据元。
``` ```
data.filter(lambda x: x &gt; 1000) data.filter(lambda x: x &gt; 1000)
``` ```
&lt;/figure&gt;
|
| **Reduce** | 通过将两个数据元重复组合成一个数据元,将一组数据元组合成一个数据元。Reduce可以应用于完整数据集或分组数据集。
&lt;figure class="highlight"&gt; ---
转换:**Reduce**
描述:通过将两个数据元重复组合成一个数据元,将一组数据元组合成一个数据元。Reduce可以应用于完整数据集或分组数据集。
``` ```
data.reduce(lambda x,y : x + y) data.reduce(lambda x,y : x + y)
``` ```
&lt;/figure&gt;
|
| **ReduceGroup** | 将一组数据元组合成一个或多个数据元。ReduceGroup可以应用于完整数据集或分组数据集。
&lt;figure class="highlight"&gt; ---
转换:**ReduceGroup**
描述:将一组数据元组合成一个或多个数据元。ReduceGroup可以应用于完整数据集或分组数据集。
``` ```
class Adder(GroupReduceFunction): class Adder(GroupReduceFunction):
...@@ -197,12 +209,14 @@ class Adder(GroupReduceFunction): ...@@ -197,12 +209,14 @@ class Adder(GroupReduceFunction):
data.reduce_group(Adder()) data.reduce_group(Adder())
``` ```
&lt;/figure&gt;
|
| **骨料** | 在数据集或数据集的每个组中的所有元组的一个字段上执行内置 算子操作(sum,min,max)。聚合可以应用于完整数据集或分组数据集。
&lt;figure class="highlight"&gt; ---
转换:**骨料**
描述:在数据集或数据集的每个组中的所有元组的一个字段上执行内置 算子操作(sum,min,max)。聚合可以应用于完整数据集或分组数据集。
``` ```
# This code finds the sum of all of the values in the first field and the maximum of all of the values in the second field # This code finds the sum of all of the values in the first field and the maximum of all of the values in the second field
...@@ -218,12 +232,14 @@ data.aggregate(Aggregation.Sum, 0).and_agg(Aggregation.Max, 1) ...@@ -218,12 +232,14 @@ data.aggregate(Aggregation.Sum, 0).and_agg(Aggregation.Max, 1)
data.sum(0).and_agg(Aggregation.Max, 1) data.sum(0).and_agg(Aggregation.Max, 1)
``` ```
&lt;/figure&gt;
|
| **Join** | 通过创建在其键上相等的所有数据元对来连接两个数据集。(可选)使用JoinFunction将数据元对转换为单个数据元。见[](#specifying-keys)如何定义连接Keys。
&lt;figure class="highlight"&gt; ---
转换:**Join**
描述:通过创建在其键上相等的所有数据元对来连接两个数据集。(可选)使用JoinFunction将数据元对转换为单个数据元。见[](#specifying-keys)如何定义连接Keys。
``` ```
# In this case tuple fields are used as keys. # In this case tuple fields are used as keys.
...@@ -241,53 +257,60 @@ data.sum(0).and_agg(Aggregation.Max, 1) ...@@ -241,53 +257,60 @@ data.sum(0).and_agg(Aggregation.Max, 1)
result = input1.join(input2).where(0).equal_to(1) result = input1.join(input2).where(0).equal_to(1)
``` ```
&lt;/figure&gt;
|
| **CoGroup** | reduce 算子操作的二维变体。将一个或多个字段上的每个输入分组,然后关联组。每对组调用转换函数。见[](#specifying-keys)如何定义CoGroup键。
&lt;figure class="highlight"&gt; ---
转换:**CoGroup**
描述:reduce 算子操作的二维变体。将一个或多个字段上的每个输入分组,然后关联组。每对组调用转换函数。见[键](#specifying-keys)如何定义CoGroup键。
``` ```
data1.co_group(data2).where(0).equal_to(1) data1.co_group(data2).where(0).equal_to(1)
``` ```
&lt;/figure&gt;
|
| **交叉** | 构建两个输入的笛卡尔积(交叉乘积),创建所有数据元对。可选择使用CrossFunction将数据元对转换为单个数据元。
&lt;figure class="highlight"&gt; ---
转换:**交叉**
描述:构建两个输入的笛卡尔积(交叉乘积),创建所有数据元对。可选择使用CrossFunction将数据元对转换为单个数据元。
``` ```
result = data1.cross(data2) result = data1.cross(data2)
``` ```
&lt;/figure&gt;
|
| **Union** | 生成两个数据集的并集。
&lt;figure class="highlight"&gt; ---
转换:**Union**
描述:生成两个数据集的并集。
``` ```
data.union(data2) data.union(data2)
``` ```
&lt;/figure&gt;
|
| **ZipWithIndex** | 为每个数据元分配连续索引。有关详细信息,请参阅[Zip数据元指南](zip_elements_guide.html#zip-with-a-dense-index)。
&lt;figure class="highlight"&gt; ---
转换:**ZipWithIndex**
描述:为每个数据元分配连续索引。有关详细信息,请参阅[Zip数据元指南](zip_elements_guide.html#zip-with-a-dense-index)。
``` ```
data.zip_with_index() data.zip_with_index()
``` ```
&lt;/figure&gt;
|
## 指定Keys ## 指定Keys
......
此差异已折叠。
...@@ -190,7 +190,6 @@ Flink SQL对类似于Java标识符(表,属性,函数名)使用词法策 ...@@ -190,7 +190,6 @@ Flink SQL对类似于Java标识符(表,属性,函数名)使用词法策
| **Scan/Select/As** | **Scan/Select/As**
批量 流 | 批量 流 |
&lt;figure class="highlight"&gt;
``` ```
SELECT * FROM Orders SELECT * FROM Orders
...@@ -198,13 +197,11 @@ SELECT * FROM Orders ...@@ -198,13 +197,11 @@ SELECT * FROM Orders
SELECT a, c AS d FROM Orders SELECT a, c AS d FROM Orders
``` ```
&lt;/figure&gt;
| |
| **Where / Filter** | **Where / Filter**
Batch Streaming | Batch Streaming |
&lt;figure class="highlight"&gt;
``` ```
SELECT * FROM Orders WHERE b = 'red' SELECT * FROM Orders WHERE b = 'red'
...@@ -212,19 +209,16 @@ SELECT * FROM Orders WHERE b = 'red' ...@@ -212,19 +209,16 @@ SELECT * FROM Orders WHERE b = 'red'
SELECT * FROM Orders WHERE a % 2 = 0 SELECT * FROM Orders WHERE a % 2 = 0
``` ```
&lt;/figure&gt;
| |
| **User-defined Scalar Functions (Scalar UDF)** | **User-defined Scalar Functions (Scalar UDF)**
批量 流 | UDF必须在TableEnvironment中注册。有关如何指定和注册标量UDF的详细信息,请参阅[UDF文档](udfs.html) 批量 流 | UDF必须在TableEnvironment中注册。有关如何指定和注册标量UDF的详细信息,请参阅[UDF文档](udfs.html)
&lt;figure class="highlight"&gt;
``` ```
SELECT PRETTY_PRINT(user) FROM Orders SELECT PRETTY_PRINT(user) FROM Orders
``` ```
&lt;/figure&gt;
| |
...@@ -236,7 +230,6 @@ SELECT PRETTY_PRINT(user) FROM Orders ...@@ -236,7 +230,6 @@ SELECT PRETTY_PRINT(user) FROM Orders
批处理 流 批处理 流
结果更新 | **注意:**流表上的GroupBy会生成更新结果。有关详细信息,请参阅[Streaming Concepts](streaming.html)页面。 结果更新 | **注意:**流表上的GroupBy会生成更新结果。有关详细信息,请参阅[Streaming Concepts](streaming.html)页面。
&lt;figure class="highlight"&gt;
``` ```
SELECT a, SUM(b) as d SELECT a, SUM(b) as d
...@@ -244,13 +237,11 @@ FROM Orders ...@@ -244,13 +237,11 @@ FROM Orders
GROUP BY a GROUP BY a
``` ```
&lt;/figure&gt;
| |
| **GroupBy窗口聚合** | **GroupBy窗口聚合**
批量 流 | 使用组窗口计算每个组的单个结果行。有关详细信息,请参阅[GroupWindows](#group-windows)部分。 批量 流 | 使用组窗口计算每个组的单个结果行。有关详细信息,请参阅[GroupWindows](#group-windows)部分。
&lt;figure class="highlight"&gt;
``` ```
SELECT user, SUM(amount) SELECT user, SUM(amount)
...@@ -258,13 +249,11 @@ FROM Orders ...@@ -258,13 +249,11 @@ FROM Orders
GROUP BY TUMBLE(rowtime, INTERVAL '1' DAY), user GROUP BY TUMBLE(rowtime, INTERVAL '1' DAY), user
``` ```
&lt;/figure&gt;
| |
| **Over Window聚合** | **Over Window聚合**
流 | **注意:**必须在同一窗口中定义所有聚合,即相同的分区,排序和范围。目前,仅支持具有PRREDING(UNBOUNDED和有界)到CURRENT ROW范围的窗口。尚不支持使用FOLLOWING的范围。必须在单个[时间属性](streaming.html#time-attributes)上指定ORDER BY[](streaming.html#time-attributes) 流 | **注意:**必须在同一窗口中定义所有聚合,即相同的分区,排序和范围。目前,仅支持具有PRREDING(UNBOUNDED和有界)到CURRENT ROW范围的窗口。尚不支持使用FOLLOWING的范围。必须在单个[时间属性](streaming.html#time-attributes)上指定ORDER BY[](streaming.html#time-attributes)
&lt;figure class="highlight"&gt;
``` ```
SELECT COUNT(amount) OVER ( SELECT COUNT(amount) OVER (
...@@ -281,26 +270,22 @@ WINDOW w AS ( ...@@ -281,26 +270,22 @@ WINDOW w AS (
ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) ROWS BETWEEN 2 PRECEDING AND CURRENT ROW)
``` ```
&lt;/figure&gt;
| |
| **Distinct** | **Distinct**
批量 流 批量 流
结果更新 | 结果更新 |
&lt;figure class="highlight"&gt;
``` ```
SELECT DISTINCT users FROM Orders SELECT DISTINCT users FROM Orders
``` ```
&lt;/figure&gt;
**注意:**对于流式查询,计算查询结果所需的状态可能会无限增长,具体取决于不同字段的数量。请提供具有有效保存间隔的查询配置,以防止过大的状态。有关详细信息,请参阅[Streaming Concepts](streaming.html)。 | **注意:**对于流式查询,计算查询结果所需的状态可能会无限增长,具体取决于不同字段的数量。请提供具有有效保存间隔的查询配置,以防止过大的状态。有关详细信息,请参阅[Streaming Concepts](streaming.html)。 |
| **分组集,汇总,多维数据集** | **分组集,汇总,多维数据集**
批量 | 批量 |
&lt;figure class="highlight"&gt;
``` ```
SELECT SUM(amount) SELECT SUM(amount)
...@@ -308,13 +293,11 @@ FROM Orders ...@@ -308,13 +293,11 @@ FROM Orders
GROUP BY GROUPING SETS ((user), (product)) GROUP BY GROUPING SETS ((user), (product))
``` ```
&lt;/figure&gt;
| |
| **Having** | **Having**
批量 流 | 批量 流 |
&lt;figure class="highlight"&gt;
``` ```
SELECT SUM(amount) SELECT SUM(amount)
...@@ -323,13 +306,11 @@ GROUP BY users ...@@ -323,13 +306,11 @@ GROUP BY users
HAVING SUM(amount) &gt; 50 HAVING SUM(amount) &gt; 50
``` ```
&lt;/figure&gt;
| |
| **用户定义的聚合函数(UDAGG)** | **用户定义的聚合函数(UDAGG)**
批量 流 | UDAGG必须在TableEnvironment中注册。有关如何指定和注册UDAGG的详细信息,请参阅[UDF文档](udfs.html) 批量 流 | UDAGG必须在TableEnvironment中注册。有关如何指定和注册UDAGG的详细信息,请参阅[UDF文档](udfs.html)
&lt;figure class="highlight"&gt;
``` ```
SELECT MyAggregate(amount) SELECT MyAggregate(amount)
...@@ -337,7 +318,6 @@ FROM Orders ...@@ -337,7 +318,6 @@ FROM Orders
GROUP BY users GROUP BY users
``` ```
&lt;/figure&gt;
| |
...@@ -348,20 +328,17 @@ GROUP BY users ...@@ -348,20 +328,17 @@ GROUP BY users
| **内部Equi-join** | **内部Equi-join**
批量 流 | 目前,仅支持等连接,即具有至少一个带有等式谓词的连接条件的连接。不支持任意交叉或theta连接。**注意:**连接顺序未优化。表按照FROM子句中指定的顺序连接。确保以不产生交叉连接(笛卡尔积)的顺序指定表,这些表不受支持并且会导致查询失败。 批量 流 | 目前,仅支持等连接,即具有至少一个带有等式谓词的连接条件的连接。不支持任意交叉或theta连接。**注意:**连接顺序未优化。表按照FROM子句中指定的顺序连接。确保以不产生交叉连接(笛卡尔积)的顺序指定表,这些表不受支持并且会导致查询失败。
&lt;figure class="highlight"&gt;
``` ```
SELECT * SELECT *
FROM Orders INNER JOIN Product ON Orders.productId = Product.id FROM Orders INNER JOIN Product ON Orders.productId = Product.id
``` ```
&lt;/figure&gt;
**注意:**对于流式查询,计算查询结果所需的状态可能会无限增长,具体取决于不同输入行的数量。请提供具有有效保存间隔的查询配置,以防止过大的状态。有关详细信息,请参阅[Streaming Concepts](streaming.html)。 | **注意:**对于流式查询,计算查询结果所需的状态可能会无限增长,具体取决于不同输入行的数量。请提供具有有效保存间隔的查询配置,以防止过大的状态。有关详细信息,请参阅[Streaming Concepts](streaming.html)。 |
| **外部Equi-join** | **外部Equi-join**
批量 流 结果更新 | 目前,仅支持等连接,即具有至少一个带有等式谓词的连接条件的连接。不支持任意交叉或theta连接。**注意:**连接顺序未优化。表按照FROM子句中指定的顺序连接。确保以不产生交叉连接(笛卡尔积)的顺序指定表,这些表不受支持并且会导致查询失败。 批量 流 结果更新 | 目前,仅支持等连接,即具有至少一个带有等式谓词的连接条件的连接。不支持任意交叉或theta连接。**注意:**连接顺序未优化。表按照FROM子句中指定的顺序连接。确保以不产生交叉连接(笛卡尔积)的顺序指定表,这些表不受支持并且会导致查询失败。
&lt;figure class="highlight"&gt;
``` ```
SELECT * SELECT *
...@@ -374,7 +351,6 @@ SELECT * ...@@ -374,7 +351,6 @@ SELECT *
FROM Orders FULL OUTER JOIN Product ON Orders.productId = Product.id FROM Orders FULL OUTER JOIN Product ON Orders.productId = Product.id
``` ```
&lt;/figure&gt;
**注意:**对于流式查询,计算查询结果所需的状态可能会无限增长,具体取决于不同输入行的数量。请提供具有有效保存间隔的查询配置,以防止过大的状态。有关详细信息,请参阅[Streaming Concepts](streaming.html)。 | **注意:**对于流式查询,计算查询结果所需的状态可能会无限增长,具体取决于不同输入行的数量。请提供具有有效保存间隔的查询配置,以防止过大的状态。有关详细信息,请参阅[Streaming Concepts](streaming.html)。 |
| **Time-windowed Join** | **Time-windowed Join**
...@@ -384,7 +360,6 @@ FROM Orders FULL OUTER JOIN Product ON Orders.productId = Product.id ...@@ -384,7 +360,6 @@ FROM Orders FULL OUTER JOIN Product ON Orders.productId = Product.id
* `ltime &gt;= rtime AND ltime &lt; rtime + INTERVAL '10' MINUTE` * `ltime &gt;= rtime AND ltime &lt; rtime + INTERVAL '10' MINUTE`
* `ltime BETWEEN rtime - INTERVAL '10' SECOND AND rtime + INTERVAL '5' SECOND` * `ltime BETWEEN rtime - INTERVAL '10' SECOND AND rtime + INTERVAL '5' SECOND`
&lt;figure class="highlight"&gt;
``` ```
SELECT * SELECT *
...@@ -393,44 +368,37 @@ WHERE o.id = s.orderId AND ...@@ -393,44 +368,37 @@ WHERE o.id = s.orderId AND
o.ordertime BETWEEN s.shiptime - INTERVAL '4' HOUR AND s.shiptime o.ordertime BETWEEN s.shiptime - INTERVAL '4' HOUR AND s.shiptime
``` ```
&lt;/figure&gt;
如果订单在收到订单后四小时发货,上面的示例将关联所有订单及其相应的货件。 | 如果订单在收到订单后四小时发货,上面的示例将关联所有订单及其相应的货件。 |
| **将数组扩展为关系** | **将数组扩展为关系**
Batch Streaming | 尚未支持UnANDing WITH ORDINALITY。 Batch Streaming | 尚未支持UnANDing WITH ORDINALITY。
&lt;figure class="highlight"&gt;
``` ```
SELECT users, tag SELECT users, tag
FROM Orders CROSS JOIN UNNEST(tags) AS t (tag) FROM Orders CROSS JOIN UNNEST(tags) AS t (tag)
``` ```
&lt;/figure&gt;
| |
| **关联用户定义的表函数(UDTF)** | **关联用户定义的表函数(UDTF)**
批量 流 | UDTF必须在TableEnvironment中注册。有关如何指定和注册UDTF的详细信息,请参阅[UDF文档](udfs.html)。内部联接 批量 流 | UDTF必须在TableEnvironment中注册。有关如何指定和注册UDTF的详细信息,请参阅[UDF文档](udfs.html)。内部联接
&lt;figure class="highlight"&gt;
``` ```
SELECT users, tag SELECT users, tag
FROM Orders, LATERAL TABLE(unnest_udtf(tags)) t AS tag FROM Orders, LATERAL TABLE(unnest_udtf(tags)) t AS tag
``` ```
&lt;/figure&gt;
左外连接 左外连接
&lt;figure class="highlight"&gt;
``` ```
SELECT users, tag SELECT users, tag
FROM Orders LEFT JOIN LATERAL TABLE(unnest_udtf(tags)) t AS tag ON TRUE FROM Orders LEFT JOIN LATERAL TABLE(unnest_udtf(tags)) t AS tag ON TRUE
``` ```
&lt;/figure&gt;
**注意:**目前,`TRUE`对于横向表,只支持左外连接的谓词作为谓词。 | **注意:**目前,`TRUE`对于横向表,只支持左外连接的谓词作为谓词。 |
...@@ -441,7 +409,6 @@ FROM Orders LEFT JOIN LATERAL TABLE(unnest_udtf(tags)) t AS tag ON TRUE ...@@ -441,7 +409,6 @@ FROM Orders LEFT JOIN LATERAL TABLE(unnest_udtf(tags)) t AS tag ON TRUE
| **Union** | **Union**
批次 | 批次 |
&lt;figure class="highlight"&gt;
``` ```
SELECT * SELECT *
...@@ -452,13 +419,11 @@ FROM ( ...@@ -452,13 +419,11 @@ FROM (
) )
``` ```
&lt;/figure&gt;
| |
| **UnionAll** | **UnionAll**
Batch Streaming | Batch Streaming |
&lt;figure class="highlight"&gt;
``` ```
SELECT * SELECT *
...@@ -469,13 +434,11 @@ FROM ( ...@@ -469,13 +434,11 @@ FROM (
) )
``` ```
&lt;/figure&gt;
| |
| **Intersect/ Except**批量 | **Intersect/ Except**批量
| |
&lt;figure class="highlight"&gt;
``` ```
SELECT * SELECT *
...@@ -486,9 +449,7 @@ FROM ( ...@@ -486,9 +449,7 @@ FROM (
) )
``` ```
&lt;/figure&gt;
&lt;figure class="highlight"&gt;
``` ```
SELECT * SELECT *
...@@ -499,13 +460,11 @@ FROM ( ...@@ -499,13 +460,11 @@ FROM (
) )
``` ```
&lt;/figure&gt;
| |
| **IN** | **IN**
批量 流中 | 如果表达式存在于给定的表子查询中,则返回true。子查询表必须包含一列。此列必须与表达式具有相同的数据类型。 批量 流中 | 如果表达式存在于给定的表子查询中,则返回true。子查询表必须包含一列。此列必须与表达式具有相同的数据类型。
&lt;figure class="highlight"&gt;
``` ```
SELECT user, amount SELECT user, amount
...@@ -515,13 +474,11 @@ WHERE product IN ( ...@@ -515,13 +474,11 @@ WHERE product IN (
) )
``` ```
&lt;/figure&gt;
**注意:**对于流式查询, 算子操作将在连接和组 算子操作中重写。计算查询结果所需的状态可能会无限增长,具体取决于不同输入行的数量。请提供具有有效保存间隔的查询配置,以防止过大的状态。有关详细信息,请参阅[Streaming Concepts](streaming.html)。 | **注意:**对于流式查询, 算子操作将在连接和组 算子操作中重写。计算查询结果所需的状态可能会无限增长,具体取决于不同输入行的数量。请提供具有有效保存间隔的查询配置,以防止过大的状态。有关详细信息,请参阅[Streaming Concepts](streaming.html)。 |
| **Exists** | **Exists**
批量 流 | 如果子查询至少返回一行,则返回true。仅在可以在连接和组 算子操作中重写 算子操作时才支持。 批量 流 | 如果子查询至少返回一行,则返回true。仅在可以在连接和组 算子操作中重写 算子操作时才支持。
&lt;figure class="highlight"&gt;
``` ```
SELECT user, amount SELECT user, amount
...@@ -531,7 +488,6 @@ WHERE product EXISTS ( ...@@ -531,7 +488,6 @@ WHERE product EXISTS (
) )
``` ```
&lt;/figure&gt;
**注意:**对于流式查询, 算子操作将在连接和组 算子操作中重写。计算查询结果所需的状态可能会无限增长,具体取决于不同输入行的数量。请提供具有有效保存间隔的查询配置,以防止过大的状态。有关详细信息,请参阅[Streaming Concepts](streaming.html)。 | **注意:**对于流式查询, 算子操作将在连接和组 算子操作中重写。计算查询结果所需的状态可能会无限增长,具体取决于不同输入行的数量。请提供具有有效保存间隔的查询配置,以防止过大的状态。有关详细信息,请参阅[Streaming Concepts](streaming.html)。 |
...@@ -542,7 +498,6 @@ WHERE product EXISTS ( ...@@ -542,7 +498,6 @@ WHERE product EXISTS (
| **Order By** | **Order By**
批量 流 | **注意:**流式查询的结果必须主要按升序[时间属性](streaming.html#time-attributes)排序。支持其他排序属性。 批量 流 | **注意:**流式查询的结果必须主要按升序[时间属性](streaming.html#time-attributes)排序。支持其他排序属性。
&lt;figure class="highlight"&gt;
``` ```
SELECT * SELECT *
...@@ -550,13 +505,11 @@ FROM Orders ...@@ -550,13 +505,11 @@ FROM Orders
ORDER BY orderTime ORDER BY orderTime
``` ```
&lt;/figure&gt;
| |
| **Limit** | **Limit**
批次 | 批次 |
&lt;figure class="highlight"&gt;
``` ```
SELECT * SELECT *
...@@ -564,7 +517,6 @@ FROM Orders ...@@ -564,7 +517,6 @@ FROM Orders
LIMIT 3 LIMIT 3
``` ```
&lt;/figure&gt;
| |
...@@ -575,7 +527,6 @@ LIMIT 3 ...@@ -575,7 +527,6 @@ LIMIT 3
| **Insert** | **Insert**
批量 流处理 | 输出表必须在TableEnvironment中[注册](common.html#register-a-tablesink)(请参阅[注册TableSink](common.html#register-a-tablesink))。此外,已注册表的模式必须与查询的模式匹配。 批量 流处理 | 输出表必须在TableEnvironment中[注册](common.html#register-a-tablesink)(请参阅[注册TableSink](common.html#register-a-tablesink))。此外,已注册表的模式必须与查询的模式匹配。
&lt;figure class="highlight"&gt;
``` ```
INSERT INTO OutputTable INSERT INTO OutputTable
...@@ -583,7 +534,6 @@ SELECT users, tag ...@@ -583,7 +534,6 @@ SELECT users, tag
FROM Orders FROM Orders
``` ```
&lt;/figure&gt;
| |
......
...@@ -376,11 +376,13 @@ pattern.where(event => ... /* some condition */).or(event => ... /* or condition ...@@ -376,11 +376,13 @@ pattern.where(event => ... /* some condition */).or(event => ... /* or condition
* [**Java**](#tab_java_7) * [**Java**](#tab_java_7)
* [**Scala**](#tab_scala_7) * [**Scala**](#tab_scala_7)
| 模式 算子操作 | 描述 |
| --- | --- |
| **其中(条件)** | 定义当前模式的条件。要匹配模式,事件必须满足条件。多个连续的where()子句导致其条件为AND:
&lt;figure class="highlight"&gt; ---
模式算子操作:`where(condition)`
描述:定义当前模式的条件。要匹配模式,事件必须满足条件。多个连续的where()子句导致其条件为AND:
``` ```
pattern.where(new IterativeCondition&lt;Event&gt;() { pattern.where(new IterativeCondition&lt;Event&gt;() {
...@@ -391,12 +393,14 @@ pattern.where(new IterativeCondition&lt;Event&gt;() { ...@@ -391,12 +393,14 @@ pattern.where(new IterativeCondition&lt;Event&gt;() {
}); });
``` ```
&lt;/figure&gt;
|
| **或(条件)** | 添加与现有条件进行OR运算的新条件。只有在至少通过其中一个条件时,事件才能匹配该模式:
&lt;figure class="highlight"&gt; ---
模式算子操作:`or(condition)`
描述:添加与现有条件进行OR运算的新条件。只有在至少通过其中一个条件时,事件才能匹配该模式:
``` ```
pattern.where(new IterativeCondition&lt;Event&gt;() { pattern.where(new IterativeCondition&lt;Event&gt;() {
...@@ -412,12 +416,14 @@ pattern.where(new IterativeCondition&lt;Event&gt;() { ...@@ -412,12 +416,14 @@ pattern.where(new IterativeCondition&lt;Event&gt;() {
}); });
``` ```
&lt;/figure&gt;
|
| **直到(条件)** | 指定循环模式的停止条件。意味着如果匹配给定条件的事件发生,则不再接受该模式中的事件。仅适用于 `oneOrMore()`**注意:**它允许在基于事件的条件下清除相应模式的状态。
&lt;figure class="highlight"&gt; ---
模式算子操作:`until(condition)`
描述:指定循环模式的停止条件。意味着如果匹配给定条件的事件发生,则不再接受该模式中的事件。仅适用于 `oneOrMore()`**注意:**它允许在基于事件的条件下清除相应模式的状态。
``` ```
pattern.oneOrMore().until(new IterativeCondition&lt;Event&gt;() { pattern.oneOrMore().until(new IterativeCondition&lt;Event&gt;() {
...@@ -428,201 +434,97 @@ pattern.oneOrMore().until(new IterativeCondition&lt;Event&gt;() { ...@@ -428,201 +434,97 @@ pattern.oneOrMore().until(new IterativeCondition&lt;Event&gt;() {
}); });
``` ```
&lt;/figure&gt;
|
| **亚型(子类)** | 定义当前模式的子类型条件。如果事件属于此子类型,则事件只能匹配该模式:
&lt;figure class="highlight"&gt; ---
``` 模式算子操作:`subtype(subClass)`
pattern.subtype(SubEvent.class);
```
&lt;/figure&gt; 描述:定义当前模式的子类型条件。如果事件属于此子类型,则事件只能匹配该模式:
|
| **一个或多个()** | 指定此模式至少发生一次匹配事件。默认情况下,使用宽松的内部连续性(在后续事件之间)。有关内部连续性的更多信息,请参阅[连续](#consecutive_java)**注意:**建议使用`until()``within()`启用状态清除
&lt;figure class="highlight"&gt;
```
pattern.oneOrMore();
``` ```
pattern.subtype(SubEvent.class);
&lt;/figure&gt;
|
| **timesOrMore(#times)** | 指定此模式至少需要**#times**出现匹配事件。默认情况下,使用宽松的内部连续性(在后续事件之间)。有关内部连续性的更多信息,请参阅[连续](#consecutive_java)
&lt;figure class="highlight"&gt;
```
pattern.timesOrMore(2);
```
&lt;/figure&gt;
|
| **次(#ofTimes)** | 指定此模式需要匹配事件的确切出现次数。默认情况下,使用宽松的内部连续性(在后续事件之间)。有关内部连续性的更多信息,请参阅[连续](#consecutive_java)
&lt;figure class="highlight"&gt;
```
pattern.times(2);
``` ```
&lt;/figure&gt;
|
| **次(#fromTimes,#toTimes)** | 指定此模式期望在匹配事件的**#fromTimes****#toTimes**之间出现。默认情况下,使用宽松的内部连续性(在后续事件之间)。有关内部连续性的更多信息,请参阅[连续](#consecutive_java)
&lt;figure class="highlight"&gt; ---
``` 模式算子操作:`oneOrMore()`
pattern.times(2, 4);
```
&lt;/figure&gt;
| 描述:指定此模式至少发生一次匹配事件。默认情况下,使用宽松的内部连续性(在后续事件之间)。有关内部连续性的更多信息,请参阅[连续](#consecutive_java)。**注意:**建议使用`until()`或`within()`启用状态清除
| **Optional()** | 指定此模式是可选的,即根本不会发生。这适用于所有上述量词。
&lt;figure class="highlight"&gt;
``` ```
pattern.oneOrMore().optional(); pattern.oneOrMore();
```
&lt;/figure&gt;
|
| **贪婪()** | 指定此模式是贪婪的,即它将尽可能多地重复。这仅适用于量词,目前不支持组模式。
&lt;figure class="highlight"&gt;
```
pattern.oneOrMore().greedy();
``` ```
&lt;/figure&gt;
|
| Pattern Operation | Description |
| --- | --- |
| **where(condition)** | Defines a condition for the current pattern. To match the pattern, an event must satisfy the condition. Multiple consecutive where() clauses lead to their conditions being ANDed:
&lt;figure class="highlight"&gt;
``` ---
pattern.where(event =&gt; ... /* some condition */)
```
&lt;/figure&gt; 模式算子操作:`timesOrMore(#times)`
| 描述:指定此模式至少需要**#times**出现匹配事件。默认情况下,使用宽松的内部连续性(在后续事件之间)。有关内部连续性的更多信息,请参阅[连续](#consecutive_java)
| **or(condition)** | Adds a new condition which is ORed with an existing one. An event can match the pattern only if it passes at least one of the conditions:
&lt;figure class="highlight"&gt;
``` ```
pattern.where(event =&gt; ... /* some condition */) pattern.timesOrMore(2);
.or(event =&gt; ... /* alternative condition */)
``` ```
&lt;/figure&gt;
|
| **until(condition)** | Specifies a stop condition for looping pattern. Meaning if event matching the given condition occurs, no more events will be accepted into the pattern.Applicable only in conjunction with `oneOrMore()`**NOTE:** It allows for cleaning state for corresponding pattern on event-based condition.
&lt;figure class="highlight"&gt; ---
``` 模式算子操作:`次(#ofTimes)`
pattern.oneOrMore().until(event =&gt; ... /* some condition */)
```
&lt;/figure&gt; 描述:指定此模式需要匹配事件的确切出现次数。默认情况下,使用宽松的内部连续性(在后续事件之间)。有关内部连续性的更多信息,请参阅[连续](#consecutive_java)。
|
| **subtype(subClass)** | Defines a subtype condition for the current pattern. An event can only match the pattern if it is of this subtype:
&lt;figure class="highlight"&gt;
``` ```
pattern.subtype(classOf[SubEvent]) pattern.times(2);
``` ```
&lt;/figure&gt;
|
| **oneOrMore()** | Specifies that this pattern expects at least one occurrence of a matching event.By default a relaxed internal contiguity (between subsequent events) is used. For more info on internal contiguity see [consecutive](#consecutive_scala).**NOTE:** It is advised to use either `until()` or `within()` to enable state clearing
&lt;figure class="highlight"&gt;
``` ---
pattern.oneOrMore()
```
&lt;/figure&gt; 模式算子操作:`times(#fromTimes,#toTimes)`
| 描述:指定此模式期望在匹配事件的**#fromTimes****#toTimes**之间出现。默认情况下,使用宽松的内部连续性(在后续事件之间)。有关内部连续性的更多信息,请参阅[连续](#consecutive_java)
| **timesOrMore(#times)** | Specifies that this pattern expects at least **#times** occurrences of a matching event.By default a relaxed internal contiguity (between subsequent events) is used. For more info on internal contiguity see [consecutive](#consecutive_scala).
&lt;figure class="highlight"&gt;
``` ```
pattern.timesOrMore(2) pattern.times(2, 4);
``` ```
&lt;/figure&gt;
|
| **times(#ofTimes)** | Specifies that this pattern expects an exact number of occurrences of a matching event.By default a relaxed internal contiguity (between subsequent events) is used. For more info on internal contiguity see [consecutive](#consecutive_scala).
&lt;figure class="highlight"&gt;
``` ---
pattern.times(2)
```
&lt;/figure&gt; 模式算子操作:`Optional()`
| 描述:指定此模式是可选的,即根本不会发生。这适用于所有上述量词。
| **times(#fromTimes, #toTimes)** | Specifies that this pattern expects occurrences between **#fromTimes** and **#toTimes** of a matching event.By default a relaxed internal contiguity (between subsequent events) is used. For more info on internal contiguity see [consecutive](#consecutive_java).
&lt;figure class="highlight"&gt;
``` ```
pattern.times(2, 4) pattern.oneOrMore().optional();
``` ```
&lt;/figure&gt;
|
| **optional()** | Specifies that this pattern is optional, i.e. it may not occur at all. This is applicable to all aforementioned quantifiers.
&lt;figure class="highlight"&gt; ---
``` 模式算子操作:`greedy()`
pattern.oneOrMore().optional()
```
&lt;/figure&gt; 描述:指定此模式是贪婪的,即它将尽可能多地重复。这仅适用于量词,目前不支持组模式。
|
| **greedy()** | Specifies that this pattern is greedy, i.e. it will repeat as many as possible. This is only applicable to quantifiers and it does not support group pattern currently.
&lt;figure class="highlight"&gt;
``` ```
pattern.oneOrMore().greedy() pattern.oneOrMore().greedy();
``` ```
&lt;/figure&gt;
|
### 结合模式 ### 结合模式
现在你已经看到了单个模式的样子,现在是时候看看如何将它们组合成一个完整的模式序列。 现在你已经看到了单个模式的样子,现在是时候看看如何将它们组合成一个完整的模式序列。
...@@ -761,7 +663,6 @@ next.within(Time.seconds(10)) ...@@ -761,7 +663,6 @@ next.within(Time.seconds(10))
| --- | --- | | --- | --- |
| **连续的()** | 与匹配事件一起使用`oneOrMore()``times()`强制执行严格的连续性,即任何不匹配的数据元都会中断匹配(如`next()`)。如果不应用,则使用放松的连续性(如`followedBy()`)。例如: | **连续的()** | 与匹配事件一起使用`oneOrMore()``times()`强制执行严格的连续性,即任何不匹配的数据元都会中断匹配(如`next()`)。如果不应用,则使用放松的连续性(如`followedBy()`)。例如:
&lt;figure class="highlight"&gt;
``` ```
Pattern.&lt;Event&gt;begin("start").where(new SimpleCondition&lt;Event&gt;() { Pattern.&lt;Event&gt;begin("start").where(new SimpleCondition&lt;Event&gt;() {
...@@ -784,12 +685,10 @@ Pattern.&lt;Event&gt;begin("start").where(new SimpleCondition&lt;Event&gt;() { ...@@ -784,12 +685,10 @@ Pattern.&lt;Event&gt;begin("start").where(new SimpleCondition&lt;Event&gt;() {
}); });
``` ```
&lt;/figure&gt;
将为输入序列生成以下匹配项:CD A1 A2 A3 D A4 B.连续申请:{C A1 B},{C A1 A2 B},{C A1 A2 A3 B}没有连续申请:{C A1 B},{C A1 A2 B},{C A1 A2 A3 B},{C A1 A2 A3 A4 B} | 将为输入序列生成以下匹配项:CD A1 A2 A3 D A4 B.连续申请:{C A1 B},{C A1 A2 B},{C A1 A2 A3 B}没有连续申请:{C A1 B},{C A1 A2 B},{C A1 A2 A3 B},{C A1 A2 A3 A4 B} |
| **allowCombinations()** | 与匹配事件一起使用`oneOrMore()`并且`times()`在匹配事件之间施加非确定性松弛连续性(如`followedByAny()`)。如果不应用,则使用放松的连续性(如`followedBy()`)。例如: | **allowCombinations()** | 与匹配事件一起使用`oneOrMore()`并且`times()`在匹配事件之间施加非确定性松弛连续性(如`followedByAny()`)。如果不应用,则使用放松的连续性(如`followedBy()`)。例如:
&lt;figure class="highlight"&gt;
``` ```
Pattern.&lt;Event&gt;begin("start").where(new SimpleCondition&lt;Event&gt;() { Pattern.&lt;Event&gt;begin("start").where(new SimpleCondition&lt;Event&gt;() {
...@@ -812,7 +711,6 @@ Pattern.&lt;Event&gt;begin("start").where(new SimpleCondition&lt;Event&gt;() { ...@@ -812,7 +711,6 @@ Pattern.&lt;Event&gt;begin("start").where(new SimpleCondition&lt;Event&gt;() {
}); });
``` ```
&lt;/figure&gt;
将为输入序列生成以下匹配项:CD A1 A2 A3 D A4 B.启用组合:{C A1 B},{C A1 A2 B},{C A1 A3 B},{C A1 A4 B},{C A1 A2 A3 B},{C A1 A2 A4 B},{C A1 A3 A4 B},{C A1 A2 A3 A4 B}未启用组合:{C A1 B},{C A1 A2 B},{C A1 A2 A3 B},{C A1 A2 A3 A4 B} | 将为输入序列生成以下匹配项:CD A1 A2 A3 D A4 B.启用组合:{C A1 B},{C A1 A2 B},{C A1 A3 B},{C A1 A4 B},{C A1 A2 A3 B},{C A1 A2 A4 B},{C A1 A3 A4 B},{C A1 A2 A3 A4 B}未启用组合:{C A1 B},{C A1 A2 B},{C A1 A2 A3 B},{C A1 A2 A3 A4 B} |
...@@ -820,7 +718,6 @@ Pattern.&lt;Event&gt;begin("start").where(new SimpleCondition&lt;Event&gt;() { ...@@ -820,7 +718,6 @@ Pattern.&lt;Event&gt;begin("start").where(new SimpleCondition&lt;Event&gt;() {
| --- | --- | | --- | --- |
| **consecutive()** | Works in conjunction with `oneOrMore()` and `times()` and imposes strict contiguity between the matching events, i.e. any non-matching element breaks the match (as in `next()`).If not applied a relaxed contiguity (as in `followedBy()`) is used.E.g. a pattern like: | **consecutive()** | Works in conjunction with `oneOrMore()` and `times()` and imposes strict contiguity between the matching events, i.e. any non-matching element breaks the match (as in `next()`).If not applied a relaxed contiguity (as in `followedBy()`) is used.E.g. a pattern like:
&lt;figure class="highlight"&gt;
``` ```
Pattern.begin("start").where(_.getName().equals("c")) Pattern.begin("start").where(_.getName().equals("c"))
...@@ -829,12 +726,10 @@ Pattern.begin("start").where(_.getName().equals("c")) ...@@ -829,12 +726,10 @@ Pattern.begin("start").where(_.getName().equals("c"))
.followedBy("end1").where(_.getName().equals("b")) .followedBy("end1").where(_.getName().equals("b"))
``` ```
&lt;/figure&gt;
Will generate the following matches for an input sequence: C D A1 A2 A3 D A4 Bwith consecutive applied: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}without consecutive applied: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}, {C A1 A2 A3 A4 B} | Will generate the following matches for an input sequence: C D A1 A2 A3 D A4 Bwith consecutive applied: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}without consecutive applied: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}, {C A1 A2 A3 A4 B} |
| **allowCombinations()** | Works in conjunction with `oneOrMore()` and `times()` and imposes non-deterministic relaxed contiguity between the matching events (as in `followedByAny()`).If not applied a relaxed contiguity (as in `followedBy()`) is used.E.g. a pattern like: | **allowCombinations()** | Works in conjunction with `oneOrMore()` and `times()` and imposes non-deterministic relaxed contiguity between the matching events (as in `followedByAny()`).If not applied a relaxed contiguity (as in `followedBy()`) is used.E.g. a pattern like:
&lt;figure class="highlight"&gt;
``` ```
Pattern.begin("start").where(_.getName().equals("c")) Pattern.begin("start").where(_.getName().equals("c"))
...@@ -843,7 +738,6 @@ Pattern.begin("start").where(_.getName().equals("c")) ...@@ -843,7 +738,6 @@ Pattern.begin("start").where(_.getName().equals("c"))
.followedBy("end1").where(_.getName().equals("b")) .followedBy("end1").where(_.getName().equals("b"))
``` ```
&lt;/figure&gt;
Will generate the following matches for an input sequence: C D A1 A2 A3 D A4 Bwith combinations enabled: {C A1 B}, {C A1 A2 B}, {C A1 A3 B}, {C A1 A4 B}, {C A1 A2 A3 B}, {C A1 A2 A4 B}, {C A1 A3 A4 B}, {C A1 A2 A3 A4 B}without combinations enabled: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}, {C A1 A2 A3 A4 B} | Will generate the following matches for an input sequence: C D A1 A2 A3 D A4 Bwith combinations enabled: {C A1 B}, {C A1 A2 B}, {C A1 A3 B}, {C A1 A4 B}, {C A1 A2 A3 B}, {C A1 A2 A4 B}, {C A1 A3 A4 B}, {C A1 A2 A3 A4 B}without combinations enabled: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}, {C A1 A2 A3 A4 B} |
...@@ -908,18 +802,15 @@ val start: Pattern[Event, _] = Pattern.begin( ...@@ -908,18 +802,15 @@ val start: Pattern[Event, _] = Pattern.begin(
| --- | --- | | --- | --- |
| **开始(#NAME)** | 定义一个起始模式: | **开始(#NAME)** | 定义一个起始模式:
&lt;figure class="highlight"&gt;
``` ```
Pattern&lt;Event, ?&gt; start = Pattern.&lt;Event&gt;begin("start"); Pattern&lt;Event, ?&gt; start = Pattern.&lt;Event&gt;begin("start");
``` ```
&lt;/figure&gt;
| |
| **开始(#pattern_sequence)** | 定义一个起始模式: | **开始(#pattern_sequence)** | 定义一个起始模式:
&lt;figure class="highlight"&gt;
``` ```
Pattern&lt;Event, ?&gt; start = Pattern.&lt;Event&gt;begin( Pattern&lt;Event, ?&gt; start = Pattern.&lt;Event&gt;begin(
...@@ -927,23 +818,19 @@ Pattern&lt;Event, ?&gt; start = Pattern.&lt;Event&gt;begin( ...@@ -927,23 +818,19 @@ Pattern&lt;Event, ?&gt; start = Pattern.&lt;Event&gt;begin(
); );
``` ```
&lt;/figure&gt;
| |
| **下一个(#NAME)** | 添加新模式。匹配事件必须直接接替先前的匹配事件(严格连续性): | **下一个(#NAME)** | 添加新模式。匹配事件必须直接接替先前的匹配事件(严格连续性):
&lt;figure class="highlight"&gt;
``` ```
Pattern&lt;Event, ?&gt; next = start.next("middle"); Pattern&lt;Event, ?&gt; next = start.next("middle");
``` ```
&lt;/figure&gt;
| |
| **下一个(#pattern_sequence)** | 添加新模式。一系列匹配事件必须直接接替先前的匹配事件(严格连续性): | **下一个(#pattern_sequence)** | 添加新模式。一系列匹配事件必须直接接替先前的匹配事件(严格连续性):
&lt;figure class="highlight"&gt;
``` ```
Pattern&lt;Event, ?&gt; next = start.next( Pattern&lt;Event, ?&gt; next = start.next(
...@@ -951,23 +838,19 @@ Pattern&lt;Event, ?&gt; next = start.next( ...@@ -951,23 +838,19 @@ Pattern&lt;Event, ?&gt; next = start.next(
); );
``` ```
&lt;/figure&gt;
| |
| **followedBy(#NAME)** | 添加新模式。匹配事件和先前匹配事件(轻松连续)之间可能发生其他事件: | **followedBy(#NAME)** | 添加新模式。匹配事件和先前匹配事件(轻松连续)之间可能发生其他事件:
&lt;figure class="highlight"&gt;
``` ```
Pattern&lt;Event, ?&gt; followedBy = start.followedBy("middle"); Pattern&lt;Event, ?&gt; followedBy = start.followedBy("middle");
``` ```
&lt;/figure&gt;
| |
| **followedBy(#pattern_sequence)** | 添加新模式。在一系列匹配事件和先前匹配事件(轻松连续)之间可能发生其他事件: | **followedBy(#pattern_sequence)** | 添加新模式。在一系列匹配事件和先前匹配事件(轻松连续)之间可能发生其他事件:
&lt;figure class="highlight"&gt;
``` ```
Pattern&lt;Event, ?&gt; followedBy = start.followedBy( Pattern&lt;Event, ?&gt; followedBy = start.followedBy(
...@@ -975,23 +858,19 @@ Pattern&lt;Event, ?&gt; followedBy = start.followedBy( ...@@ -975,23 +858,19 @@ Pattern&lt;Event, ?&gt; followedBy = start.followedBy(
); );
``` ```
&lt;/figure&gt;
| |
| **followedByAny(#NAME)** | 添加新模式。匹配事件和先前匹配事件之间可能发生其他事件,并且将针对每个备选匹配事件(非确定性放松连续性)呈现替代匹配: | **followedByAny(#NAME)** | 添加新模式。匹配事件和先前匹配事件之间可能发生其他事件,并且将针对每个备选匹配事件(非确定性放松连续性)呈现替代匹配:
&lt;figure class="highlight"&gt;
``` ```
Pattern&lt;Event, ?&gt; followedByAny = start.followedByAny("middle"); Pattern&lt;Event, ?&gt; followedByAny = start.followedByAny("middle");
``` ```
&lt;/figure&gt;
| |
| **followedByAny(#pattern_sequence)** | 添加新模式。在一系列匹配事件和先前匹配事件之间可能发生其他事件,并且将针对匹配事件的每个替代序列(非确定性松弛邻接)呈现替代匹配: | **followedByAny(#pattern_sequence)** | 添加新模式。在一系列匹配事件和先前匹配事件之间可能发生其他事件,并且将针对匹配事件的每个替代序列(非确定性松弛邻接)呈现替代匹配:
&lt;figure class="highlight"&gt;
``` ```
Pattern&lt;Event, ?&gt; followedByAny = start.followedByAny( Pattern&lt;Event, ?&gt; followedByAny = start.followedByAny(
...@@ -999,40 +878,33 @@ Pattern&lt;Event, ?&gt; followedByAny = start.followedByAny( ...@@ -999,40 +878,33 @@ Pattern&lt;Event, ?&gt; followedByAny = start.followedByAny(
); );
``` ```
&lt;/figure&gt;
| |
| **notNext()** | 添加新的负面模式。匹配(否定)事件必须直接成功执行先前的匹配事件(严格连续性)才能丢弃部分匹配: | **notNext()** | 添加新的负面模式。匹配(否定)事件必须直接成功执行先前的匹配事件(严格连续性)才能丢弃部分匹配:
&lt;figure class="highlight"&gt;
``` ```
Pattern&lt;Event, ?&gt; notNext = start.notNext("not"); Pattern&lt;Event, ?&gt; notNext = start.notNext("not");
``` ```
&lt;/figure&gt;
| |
| **notFollowedBy()** | 添加新的负面模式。即使在匹配(否定)事件和先前匹配事件(松弛连续性)之间发生其他事件,也将丢弃部分匹配事件序列: | **notFollowedBy()** | 添加新的负面模式。即使在匹配(否定)事件和先前匹配事件(松弛连续性)之间发生其他事件,也将丢弃部分匹配事件序列:
&lt;figure class="highlight"&gt;
``` ```
Pattern&lt;Event, ?&gt; notFollowedBy = start.notFollowedBy("not"); Pattern&lt;Event, ?&gt; notFollowedBy = start.notFollowedBy("not");
``` ```
&lt;/figure&gt;
| |
| **内(时间)** | 定义事件序列与模式匹配的最大时间间隔。如果未完成的事件序列超过此时间,则将其丢弃: | **内(时间)** | 定义事件序列与模式匹配的最大时间间隔。如果未完成的事件序列超过此时间,则将其丢弃:
&lt;figure class="highlight"&gt;
``` ```
pattern.within(Time.seconds(10)); pattern.within(Time.seconds(10));
``` ```
&lt;/figure&gt;
| |
...@@ -1040,18 +912,15 @@ pattern.within(Time.seconds(10)); ...@@ -1040,18 +912,15 @@ pattern.within(Time.seconds(10));
| --- | --- | | --- | --- |
| **begin(#name)** | Defines a starting pattern: | **begin(#name)** | Defines a starting pattern:
&lt;figure class="highlight"&gt;
``` ```
val start = Pattern.begin[Event]("start") val start = Pattern.begin[Event]("start")
``` ```
&lt;/figure&gt;
| |
| **begin(#pattern_sequence)** | Defines a starting pattern: | **begin(#pattern_sequence)** | Defines a starting pattern:
&lt;figure class="highlight"&gt;
``` ```
val start = Pattern.begin( val start = Pattern.begin(
...@@ -1059,23 +928,19 @@ val start = Pattern.begin( ...@@ -1059,23 +928,19 @@ val start = Pattern.begin(
) )
``` ```
&lt;/figure&gt;
| |
| **next(#name)** | Appends a new pattern. A matching event has to directly succeed the previous matching event (strict contiguity): | **next(#name)** | Appends a new pattern. A matching event has to directly succeed the previous matching event (strict contiguity):
&lt;figure class="highlight"&gt;
``` ```
val next = start.next("middle") val next = start.next("middle")
``` ```
&lt;/figure&gt;
| |
| **next(#pattern_sequence)** | Appends a new pattern. A sequence of matching events have to directly succeed the previous matching event (strict contiguity): | **next(#pattern_sequence)** | Appends a new pattern. A sequence of matching events have to directly succeed the previous matching event (strict contiguity):
&lt;figure class="highlight"&gt;
``` ```
val next = start.next( val next = start.next(
...@@ -1083,23 +948,19 @@ val next = start.next( ...@@ -1083,23 +948,19 @@ val next = start.next(
) )
``` ```
&lt;/figure&gt;
| |
| **followedBy(#name)** | Appends a new pattern. Other events can occur between a matching event and the previous matching event (relaxed contiguity) : | **followedBy(#name)** | Appends a new pattern. Other events can occur between a matching event and the previous matching event (relaxed contiguity) :
&lt;figure class="highlight"&gt;
``` ```
val followedBy = start.followedBy("middle") val followedBy = start.followedBy("middle")
``` ```
&lt;/figure&gt;
| |
| **followedBy(#pattern_sequence)** | Appends a new pattern. Other events can occur between a sequence of matching events and the previous matching event (relaxed contiguity) : | **followedBy(#pattern_sequence)** | Appends a new pattern. Other events can occur between a sequence of matching events and the previous matching event (relaxed contiguity) :
&lt;figure class="highlight"&gt;
``` ```
val followedBy = start.followedBy( val followedBy = start.followedBy(
...@@ -1107,23 +968,19 @@ val followedBy = start.followedBy( ...@@ -1107,23 +968,19 @@ val followedBy = start.followedBy(
) )
``` ```
&lt;/figure&gt;
| |
| **followedByAny(#name)** | Appends a new pattern. Other events can occur between a matching event and the previous matching event, and alternative matches will be presented for every alternative matching event (non-deterministic relaxed contiguity): | **followedByAny(#name)** | Appends a new pattern. Other events can occur between a matching event and the previous matching event, and alternative matches will be presented for every alternative matching event (non-deterministic relaxed contiguity):
&lt;figure class="highlight"&gt;
``` ```
val followedByAny = start.followedByAny("middle") val followedByAny = start.followedByAny("middle")
``` ```
&lt;/figure&gt;
| |
| **followedByAny(#pattern_sequence)** | Appends a new pattern. Other events can occur between a sequence of matching events and the previous matching event, and alternative matches will be presented for every alternative sequence of matching events (non-deterministic relaxed contiguity): | **followedByAny(#pattern_sequence)** | Appends a new pattern. Other events can occur between a sequence of matching events and the previous matching event, and alternative matches will be presented for every alternative sequence of matching events (non-deterministic relaxed contiguity):
&lt;figure class="highlight"&gt;
``` ```
val followedByAny = start.followedByAny( val followedByAny = start.followedByAny(
...@@ -1131,40 +988,33 @@ val followedByAny = start.followedByAny( ...@@ -1131,40 +988,33 @@ val followedByAny = start.followedByAny(
) )
``` ```
&lt;/figure&gt;
| |
| **notNext()** | Appends a new negative pattern. A matching (negative) event has to directly succeed the previous matching event (strict contiguity) for the partial match to be discarded: | **notNext()** | Appends a new negative pattern. A matching (negative) event has to directly succeed the previous matching event (strict contiguity) for the partial match to be discarded:
&lt;figure class="highlight"&gt;
``` ```
val notNext = start.notNext("not") val notNext = start.notNext("not")
``` ```
&lt;/figure&gt;
| |
| **notFollowedBy()** | Appends a new negative pattern. A partial matching event sequence will be discarded even if other events occur between the matching (negative) event and the previous matching event (relaxed contiguity): | **notFollowedBy()** | Appends a new negative pattern. A partial matching event sequence will be discarded even if other events occur between the matching (negative) event and the previous matching event (relaxed contiguity):
&lt;figure class="highlight"&gt;
``` ```
val notFollowedBy = start.notFollowedBy("not") val notFollowedBy = start.notFollowedBy("not")
``` ```
&lt;/figure&gt;
| |
| **within(time)** | Defines the maximum time interval for an event sequence to match the pattern. If a non-completed event sequence exceeds this time, it is discarded: | **within(time)** | Defines the maximum time interval for an event sequence to match the pattern. If a non-completed event sequence exceeds this time, it is discarded:
&lt;figure class="highlight"&gt;
``` ```
pattern.within(Time.seconds(10)) pattern.within(Time.seconds(10))
``` ```
&lt;/figure&gt;
| |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册