T - Type of the processed eventspublic class NFA<T> extends Object
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:
The implementation is strongly based on the paper "Efficient Pattern Matching over Event Streams".
| Modifier and Type | Class and Description |
|---|---|
static class |
NFA.MigratedNFA<T>
Wrapper for migrated state.
|
static class |
NFA.MigratedNFASerializerSnapshot<T>
A
TypeSerializerSnapshot for the legacy NFA.NFASerializer. |
static class |
NFA.NFASerializer<T>
Deprecated.
|
static class |
NFA.NFASerializerConfigSnapshot<T>
Deprecated.
This snapshot class is no longer in use, and only maintained for backwards
compatibility purposes. It is fully replaced by
NFA.MigratedNFASerializerSnapshot. |
| Constructor and Description |
|---|
NFA(Collection<State<T>> validStates,
long windowTime,
boolean handleTimeout) |
| Modifier and Type | Method and Description |
|---|---|
Collection<org.apache.flink.api.java.tuple.Tuple2<Map<String,List<T>>,Long>> |
advanceTime(SharedBufferAccessor<T> sharedBufferAccessor,
NFAState nfaState,
long timestamp)
Prunes states assuming there will be no events with timestamp lower than the given
one.
|
void |
close()
Tear-down method for the NFA.
|
NFAState |
createInitialNFAState() |
Collection<State<T>> |
getStates() |
void |
open(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.
|
public NFA(Collection<State<T>> validStates, long windowTime, boolean handleTimeout)
@VisibleForTesting public Collection<State<T>> getStates()
public NFAState createInitialNFAState()
public void open(org.apache.flink.api.common.functions.RuntimeContext cepRuntimeContext,
org.apache.flink.configuration.Configuration conf)
throws Exception
cepRuntimeContext - runtime context of the enclosing operatorconf - The configuration containing the parameters attached to the contract.Exceptionpublic Collection<Map<String,List<T>>> process(SharedBufferAccessor<T> sharedBufferAccessor, NFAState nfaState, T event, long timestamp, AfterMatchSkipStrategy afterMatchSkipStrategy, TimerService timerService) throws Exception
If computations reach a stop state, the path forward is discarded and currently constructed path is returned with the element that resulted in the stop state.
sharedBufferAccessor - the accessor to SharedBuffer object that we need to work upon
while processingnfaState - The NFAState object that we need to affect while processingevent - The current event to be processed or null if only pruning shall be donetimestamp - The timestamp of the current eventafterMatchSkipStrategy - The skip strategy to use after per matchtimerService - gives access to processing time and time characteristic, needed for
condition evaluationException - Thrown if the system cannot access the state.public Collection<org.apache.flink.api.java.tuple.Tuple2<Map<String,List<T>>,Long>> advanceTime(SharedBufferAccessor<T> sharedBufferAccessor, NFAState nfaState, long timestamp) throws Exception
sharedBufferAccessor - the accessor to SharedBuffer object that we need to work upon
while processingnfaState - The NFAState object that we need to affect while processingtimestamp - timestamp that indicates that there will be no more events with lower
timestampException - Thrown if the system cannot access the state.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.