flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dawidwys <...@git.apache.org>
Subject [GitHub] flink pull request #4296: [FLINK-7147] [cep] Support greedy quantifier in CE...
Date Tue, 01 Aug 2017 07:36:23 GMT
Github user dawidwys commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4296#discussion_r130537682
  
    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
---
    @@ -657,25 +663,34 @@ private boolean isPatternOptional(Pattern<T, ?> pattern) {
     				true);
     
     			IterativeCondition<T> proceedCondition = getTrueFunction();
    -			if (currentPattern.getQuantifier().isGreedy()) {
    -				proceedCondition = getGreedyCondition(proceedCondition, Lists.newArrayList(takeCondition));
    +			if (currentPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY))
{
    +				proceedCondition = getGreedyCondition(
    +					proceedCondition,
    +					takeCondition,
    +					ignoreCondition,
    +					followingTakeCondition);;
     			}
     			final State<T> loopingState = createState(currentPattern.getName(), State.StateType.Normal,
    -				currentPattern.getQuantifier().isGreedy());
    +				currentPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY));
     			loopingState.addProceed(sinkState, proceedCondition);
     			loopingState.addTake(takeCondition);
     
     			addStopStateToLooping(loopingState);
     
     			if (ignoreCondition != null) {
     				final State<T> ignoreState = createState(currentPattern.getName(), State.StateType.Normal,
    -					currentPattern.getQuantifier().isGreedy());
    +					currentPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY));
     				ignoreState.addTake(loopingState, takeCondition);
     				ignoreState.addIgnore(ignoreCondition);
     				loopingState.addIgnore(ignoreState, ignoreCondition);
    +				if (currentPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY))
{
    --- End diff --
    
    I think the problem you mentioned with `GreedyITCase.testGreedyZeroOrMoreBeforeOptional2`
is due to that proceed. The whole reason behind the additional ignoreState was for it not
to have the `PROCEED` transition as it creates additional computationStates with the `sinkState`.
I think for the greedy to work we need to put customized ignoreCondition into the `sinkState`
of a greedy Pattern. What do you think?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message