0.10.8-alpha
ca.uqac.lif.cep.functions.ApplyFunction Class Reference

Applies a function to input events to produce output events. More...

Classes

class  ShiftTracker
 Simple tracker proxy that records associations from the underlying function, and shifts its input/output by the current position in the input/output stream. More...
 

Public Member Functions

 ApplyFunction (Function comp)
 Instantiates a new function processor. More...
 
void reset ()
 
synchronized ApplyFunction duplicate (boolean with_state)
 Duplicates an object. More...
 
final void getInputTypesFor (Set< Class<?>> classes, int index)
 
final synchronized Class<?> getOutputType (int index)
 
String toString ()
 
Function getFunction ()
 Gets the function associated to that processor. More...
 
void cloneInto (ApplyFunction af, boolean with_state)
 
Object printState ()
 
ApplyFunction readState (Object o)
 
Object getState ()
 Gets the token corresponding to the processor's internal state. More...
 
- Public Member Functions inherited from ca.uqac.lif.cep.UniformProcessor
 UniformProcessor (int in_arity, int out_arity, Context c)
 Creates a new uniform processor. More...
 
 UniformProcessor (int in_arity, int out_arity)
 Initializes a processor. More...
 
Pullable getPullableOutput (int index)
 
Pushable getPushableInput (int index)
 
- Public Member Functions inherited from ca.uqac.lif.cep.SynchronousProcessor
 SynchronousProcessor (int in_arity, int out_arity)
 Initializes a processor. More...
 
synchronized Pushable getPushableInput (int index)
 
synchronized Pullable getPullableOutput (int index)
 
final SynchronousProcessor setEventTracker (EventTracker tracker)
 
- Public Member Functions inherited from ca.uqac.lif.cep.Processor
 Processor (int in_arity, int out_arity)
 Initializes a processor. More...
 
final synchronized Object getContext (String key)
 Retrieves an object from the processor's context. More...
 
synchronized Context getContext ()
 Gets the context associated to this object. More...
 
synchronized void setContext (String key, Object value)
 Adds an object to the object's context. More...
 
synchronized void setContext (Context context)
 Adds a complete context to this object. More...
 
final int hashCode ()
 Implementation of hashCode() specific to processors. More...
 
final boolean equals (Object o)
 Implementation of equals() specific to processors. More...
 
final int getId ()
 Fetches the processor instance's unique ID. More...
 
synchronized void reset ()
 Resets the processor. More...
 
abstract Pushable getPushableInput (int index)
 Returns the Pushable corresponding to the processor's i-th input trace. More...
 
final synchronized Pushable getPushableInput ()
 Returns the Pushable corresponding to the processor's first input trace. More...
 
abstract Pullable getPullableOutput (int index)
 Returns the Pullable corresponding to the processor's i-th output trace. More...
 
final synchronized Pullable getPullableOutput ()
 Returns the Pullable corresponding to the processor's first output trace. More...
 
synchronized void setPullableInput (int i, Pullable p)
 Assigns a Pullable to the processor's i-th input. More...
 
synchronized Pullable getPullableInput (int i)
 Returns the Pullable corresponding to the processor's i-th input. More...
 
synchronized void setPushableOutput (int i, Pushable p)
 Assigns a Pushable to the processor's i-th output. More...
 
synchronized Pushable getPushableOutput (int i)
 Retrieves the Pushable associated to the processor's i-th output. More...
 
final int getInputArity ()
 Returns the processor's input arity. More...
 
final int getOutputArity ()
 Returns the processor's output arity. More...
 
void duplicateInto (Processor p)
 Copies the contents and state of the current processor into another. More...
 
final Set< Class<?> > getInputType (int index)
 Gets the type of events the processor accepts for its i-th input trace. More...
 
void getInputTypesFor (Set< Class<?>> classes, int index)
 Populates the set of classes accepted by the processor for its i-th input. More...
 
Class<?> getOutputType (int index)
 Returns the type of the events produced by the processor for its i-th output. More...
 
void start ()
 Starts the processor. More...
 
void stop ()
 Stops the processor. More...
 
final EventTracker getEventTracker ()
 Gets the instance of event tracker associated to this processor. More...
 
Processor setEventTracker (EventTracker tracker)
 Associates an event tracker to this processor. More...
 
void associateToInput (int in_stream_index, int in_stream_pos, int out_stream_index, int out_stream_pos)
 Associates an input event to an output event. More...
 
void associateTo (NodeFunction f, int out_stream_index, int out_stream_pos)
 Associates a node function to a particular event of processor's output stream. More...
 
