Github user yestinchen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4331#discussion_r132348950
  
    --- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
 ---
    @@ -150,6 +160,59 @@ long getWindowTime() {
                }
     
                /**
    +            * Check pattern after match skip strategy.
    +            */
    +           private void checkPatternSkipStrategy() {
    +                   AfterMatchSkipStrategy afterMatchSkipStrategy = 
currentPattern.getAfterMatchSkipStrategy();
    +                   if (afterMatchSkipStrategy.getStrategy() == 
AfterMatchSkipStrategy.SkipStrategy.SKIP_TO_FIRST ||
    +                           afterMatchSkipStrategy.getStrategy() == 
AfterMatchSkipStrategy.SkipStrategy.SKIP_TO_LAST) {
    +                           Pattern<T, ?> pattern = currentPattern;
    +                           while 
(!pattern.getName().equals(afterMatchSkipStrategy.getPatternName())) {
    +                                   pattern = pattern.getPrevious();
    +                           }
    +                           // pattern name match check.
    +                           if (pattern == null) {
    +                                   throw new 
MalformedPatternException("the pattern name specified in AfterMatchSkipStrategy 
" +
    +                                           "can not be found in the given 
Pattern");
    +                           } else {
    +                                   // can not be used with optional states.
    +                                   if 
(pattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.OPTIONAL)) {
    +                                           throw new 
MalformedPatternException("the AfterMatchSkipStrategy "
    +                                                   + 
afterMatchSkipStrategy.getStrategy() + " can not be used with optional 
pattern");
    +                                   }
    +                           }
    +
    +                           // start position check.
    +                           if (pattern.getPrevious() == null) {
    --- End diff --
    
    I agree with you that the fallback approach is much easier to understand 
and maintain.
    If we discard nothing, the actual sematics is to use SKIP_TO_NEXT_EVENT for 
the next match process. But it will have an impact on matching sematics, which 
may lead to incorrect results. I think users should be aware of what happens. 
My original thought was to add a configuration switch, to let user choose 
between throwing exceptions and falling back to a default skip strategy.
    Do you have any ideas about that?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to