Package org.apache.flink.cep.nfa
Class NFA<T>
java.lang.Object
org.apache.flink.cep.nfa.NFA<T>
- Type Parameters:
T- Type of the processed events
Non-deterministic finite automaton implementation.
The CEP operator keeps one NFA per key, for
keyed input streams, and a single global NFA for non-keyed ones. When an event gets processed, it
updates the NFA's internal state machine.
An event that belongs to a partially matched sequence is kept in an internal buffer, which is a memory-optimized data-structure exactly for this purpose. Events
in the buffer are removed when all the matched sequences that contain them are:
- emitted (success)
- discarded (patterns containing NOT)
- timed-out (windowed patterns)
The implementation is strongly based on the paper "Efficient Pattern Matching over Event Streams".
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.flink.api.java.tuple.Tuple2<Collection<Map<String,List<T>>>, Collection<org.apache.flink.api.java.tuple.Tuple2<Map<String, List<T>>, Long>>> advanceTime(SharedBufferAccessor<T> sharedBufferAccessor, NFAState nfaState, long timestamp, AfterMatchSkipStrategy afterMatchSkipStrategy) Prunes states assuming there will be no events with timestamp lower than the given one.voidclose()Tear-down method for the NFA.Collection<State<T>>longvoidopen(org.apache.flink.api.common.functions.RuntimeContext cepRuntimeContext, org.apache.flink.configuration.Configuration conf) Initialization method for the NFA.Collection<Map<String,List<T>>> process(SharedBufferAccessor<T> sharedBufferAccessor, NFAState nfaState, T event, long timestamp, AfterMatchSkipStrategy afterMatchSkipStrategy, TimerService timerService) Processes the next input event.
-
Constructor Details
-
NFA
-
-
Method Details
-
getWindowTime
public long getWindowTime() -
getStates
-
createInitialNFAState
-
open
public void open(org.apache.flink.api.common.functions.RuntimeContext cepRuntimeContext, org.apache.flink.configuration.Configuration conf) throws Exception Initialization method for the NFA. It is called before any element is passed and thus suitable for one time setup work.- Parameters:
cepRuntimeContext- runtime context of the enclosing operatorconf- The configuration containing the parameters attached to the contract.- Throws:
Exception
-
close
Tear-down method for the NFA.- Throws:
Exception
-