T
- Type of the processed eventspublic class NFA<T> extends Object implements Serializable
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.NFASerializer<T>
A
TypeSerializer for NFA that uses Java Serialization. |
static class |
NFA.NFASerializerConfigSnapshot<T>
The
TypeSerializerConfigSnapshot serializer configuration to be stored with the managed state. |
Constructor and Description |
---|
NFA(TypeSerializer<T> eventSerializer,
long windowTime,
boolean handleTimeout) |
Modifier and Type | Method and Description |
---|---|
void |
addState(State<T> state) |
void |
addStates(Collection<State<T>> newStates) |
boolean |
equals(Object obj) |
Set<State<T>> |
getStates() |
int |
hashCode() |
boolean |
isEmpty()
Check if the NFA has finished processing all incoming data so far.
|
boolean |
isNFAChanged()
Check if the matching status of the NFA has changed so far.
|
Tuple2<Collection<Map<String,List<T>>>,Collection<Tuple2<Map<String,List<T>>,Long>>> |
process(T event,
long timestamp)
Processes the next input event.
|
Tuple2<Collection<Map<String,List<T>>>,Collection<Tuple2<Map<String,List<T>>,Long>>> |
process(T event,
long timestamp,
AfterMatchSkipStrategy afterMatchSkipStrategy)
Processes the next input event.
|
void |
resetNFAChanged()
Reset
nfaChanged to false . |
public NFA(TypeSerializer<T> eventSerializer, long windowTime, boolean handleTimeout)
public void addStates(Collection<State<T>> newStates)
public boolean isEmpty()
true
if there are no elements in the SharedBuffer
,
false
otherwise.public boolean isNFAChanged()
true
if matching status has changed, false
otherwisepublic void resetNFAChanged()
nfaChanged
to false
.public Tuple2<Collection<Map<String,List<T>>>,Collection<Tuple2<Map<String,List<T>>,Long>>> process(T event, long timestamp)
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.
event
- The current event to be processed or null if only pruning shall be donetimestamp
- The timestamp of the current eventpublic Tuple2<Collection<Map<String,List<T>>>,Collection<Tuple2<Map<String,List<T>>,Long>>> process(T event, long timestamp, AfterMatchSkipStrategy afterMatchSkipStrategy)
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.
event
- 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 matchCopyright © 2014–2018 The Apache Software Foundation. All rights reserved.