flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yestinchen <...@git.apache.org>
Subject [GitHub] flink pull request #4331: [FLINK-7169][CEP] Support AFTER MATCH SKIP functio...
Date Wed, 26 Jul 2017 08:50:29 GMT
Github user yestinchen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4331#discussion_r129515022
  
    --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/NFA.java ---
    @@ -551,18 +579,47 @@ private boolean isSelfIgnore(final StateTransition<T> edge)
{
     								nextVersion,
     								startTimestamp);
     					}
    +
    +					switch (skipStrategy.getStrategy()) {
    +						case SKIP_PAST_LAST_ROW:
    +							if (nextState.isFinal()) {
    +								resultingComputationStates.add(createStartComputationState(computationState,
outgoingEdges));
    +							}
    +							break;
    +						case SKIP_TO_FIRST:
    +							if (nextState.getName().equals(skipStrategy.getRpv()) &&
    +								!nextState.getName().equals(currentState.getName())) {
    +								ComputationState<T> startComputationState = createStartComputationState(computationState,
outgoingEdges);
    +								if (callLevel > 0) {
    +									throw new RuntimeException("infinite loop! Will abort the match process, please
rewrite your pattern query");
    +								}
    +								// feed current matched event to the state.
    +								Collection<ComputationState<T>> computationStates = computeNextStates(startComputationState,
event, timestamp, callLevel++);
    --- End diff --
    
    Because SKIP_TO_FIRST or SKIP_TO_LAST needs to start the next match process at the first
or last matched event in specified pattern. For example, for a given event stream: `a1, b1,
c1, a2` and a given match `(A B C)`. If we set the SkipStrategy to SKIP_TO_FIRST with a pattern
name `B`, we should create a new `startComputationState` after `b1` is being processed. And
the next match should start at event `b1`. So we need to manually feed `b1` to the newly created
`startComputationState`. 


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