Repository: flink
Updated Branches:
  refs/heads/master 8ba5c7a37 -> 28ab73750


[FLINK-6463] [cep] Throw exception when NOT-NEXT is after OPTIONAL.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/28ab7375
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/28ab7375
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/28ab7375

Branch: refs/heads/master
Commit: 28ab737506aa53248de8f71eed0dcff87d7e6f40
Parents: 8ba5c7a
Author: kl0u <kklou...@gmail.com>
Authored: Fri May 5 15:05:52 2017 +0200
Committer: kl0u <kklou...@gmail.com>
Committed: Fri May 5 17:25:08 2017 +0200

----------------------------------------------------------------------
 .../org/apache/flink/cep/pattern/Pattern.java   | 15 +++--
 .../org/apache/flink/cep/nfa/NFAITCase.java     | 67 --------------------
 2 files changed, 10 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/28ab7375/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java
----------------------------------------------------------------------
diff --git 
a/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java
 
b/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java
index 3cf25ef..2d10b41 100644
--- 
a/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java
+++ 
b/flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/pattern/Pattern.java
@@ -221,6 +221,12 @@ public class Pattern<T, F extends T> {
         * @return A new pattern which is appended to this one
         */
        public Pattern<T, T> notNext(final String name) {
+               if 
(quantifier.hasProperty(Quantifier.QuantifierProperty.OPTIONAL)) {
+                       throw new UnsupportedOperationException(
+                                       "Specifying a pattern with an optional 
path to NOT condition is not supported yet. " +
+                                       "You can simulate such pattern with two 
independent patterns, one with and the other without " +
+                                       "the optional part.");
+               }
                return new Pattern<>(name, this, ConsumingStrategy.NOT_NEXT);
        }
 
@@ -247,12 +253,11 @@ public class Pattern<T, F extends T> {
         */
        public Pattern<T, T> notFollowedBy(final String name) {
                if 
(quantifier.hasProperty(Quantifier.QuantifierProperty.OPTIONAL)) {
-                       throw new MalformedPatternException(
-                               "Specifying a pattern with an optional path to 
NOT condition is not supported yet. " +
-                               "You can simulate such pattern with two 
independent patterns, one with and the other without " +
-                               "the optional part.");
+                       throw new UnsupportedOperationException(
+                                       "Specifying a pattern with an optional 
path to NOT condition is not supported yet. " +
+                                       "You can simulate such pattern with two 
independent patterns, one with and the other without " +
+                                       "the optional part.");
                }
-
                return new Pattern<>(name, this, ConsumingStrategy.NOT_FOLLOW);
        }
 

http://git-wip-us.apache.org/repos/asf/flink/blob/28ab7375/flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/nfa/NFAITCase.java
----------------------------------------------------------------------
diff --git 
a/flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/nfa/NFAITCase.java
 
b/flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/nfa/NFAITCase.java
index ab6ff82..2cc67e5 100644
--- 
a/flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/nfa/NFAITCase.java
+++ 
b/flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/nfa/NFAITCase.java
@@ -3742,73 +3742,6 @@ public class NFAITCase extends TestLogger {
        }
 
        @Test
-       public void testNotNextAfterZeroOrMoreSkipTillNext() {
-               final List<List<Event>> matches = 
testNotNextAfterZeroOrMore(false);
-               compareMaps(matches, Lists.<List<Event>>newArrayList(
-                       Lists.newArrayList(NotFollowByData.a1, 
NotFollowByData.d1)
-               ));
-       }
-
-       @Test
-       public void testNotNextAfterZeroOrMoreSkipTillAny() {
-               final List<List<Event>> matches = 
testNotNextAfterZeroOrMore(true);
-               compareMaps(matches, Lists.<List<Event>>newArrayList(
-                       Lists.newArrayList(NotFollowByData.a1, 
NotFollowByData.b2, NotFollowByData.d1),
-                       Lists.newArrayList(NotFollowByData.a1, 
NotFollowByData.d1)
-               ));
-       }
-
-       private List<List<Event>> testNotNextAfterZeroOrMore(boolean 
allMatches) {
-               List<StreamRecord<Event>> inputEvents = new ArrayList<>();
-
-               int i = 0;
-               inputEvents.add(new StreamRecord<>(NotFollowByData.a1, i++));
-               inputEvents.add(new StreamRecord<>(NotFollowByData.b1, i++));
-               inputEvents.add(new StreamRecord<>(NotFollowByData.c1, i++));
-               inputEvents.add(new StreamRecord<>(NotFollowByData.b2, i++));
-               inputEvents.add(new StreamRecord<>(NotFollowByData.d1, i++));
-
-               Pattern<Event, ?> pattern = Pattern
-                       .<Event>begin("a").where(new SimpleCondition<Event>() {
-                               private static final long serialVersionUID = 
5726188262756267490L;
-
-                               @Override
-                               public boolean filter(Event value) throws 
Exception {
-                                       return value.getName().equals("a");
-                               }
-                       });
-
-               pattern = (allMatches ? pattern.followedByAny("b*") : 
pattern.followedBy("b*")).where(new SimpleCondition<Event>() {
-                       private static final long serialVersionUID = 
5726188262756267490L;
-
-                       @Override
-                       public boolean filter(Event value) throws Exception {
-                               return value.getName().equals("b");
-                       }
-               }).oneOrMore().optional()
-                       .notNext("not c").where(new SimpleCondition<Event>() {
-                               private static final long serialVersionUID = 
5726188262756267490L;
-
-                               @Override
-                               public boolean filter(Event value) throws 
Exception {
-                                       return value.getName().equals("c");
-                               }
-                       })
-                       .followedBy("d").where(new SimpleCondition<Event>() {
-                               private static final long serialVersionUID = 
5726188262756267490L;
-
-                               @Override
-                               public boolean filter(Event value) throws 
Exception {
-                                       return value.getName().equals("d");
-                               }
-                       });
-
-               NFA<Event> nfa = NFACompiler.compile(pattern, 
Event.createTypeSerializer(), false);
-
-               return feedNFA(inputEvents, nfa);
-       }
-
-       @Test
        public void testNotNextAfterOneOrMoreSkipTillNext() {
                final List<List<Event>> matches = 
testNotNextAfterOneOrMore(false);
                assertEquals(0, matches.size());

Reply via email to