Class AfterMatchSkipStrategy
- java.lang.Object
-
- org.apache.flink.cep.nfa.aftermatch.AfterMatchSkipStrategy
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
NoSkipStrategy,SkipPastLastStrategy,SkipToFirstStrategy,SkipToLastStrategy,SkipToNextStrategy
public abstract class AfterMatchSkipStrategy extends Object implements Serializable
Indicate the skip strategy after a match process.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Optional<String>getPatternName()Name of pattern that processing will be skipped to.protected abstract EventIdgetPruningId(Collection<Map<String,List<EventId>>> match)Retrieves event id of the pruning element from the given match based on the strategy.abstract booleanisSkipStrategy()Tells if the strategy may skip some matches.static NoSkipStrategynoSkip()Every possible match will be emitted.voidprune(Collection<ComputationState> matchesToPrune, Collection<Map<String,List<EventId>>> matchedResult, SharedBufferAccessor<?> sharedBufferAccessor)Prunes matches/partial matches based on the chosen strategy.protected abstract booleanshouldPrune(EventId startEventID, EventId pruningId)Tells if the partial/completed match starting at given id should be prunned by given pruningId.static SkipPastLastStrategyskipPastLastEvent()Discards every partial match that started before emitted match ended.static SkipToFirstStrategyskipToFirst(String patternName)Discards every partial match that started before the first event of emitted match mapped to *PatternName*.static SkipToLastStrategyskipToLast(String patternName)Discards every partial match that started before the last event of emitted match mapped to *PatternName*.static AfterMatchSkipStrategyskipToNext()Discards every partial match that started with the same event, emitted match was started.
-
-
-
Method Detail
-
skipToFirst
public static SkipToFirstStrategy skipToFirst(String patternName)
Discards every partial match that started before the first event of emitted match mapped to *PatternName*.- Parameters:
patternName- the pattern name to skip to- Returns:
- the created AfterMatchSkipStrategy
-
skipToLast
public static SkipToLastStrategy skipToLast(String patternName)
Discards every partial match that started before the last event of emitted match mapped to *PatternName*.- Parameters:
patternName- the pattern name to skip to- Returns:
- the created AfterMatchSkipStrategy
-
skipPastLastEvent
public static SkipPastLastStrategy skipPastLastEvent()
Discards every partial match that started before emitted match ended.- Returns:
- the created AfterMatchSkipStrategy
-
skipToNext
public static AfterMatchSkipStrategy skipToNext()
Discards every partial match that started with the same event, emitted match was started.- Returns:
- the created AfterMatchSkipStrategy
-
noSkip
public static NoSkipStrategy noSkip()
Every possible match will be emitted.- Returns:
- the created AfterMatchSkipStrategy
-
isSkipStrategy
public abstract boolean isSkipStrategy()
Tells if the strategy may skip some matches.- Returns:
- false if the strategy is NO_SKIP strategy
-
prune
public void prune(Collection<ComputationState> matchesToPrune, Collection<Map<String,List<EventId>>> matchedResult, SharedBufferAccessor<?> sharedBufferAccessor) throws Exception
Prunes matches/partial matches based on the chosen strategy.- Parameters:
matchesToPrune- current partial matchesmatchedResult- already completed matchessharedBufferAccessor- accessor to corresponding shared buffer- Throws:
Exception- thrown if could not access the state
-
shouldPrune
protected abstract boolean shouldPrune(EventId startEventID, EventId pruningId)
Tells if the partial/completed match starting at given id should be prunned by given pruningId.- Parameters:
startEventID- starting event id of a partial/completed matchpruningId- pruningId calculated by this strategy- Returns:
- true if the match should be pruned
-
getPruningId
protected abstract EventId getPruningId(Collection<Map<String,List<EventId>>> match)
Retrieves event id of the pruning element from the given match based on the strategy.- Parameters:
match- match corresponding to which should the pruning happen- Returns:
- pruning event id
-
-