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 ;)


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to