use of org.apache.flink.cep.nfa.ComputationState in project flink by apache.
the class AfterMatchSkipStrategy method prune.
/**
* Prunes matches/partial matches based on the chosen strategy.
*
* @param matchesToPrune current partial matches
* @param matchedResult already completed matches
* @param sharedBufferAccessor accessor to corresponding shared buffer
* @throws Exception thrown if could not access the state
*/
public void prune(Collection<ComputationState> matchesToPrune, Collection<Map<String, List<EventId>>> matchedResult, SharedBufferAccessor<?> sharedBufferAccessor) throws Exception {
EventId pruningId = getPruningId(matchedResult);
if (pruningId != null) {
List<ComputationState> discardStates = new ArrayList<>();
for (ComputationState computationState : matchesToPrune) {
if (computationState.getStartEventID() != null && shouldPrune(computationState.getStartEventID(), pruningId)) {
sharedBufferAccessor.releaseNode(computationState.getPreviousBufferEntry(), computationState.getVersion());
discardStates.add(computationState);
}
}
matchesToPrune.removeAll(discardStates);
}
}
Aggregations