[ https://issues.apache.org/jira/browse/FLINK-3319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15340352#comment-15340352 ]
Robert Thorman commented on FLINK-3319: --------------------------------------- Below is a test case I wrote which passes with a new OrFilterFunction. Let me know if this is what was expected or not. /** * Checks that a certain event sequence is recognized with an OR filter * @throws Exception */ @Test public void testSimpleOrFilterPatternCEP() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStream<Event> input = env.fromElements( new Event(1, "start", 1.0), new Event(2, "middle", 2.0), new Event(3, "end", 3.0), new Event(4, "start", 4.0), new Event(5, "middle", 5.0), new Event(6, "end", 6.0) ); Pattern<Event, ?> pattern = Pattern.<Event>begin("start") .where(new FilterFunction<Event>() { @Override public boolean filter(Event value) throws Exception { return value.getName().equals("start"); } }) .followedBy("middle") .where(new FilterFunction<Event>() { @Override public boolean filter(Event value) throws Exception { return value.getPrice() == 2.0; } }) .or(new FilterFunction<Event>() { @Override public boolean filter(Event value) throws Exception { return value.getPrice() == 5.0; } }) .followedBy("end").where(new FilterFunction<Event>() { @Override public boolean filter(Event value) throws Exception { return value.getName().equals("end"); } }); DataStream<String> result = CEP.pattern(input, pattern).select(new PatternSelectFunction<Event, String>() { @Override public String select(Map<String, Event> pattern) { StringBuilder builder = new StringBuilder(); builder.append(pattern.get("start").getId()).append(",") .append(pattern.get("middle").getId()).append(",") .append(pattern.get("end").getId()); return builder.toString(); } }); result.writeAsText(resultPath, FileSystem.WriteMode.OVERWRITE); // expected sequence of matching event ids expected = "1,5,6\n1,2,3\n4,5,6\n1,2,6"; env.execute(); } > Add or operator to CEP's pattern API > ------------------------------------ > > Key: FLINK-3319 > URL: https://issues.apache.org/jira/browse/FLINK-3319 > Project: Flink > Issue Type: Improvement > Components: CEP > Affects Versions: 1.0.0 > Reporter: Till Rohrmann > Assignee: Robert Thorman > Priority: Minor > > Adding an {{or}} operator to CEP's pattern API would be beneficial. This > would considerably extend the set of supported patterns. The {{or}} operator > lets you define multiple succeeding pattern states for the next stage. > {code} > Pattern.begin("start").next("middle1").where(...).or("middle2").where(...) > {code} > In order to implement the {{or}} operator, one has to extend the {{Pattern}} > class. Furthermore, the {{NFACompiler}} has to be extended to generate two > resulting pattern states in case of an {{or}} operator. -- This message was sent by Atlassian JIRA (v6.3.4#6332)