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

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

Github user kl0u commented on the issue:

    https://github.com/apache/flink/pull/2361
  
    Hi @mushketyk ! Thanks a lot!
    
    The problem is in the `NFACompiler` and more specifically the way the 
pattern is compiled. I have not come up with a concrete solution yet but I 
would say that:
    
    i) there should be another `StateType` as well, sth like `PotentialFinal` 
(or a better name) and in the case that the final pattern is optional, then it 
gets assigned this `StateType`. This also propagates backwards in the pattern 
graph in the case that the final pattern is optional (0 to sth times). 
    
    ii) the `addTransitions()` should also be extended to account for 
quantifiers  at the end and at the start of the pattern when "unrolling" or 
expanding the original pattern, e.g. the `expandRepeatingPattern()` should not 
always assign `State.StateType.Normal` to the unrolled patterns as they may be 
at the end or the start.
    
    iii) the `NFA` should also be modified to account for the new 
`PotentialFinal` state. In this case, when we see such a pattern, a flag should 
be set, and for example in the one-to-many case the pattern should be matched 
when the next non-matching element comes.
    
    Again these are some initial thoughts. We can discuss more on the design if 
you want, as this seems to be a bigger change than expected ;)


> Add support for quantifiers to CEP's pattern API
> ------------------------------------------------
>
>                 Key: FLINK-3318
>                 URL: https://issues.apache.org/jira/browse/FLINK-3318
>             Project: Flink
>          Issue Type: Improvement
>          Components: CEP
>    Affects Versions: 1.0.0
>            Reporter: Till Rohrmann
>            Assignee: Ivan Mushketyk
>            Priority: Minor
>
> It would be a good addition to extend the pattern API to support quantifiers 
> known from regular expressions (e.g. Kleene star, ?, +, or count bounds). 
> This would considerably enrich the set of supported patterns.
> Implementing the count bounds could be done by unrolling the pattern state. 
> In order to support the Kleene star operator, the {{NFACompiler}} has to be 
> extended to insert epsilon-transition between a Kleene start state and the 
> succeeding pattern state. In order to support {{?}}, one could insert two 
> paths from the preceding state, one which accepts the event and another which 
> directly goes into the next pattern state.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to