[ 
https://issues.apache.org/jira/browse/FLINK-27456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17529911#comment-17529911
 ] 

zhangtianyu commented on FLINK-27456:
-------------------------------------

t-1退订【[email protected]】

jira <[email protected]>写到:

David Anderson created FLINK-27456:-------------------------------------- 
Summary: mistake and confusion with CEP example in docs Key: FLINK-27456 URL: 
https://issues.apache.org/jira/browse/FLINK-27456 Project: Flink Issue Type: 
Bug Components: Documentation, Library / CEP Affects Versions: 1.14.4 Reporter: 
David 
Anderson[https://nightlies.apache.org/flink/flink-docs-master/docs/libs/cep/#contiguity-within-looping-patterns]In
 the section of the docs on contiguity within looping patterns, what it says 
about strict contiguity for the given example is either incorrect or very 
confusing (or both). It doesn't help that the example code doesn't precisely 
match the scenario described in the text.To study this, I implemented the 
example in the text and find it produces no output for strict contiguity (as I 
expected), which contradicts what the text says.{code:java}public class 
StreamingJob { public static void main(String[] args) throws Exception { 
StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment(); DataStream  events = 
env.fromElements("a", "b1", "d1", "b2", "d2", "b3", "c"); 
AfterMatchSkipStrategy skipStrategy = 
AfterMatchSkipStrategy.skipPastLastEvent(); Pattern  pattern = Pattern.  
begin("a", skipStrategy) .where( new SimpleCondition  () { @Override public 
boolean filter(String element) throws Exception { return 
element.startsWith("a"); } }) .next("b ") .where( new SimpleCondition  () { 
@Override public boolean filter(String element) throws Exception { return 
element.startsWith("b"); } }) .oneOrMore().consecutive() .next("c") .where( new 
SimpleCondition  () { @Override public boolean filter(String element) throws 
Exception { return element.startsWith("c"); } }); PatternStream  patternStream 
= CEP.pattern(events, pattern).inProcessingTime(); patternStream.select(new 
SelectSegment()).addSink(new PrintSinkFunction<>(true)); env.execute(); } 
public static class SelectSegment implements PatternSelectFunction  { public 
String select(Map


> mistake and confusion with CEP example in docs
> ----------------------------------------------
>
>                 Key: FLINK-27456
>                 URL: https://issues.apache.org/jira/browse/FLINK-27456
>             Project: Flink
>          Issue Type: Bug
>          Components: Documentation, Library / CEP
>    Affects Versions: 1.14.4
>            Reporter: David Anderson
>            Priority: Major
>
> [https://nightlies.apache.org/flink/flink-docs-master/docs/libs/cep/#contiguity-within-looping-patterns]
> In the section of the docs on contiguity within looping patterns, what it 
> says about strict contiguity for the given example is either incorrect or 
> very confusing (or both). It doesn't help that the example code doesn't 
> precisely match the scenario described in the text.
> To study this, I implemented the example in the text and find it produces no 
> output for strict contiguity (as I expected), which contradicts what the text 
> says.
> {code:java}
> public class StreamingJob {
>     public static void main(String[] args) throws Exception {
>         StreamExecutionEnvironment env = 
> StreamExecutionEnvironment.getExecutionEnvironment();
>         DataStream<String> events = env.fromElements("a", "b1", "d1", "b2", 
> "d2", "b3", "c");
>         AfterMatchSkipStrategy skipStrategy = 
> AfterMatchSkipStrategy.skipPastLastEvent();
>         Pattern<String, String> pattern =
>                 Pattern.<String>begin("a", skipStrategy)
>                         .where(
>                                 new SimpleCondition<String>() {
>                                     @Override
>                                     public boolean filter(String element) 
> throws Exception {
>                                         return element.startsWith("a");
>                                     }
>                                 })
>                         .next("b+")
>                         .where(
>                                 new SimpleCondition<String>() {
>                                     @Override
>                                     public boolean filter(String element) 
> throws Exception {
>                                         return element.startsWith("b");
>                                     }
>                                 })
>                         .oneOrMore().consecutive()
>                         .next("c")
>                         .where(
>                                 new SimpleCondition<String>() {
>                                     @Override
>                                     public boolean filter(String element) 
> throws Exception {
>                                         return element.startsWith("c");
>                                     }
>                                 });
>         PatternStream<String> patternStream = CEP.pattern(events, 
> pattern).inProcessingTime();
>         patternStream.select(new SelectSegment()).addSink(new 
> PrintSinkFunction<>(true));
>         env.execute();
>     }
>     public static class SelectSegment implements 
> PatternSelectFunction<String, String> {
>         public String select(Map<String, List<String>> pattern) {
>             return String.join("", pattern.get("a"))
>                     + String.join("", pattern.get("b+"))
>                     + String.join("", pattern.get("c"));
>         }
>     }
> }
>  {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to