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.
|
Constructor and Description |
---|
NFA(Collection<State<T>> validStates,
Map<String,Long> windowTimes,
long windowTime,
boolean handleTimeout) |
Modifier and Type | Method and Description |
---|---|
Tuple2<Collection<Map<String,List<T>>>,Collection<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.
|
void |
close()
Tear-down method for the NFA.
|
NFAState |
createInitialNFAState() |
Collection<State<T>> |
getStates() |
long |
getWindowTime() |
void |
open(RuntimeContext cepRuntimeContext,
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 long getWindowTime()
@VisibleForTesting public Collection<State<T>> getStates()
public NFAState createInitialNFAState()
public void open(RuntimeContext cepRuntimeContext, Configuration conf) throws Exception
cepRuntimeContext
- runtime context of the enclosing operatorconf
- The configuration containing the parameters attached to the contract.Exception
public 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 Tuple2<Collection<Map<String,List<T>>>,Collection<Tuple2<Map<String,List<T>>,Long>>> advanceTime(SharedBufferAccessor<T> sharedBufferAccessor, NFAState nfaState, long timestamp, AfterMatchSkipStrategy afterMatchSkipStrategy) 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–2023 The Apache Software Foundation. All rights reserved.