void associateToOutput (int in_stream_index, int in_stream_pos, int out_stream_index, int out_stream_pos)
 Associates an input event to an output event. More...
 
final int getInputCount ()
 Gets the number of event fronts received so far by this processor. More...
 
final int getOutputCount ()
 Gets the number of event fronts produced so far by this processor. More...
 
final Object print (ObjectPrinter<?> printer) throws ProcessorException
 Prints the contents of this processor into an object printer. More...
 
final Processor read (ObjectReader<?> reader, Object o) throws ProcessorException
 Reads the content of a processor from a serialized object. More...
 
final Processor duplicate ()
 Duplicates an object and sets it to its initial state. More...
 
void copyInputQueue (int index, Collection< Object > to)
 Copies the content of one of the processor's input queue to a collection. More...
 
void copyOutputQueue (int index, Collection< Object > to)
 Copies the content of one of the processor's output queue to a collection. More...
 
abstract Processor duplicate (boolean with_state)
 Duplicates an object. More...
 
Processor or (Processor p)
 Connects the first output pipe of this processor to the first input pipe of another processor. More...
 
Processor or (Pushable p)
 Connects the output at index 0 of the current processor to the input of another processor. More...
 
Pushable getAt (int index)
 Gets the Pushable object corresponding to the processor's input pipe for a given index. More...
 

Protected Member Functions

boolean compute (Object[] inputs, Object[] outputs)
 
- Protected Member Functions inherited from ca.uqac.lif.cep.UniformProcessor
final boolean compute (Object[] inputs, Queue< Object[]> outputs)
 
abstract boolean compute (Object[] inputs, Object[] outputs)
 Computes one output events from its input events. More...
 
final boolean onEndOfTrace (Queue< Object[]> outputs)
 
boolean onEndOfTrace (Object[] outputs)
 Allows to describe a specific behavior when the trace of input fronts has reached its end. More...
 
- Protected Member Functions inherited from ca.uqac.lif.cep.SynchronousProcessor
abstract boolean compute (Object[] inputs, Queue< Object[]> outputs)
 Computes one or more output events from its input events. More...
 
- Protected Member Functions inherited from ca.uqac.lif.cep.Processor
boolean allNotifiedEndOfTrace ()
 Determines if all the upstream pushables have sent the end of trace notification. More...
 
final Context newContext ()
 Creates a new empty context map. More...
 
boolean onEndOfTrace (Queue< Object[]> outputs) throws ProcessorException
 Allows to describe a specific behavior when the trace of input fronts has reached its end. More...
 
Object printState ()
 Produces an object that represents the state of the current processor. More...
 
Processor readState (Object o)
 Reads the state of a processor and uses it to create a new instance. More...
 

Protected Attributes

Function m_function
 The object responsible for the computation. More...
 
ShiftTracker m_shiftTracker
 A shift tracker. More...
 
- Protected Attributes inherited from ca.uqac.lif.cep.UniformProcessor
transient Object [] m_outputArray
 An array that will be used by the processor to compute its output. More...
 
- Protected Attributes inherited from ca.uqac.lif.cep.SynchronousProcessor
final transient Queue< Object[]> m_tempQueue
 A queue object that will be passed to the compute(Object[], Queue) method. More...
 
final transient Pushable [] m_inputPushables
 An array of input pushables. More...
 
transient Pullable [] m_outputPullables
 An array of output pullables. More...
 
- Protected Attributes inherited from ca.uqac.lif.cep.Processor
int m_inputArity
 The processor's input arity, i.e. More...
 
int m_outputArity
 The processor's output arity, i.e. More...
 
transient Queue< Object > [] m_inputQueues
 An array of input event queues. More...
 
transient EventTracker m_eventTracker = null
 An object that keeps track of the relationship between input and output events. More...
 
transient Queue< Object > [] m_outputQueues
 An array of output event queues. More...
 
transient Pullable [] m_inputPullables
 An array of Pullables, one for each input trace this processor receives. More...
 
transient Pushable [] m_outputPushables
 An array of Pushables, one for each output trace this processor produces. More...
 
int m_inputCount = 0
 A counter incremented upon each input front processed. More...
 
int m_outputCount = 0
 A counter incremented upon each output front processed. More...
 
Context m_context = null
 The context in which the processor is instantiated. More...
 
boolean [] m_hasBeenNotifiedOfEndOfTrace
 Indicates whether the processor has been notified of the end of trace or not. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ca.uqac.lif.cep.Processor
static boolean allNull (Object[] v)
 Checks if all objects in the array are null. More...
 
