Github user dawidwys commented on a diff in the pull request: https://github.com/apache/flink/pull/4331#discussion_r132139074 --- Diff: flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/NFA.java --- @@ -322,6 +336,64 @@ public void resetNFAChanged() { } + Set<T> discardEvents = new HashSet<>(); + switch(afterMatchSkipStrategy.getStrategy()) { + case SKIP_TO_LAST: + for (Map<String, List<T>> resultMap: result) { + boolean matched = false; --- End diff -- How about: for (Map<String, List<T>> resultMap: result) { for (Map.Entry<String, List<T>> keyMatches : resultMap.entrySet()) { if (keyMatches.getKey().equals(afterMatchSkipStrategy.getPatternName())) { discardEvents.addAll(keyMatches.getValue().subList(0, keyMatches.getValue().size() - 1)); break; } else { discardEvents.addAll(keyMatches.getValue()); } } } This way we will stop whenever we reach the matching pattern.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---