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

ASF GitHub Bot commented on FLINK-6927:
---------------------------------------

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

    https://github.com/apache/flink/pull/4153#discussion_r124999092
  
    --- Diff: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
 ---
    @@ -455,6 +548,76 @@ private void addStopStateToLooping(final State<T> 
loopingState) {
                }
     
                /**
    +            * Create all the states for the group pattern.
    +            *
    +            * @param groupPattern the group pattern to create the states 
for
    +            * @param sinkState the state that the group pattern being 
converted should point to
    +            * @param proceedState the state that the group pattern being 
converted should proceed to
    +            * @param isOptional whether the group pattern being converted 
is optional
    +            * @return the first state of the states of the group pattern
    +            */
    +           private State<T> createGroupPatternState(
    +                   final GroupPattern<T, ?> groupPattern,
    +                   final State<T> sinkState,
    +                   final State<T> proceedState,
    +                   final boolean isOptional) {
    +                   final IterativeCondition<T> trueFunction = 
BooleanConditions.trueFunction();
    +
    +                   Pattern<T, ?> oldCurrentPattern = currentPattern;
    +                   Pattern<T, ?> oldFollowingPattern = followingPattern;
    +                   GroupPattern<T, ?> oldGroupPattern = 
currentGroupPattern;
    +                   try {
    --- End diff --
    
    What is the point of this `try` block? Why not:
    
        private State<T> createGroupPatternState(
                final GroupPattern<T, ?> groupPattern,
                final State<T> sinkState,
                final State<T> proceedState,
                final boolean isOptional) {
                final IterativeCondition<T> trueFunction = 
BooleanConditions.trueFunction();
    
                Pattern<T, ?> oldCurrentPattern = currentPattern;
                Pattern<T, ?> oldFollowingPattern = followingPattern;
                GroupPattern<T, ?> oldGroupPattern = currentGroupPattern;
                State<T> lastSink = sinkState;
                currentGroupPattern = groupPattern;
                currentPattern = groupPattern.getRawPattern();
                lastSink = createMiddleStates(lastSink);
                lastSink = convertPattern(lastSink);
                if (isOptional) {
                        // for the first state of a group pattern, its PROCEED 
edge should point to
                        // the following state of that group pattern
                        lastSink.addProceed(proceedState, trueFunction);
                }
                currentPattern = oldCurrentPattern;
                followingPattern = oldFollowingPattern;
                currentGroupPattern = oldGroupPattern;
                return lastSink;
        }


> Support pattern group in CEP
> ----------------------------
>
>                 Key: FLINK-6927
>                 URL: https://issues.apache.org/jira/browse/FLINK-6927
>             Project: Flink
>          Issue Type: Sub-task
>          Components: CEP
>            Reporter: Dian Fu
>            Assignee: Dian Fu
>
> We should add support for pattern group. This would enrich the set of 
> supported patterns. For example, users can write patterns like this with this 
> feature available:
> {code}
>  A --> (B --> C.times(3)).optional() --> D
> {code}
> or
> {code}
> A --> (B --> C).times(3) --> D
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to