static Queue< Object[]> getEmptyQueue ()
 Gets an instance of an empty event queue. More...
 
static void startAll (Processor ... procs)
 Starts all processors given as an argument. More...
 
static void stopAll (Processor ... procs)
 Stops all processors given as an argument. More...
 
static List< ProvenanceNode > getLeaves (ProvenanceNode root)
 Gets the leaves of a provenance tree. More...
 
- Static Public Attributes inherited from ca.uqac.lif.cep.Processor
static final transient String s_versionString = "0.10.5"
 A string used to identify the program's version. More...
 
static final transient int MAX_PULL_RETRIES = 10000000
 Number of times the Pullable#hasNext() method tries to produce an output from the input before giving up. More...
 
- Static Protected Member Functions inherited from ca.uqac.lif.cep.Processor
static void getLeaves (ProvenanceNode root, List< ProvenanceNode > leaves)
 Accumulates the leaves of a provenance tree in a list. More...
 

Detailed Description

Applies a function to input events to produce output events.

This class provides a way to "lift" any m-to-n function into an m-to-n processor, by simply calling the function on the inputs to produce the outputs.

In earlier versions of the library, this class was called FunctionProcessor.

Author
Sylvain Hallé
Since
0.2.1

Definition at line 43 of file ApplyFunction.java.

Constructor & Destructor Documentation

◆ ApplyFunction()

ca.uqac.lif.cep.functions.ApplyFunction.ApplyFunction ( Function  comp)

Instantiates a new function processor.

Parameters
compThe computable object responsible for the computation

Definition at line 62 of file ApplyFunction.java.

Member Function Documentation

◆ cloneInto()

void ca.uqac.lif.cep.functions.ApplyFunction.cloneInto ( ApplyFunction  af,
boolean  with_state 
)

Definition at line 130 of file ApplyFunction.java.

◆ compute()

boolean ca.uqac.lif.cep.functions.ApplyFunction.compute ( Object []  inputs,
Object []  outputs 
)
protected

Definition at line 77 of file ApplyFunction.java.

◆ duplicate()

synchronized ApplyFunction ca.uqac.lif.cep.functions.ApplyFunction.duplicate ( boolean  with_state)

Duplicates an object.

Optionally, set the object into the same state as the source object.

Parameters
with_stateSet to true to replicate the object's state, false to create a new copy in the initial state.
Returns
Another object

Implements ca.uqac.lif.cep.Duplicable.

Definition at line 93 of file ApplyFunction.java.

◆ getFunction()

Function ca.uqac.lif.cep.functions.ApplyFunction.getFunction ( )

Gets the function associated to that processor.

Returns
The function

Definition at line 125 of file ApplyFunction.java.

◆ getInputTypesFor()

final void ca.uqac.lif.cep.functions.ApplyFunction.getInputTypesFor ( Set< Class<?>>  classes,
int  index 
)

Definition at line 101 of file ApplyFunction.java.

◆ getOutputType()

final synchronized Class<?> ca.uqac.lif.cep.functions.ApplyFunction.getOutputType ( int  index)

Definition at line 108 of file ApplyFunction.java.

◆ getState()

Object ca.uqac.lif.cep.functions.ApplyFunction.getState ( )

Gets the token corresponding to the processor's internal state.

Returns
The token
Exceptions
UnsupportedOperationExceptionThrown if the internal state cannot be provided for some reason

Implements ca.uqac.lif.cep.Stateful.

Definition at line 231 of file ApplyFunction.java.

◆ printState()

Object ca.uqac.lif.cep.functions.ApplyFunction.printState ( )
Since
0.10.2

Definition at line 140 of file ApplyFunction.java.

◆ readState()

ApplyFunction ca.uqac.lif.cep.functions.ApplyFunction.readState ( Object  o)
Since
0.10.2

Definition at line 149 of file ApplyFunction.java.

◆ reset()

void ca.uqac.lif.cep.functions.ApplyFunction.reset ( )

Definition at line 70 of file ApplyFunction.java.

◆ toString()

String ca.uqac.lif.cep.functions.ApplyFunction.toString ( )

Definition at line 115 of file ApplyFunction.java.

Member Data Documentation

◆ m_function

Function ca.uqac.lif.cep.functions.ApplyFunction.m_function
protected

The object responsible for the computation.

Definition at line 48 of file ApplyFunction.java.

◆ m_shiftTracker

ShiftTracker ca.uqac.lif.cep.functions.ApplyFunction.m_shiftTracker
protected

A shift tracker.

Since
0.10.3

Definition at line 54 of file ApplyFunction.java.


The documentation for this class was generated from the following file: