flink-issues mailing list archives

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

    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/compiler/NFACompiler.java
    @@ -526,18 +551,32 @@ private boolean isPatternOptional(Pattern<T, ?> pattern) {
     				return createGroupPatternState((GroupPattern) currentPattern, sinkState, proceedState,
    -			final IterativeCondition<T> trueFunction = getTrueFunction();
     			final State<T> singletonState = createState(currentPattern.getName(), State.StateType.Normal);
     			// if event is accepted then all notPatterns previous to the optional states are no
longer valid
     			final State<T> sink = copyWithoutTransitiveNots(sinkState);
     			singletonState.addTake(sink, takeCondition);
    +			// if no element accepted the previous nots are still valid.
    +			final IterativeCondition<T> proceedCondition = getTrueFunction();
     			// for the first state of a group pattern, its PROCEED edge should point to the following
state of
     			// that group pattern and the edge will be added at the end of creating the NFA for
that group pattern
     			if (isOptional && !headOfGroup(currentPattern)) {
    -				// if no element accepted the previous nots are still valid.
    -				singletonState.addProceed(proceedState, trueFunction);
    +				if (currentPattern.getQuantifier().hasProperty(Quantifier.QuantifierProperty.GREEDY))
    +					final IterativeCondition<T> untilCondition =
    +						(IterativeCondition<T>) currentPattern.getUntilCondition();
    +					if (untilCondition != null) {
    +						singletonState.addProceed(
    +							originalStateMap.get(proceedState.getName()),
    +							new AndCondition<>(proceedCondition, untilCondition));
    --- End diff --
    When untilCondition holds, the loop should break and the state should proceed to the next
state. This is covered by the test case GreedyITCase#testGreedyUntilWithDummyEventsBeforeQuantifier.

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.

View raw message