Package ca.uqac.lif.cep.complex
Class RangeCep
- java.lang.Object
-
- ca.uqac.lif.cep.Processor
-
- ca.uqac.lif.cep.SynchronousProcessor
-
- ca.uqac.lif.cep.complex.RangeCep
-
- All Implemented Interfaces:
ca.uqac.lif.azrael.Printable
,ca.uqac.lif.azrael.Readable
,ca.uqac.lif.cep.Contextualizable
,ca.uqac.lif.cep.Duplicable
,ca.uqac.lif.cep.DuplicableProcessor
public class RangeCep extends ca.uqac.lif.cep.SynchronousProcessor
Creates complex events out of a range of simple events. The processor is parameterized by the following elements:- A processor πR outputting a stream of Boolean values, called the range processor. This processor signals the range of contiguous events of the input stream that should be taken into account in the construction of the complex event. Its expected behavior is to continually return ⊥ until the first event of the range is observed, then to output ⊤ for each event to be included in the range, and then to resume returning ⊥ forever once the range is over.
- An array of processors π1, … πn called the data processors. Each of these processors is fed the range of events identified by πR, and only those events. The calculation done by the data processors is arbitrary.
- A function f called the complex event function. This function must be of arity n:1; it is called exactly once when the end of the range is reached. Its input arguments are the last event produced by each of the πi on the event range; its output is the complex event created out of those values.
allowRestarts(boolean)
). In this case, when a complex event is produced, πR and all of the πi are reset to their initial state, which makes it possible for a new complex event to be produced with the events received from this point on.- Author:
- Sylvain Hallé
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
RangeCep.State
The current state of the range, which is updated upon receiving each input event.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_allowRestarts
A flag that determines if more than one complex event can be produced (default:false
).protected ca.uqac.lif.cep.functions.Function
m_complexEventFunction
The function that is called when the end of the range is reached, and which is used to create the complex output event.protected boolean
m_contiguous
A flag that determines if the false event that marks the end of a range should count as the first event of a new range (i.e.protected RangeCep.State
m_currentState
The current state of the range.protected ca.uqac.lif.cep.tmf.PushUnit[]
m_dataProcessors
An array of push units that evaluate the data processors.protected boolean
m_includesLast
A flag that determines if the event that determines the end boundary of the range should be included (i.e.protected ca.uqac.lif.cep.tmf.PushUnit
m_range
A push unit that evaluates the range processor.-
Fields inherited from class ca.uqac.lif.cep.SynchronousProcessor
m_inputPushables, m_outputPullables, m_tempQueue
-
Fields inherited from class ca.uqac.lif.cep.Processor
m_context, m_eventTracker, m_hasBeenNotifiedOfEndOfTrace, m_inputArity, m_inputCount, m_inputPullables, m_inputQueues, m_notifiedEndOfTraceDownstream, m_outputArity, m_outputCount, m_outputPushables, m_outputQueues, MAX_PULL_RETRIES, s_versionString
-
-
Constructor Summary
Constructors Modifier Constructor Description RangeCep(ca.uqac.lif.cep.Processor range_processor, ca.uqac.lif.cep.Processor[] data_processors, ca.uqac.lif.cep.functions.Function ce_function)
Creates a new range complex event processor.protected
RangeCep(ca.uqac.lif.cep.tmf.PushUnit range, ca.uqac.lif.cep.tmf.PushUnit[] data, ca.uqac.lif.cep.functions.Function ce_function)
Creates a new range complex event processor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RangeCep
allowRestarts(boolean b)
Sets whether the processor is allowed to produce multiple successive complex events.protected boolean
compute(java.lang.Object[] inputs, java.util.Queue<java.lang.Object[]> outputs)
RangeCep
duplicate(boolean with_state)
RangeCep
includesLast(boolean b)
Sets whether the event that determines the end boundary of the range should be included (i.e.RangeCep
isContiguous(boolean b)
Sets whether the false event that marks the end of a range should count as the first event of a new range (i.e.protected java.lang.Object
produceComplexEvent()
Produces the complex output event out of the last event output by each data processor.protected void
pushFront(java.lang.Object[] inputs)
Pushes an event front to all data processors.void
reset()
-
Methods inherited from class ca.uqac.lif.cep.SynchronousProcessor
getPullableOutput, getPushableInput, setEventTracker
-
Methods inherited from class ca.uqac.lif.cep.Processor
allNotifiedEndOfTrace, allNull, associateTo, associateToInput, associateToOutput, copyInputQueue, copyOutputQueue, duplicate, duplicateInto, equals, getAt, getContext, getContext, getEmptyQueue, getEventTracker, getId, getInputArity, getInputCount, getInputQueue, getInputType, getInputTypesFor, getLeaves, getLeaves, getOutputArity, getOutputCount, getOutputQueue, getOutputType, getPullableInput, getPullableOutput, getPushableInput, getPushableOutput, hashCode, leftShift, newContext, onEndOfTrace, or, or, print, printState, read, readState, rightShift, setContext, setContext, setPullableInput, setPushableOutput, start, startAll, stop, stopAll
-
-
-
-
Field Detail
-
m_currentState
protected RangeCep.State m_currentState
The current state of the range.
-
m_range
protected final ca.uqac.lif.cep.tmf.PushUnit m_range
A push unit that evaluates the range processor.
-
m_dataProcessors
protected final ca.uqac.lif.cep.tmf.PushUnit[] m_dataProcessors
An array of push units that evaluate the data processors.
-
m_complexEventFunction
protected final ca.uqac.lif.cep.functions.Function m_complexEventFunction
The function that is called when the end of the range is reached, and which is used to create the complex output event.
-
m_allowRestarts
protected boolean m_allowRestarts
A flag that determines if more than one complex event can be produced (default:false
).
-
m_includesLast
protected boolean m_includesLast
A flag that determines if the event that determines the end boundary of the range should be included (i.e. pushed) a part of the complex event (default:false
).
-
m_contiguous
protected boolean m_contiguous
A flag that determines if the false event that marks the end of a range should count as the first event of a new range (i.e. complex events are contiguous).
-
-
Constructor Detail
-
RangeCep
public RangeCep(ca.uqac.lif.cep.Processor range_processor, ca.uqac.lif.cep.Processor[] data_processors, ca.uqac.lif.cep.functions.Function ce_function)
Creates a new range complex event processor.- Parameters:
range_processor
- The processor used to determine the range of events to include in the complex eventdata_processors
- An array of processors evaluated on the range of eventsce_function
- The function used to create the complex output event out of the values produced by each data processor
-
RangeCep
protected RangeCep(ca.uqac.lif.cep.tmf.PushUnit range, ca.uqac.lif.cep.tmf.PushUnit[] data, ca.uqac.lif.cep.functions.Function ce_function)
Creates a new range complex event processor. This constructor is only called internally byduplicate(boolean)
.- Parameters:
range
- A push unit that evaluates the range processordata
- An array of push units that evaluate the data processorsce_function
- The function used to create the complex output event out of the values produced by each data processor
-
-
Method Detail
-
allowRestarts
public RangeCep allowRestarts(boolean b)
Sets whether the processor is allowed to produce multiple successive complex events.- Parameters:
b
- Set totrue
to allow restarts,false
otherwise- Returns:
- This processor
-
includesLast
public RangeCep includesLast(boolean b)
Sets whether the event that determines the end boundary of the range should be included (i.e. pushed) a part of the complex event.- Parameters:
b
- Set totrue
to include this last event,false
otherwise- Returns:
- This processor
-
isContiguous
public RangeCep isContiguous(boolean b)
Sets whether the false event that marks the end of a range should count as the first event of a new range (i.e. complex events are contiguous).- Parameters:
b
- Set totrue
to make complex events contiguous,false
otherwise- Returns:
- This processor
-
compute
protected boolean compute(java.lang.Object[] inputs, java.util.Queue<java.lang.Object[]> outputs)
- Specified by:
compute
in classca.uqac.lif.cep.SynchronousProcessor
-
pushFront
protected void pushFront(java.lang.Object[] inputs)
Pushes an event front to all data processors.- Parameters:
inputs
- The event front
-
produceComplexEvent
protected java.lang.Object produceComplexEvent()
Produces the complex output event out of the last event output by each data processor. This is done by fetching all these events in an array and then calling the complex event function.- Returns:
- The complex output event
-
reset
public void reset()
- Overrides:
reset
in classca.uqac.lif.cep.Processor
-
duplicate
public RangeCep duplicate(boolean with_state)
- Specified by:
duplicate
in interfaceca.uqac.lif.cep.Duplicable
- Specified by:
duplicate
in classca.uqac.lif.cep.Processor
-
-