Search in sources :

Example 1 with ComputationState

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);
    }
}
Also used : ArrayList(java.util.ArrayList) EventId(org.apache.flink.cep.nfa.sharedbuffer.EventId) ComputationState(org.apache.flink.cep.nfa.ComputationState)

Aggregations

ArrayList (java.util.ArrayList)1 ComputationState (org.apache.flink.cep.nfa.ComputationState)1 EventId (org.apache.flink.cep.nfa.sharedbuffer.EventId)1