0.10.8-alpha
|
Receives zero or more input events, and produces zero or more output events. More...
Classes | |
class | InternalProcessorState |
An object capturing the internal state of a processor, including the current contents of its input and output queues. More... | |
Public Member Functions | |
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... | |
Static Public Member Functions | |
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 | |
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... | |
Protected Member Functions | |
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... | |
Static Protected Member Functions | |
static void | getLeaves (ProvenanceNode root, List< ProvenanceNode > leaves) |
Accumulates the leaves of a provenance tree in a list. More... | |
Protected Attributes | |
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... | |
Receives zero or more input events, and produces zero or more output events.
The processor is the fundamental class where all computation occurs. All of BeepBeep's processors (including yours) are descendants of this class.
A processor is depicted graphically as a "box", with "pipes" representing its input and output streams.
This class itself is abstract; nevertheless, it provides important methods for handling input/output event queues, connecting processors together, etc. However, if you write your own processor, you will most likely want to inherit from its child, SynchronousProcessor, which does some more work for you.
The Processor class does not assume anything about the type of events being input or output. All its input and output queues are therefore declared as containing instances of Object
, Java's most generic type.
Definition at line 68 of file Processor.java.
ca.uqac.lif.cep.Processor.Processor | ( | int | in_arity, |
int | out_arity | ||
) |
Initializes a processor.
This has for effect of executing the basic operations common to every processor:
If you create your own processor, its constructor must start by calling its ancestor's constructor (which ultimately ends up calling this constructor). Otherwise, expect a plethora of null pointers and other oddities.
in_arity | The processor's input arity |
out_arity | The processor's output arity |
Definition at line 190 of file Processor.java.
|
protected |
Determines if all the upstream pushables have sent the end of trace notification.
Definition at line 223 of file Processor.java.
|
static |
Checks if all objects in the array are null.
This is a convenience method used by other processor classes (e.g. SynchronousProcessor to make sure that some output was generated from a given input
v | The array |
true
if all elements in the array are null, false
otherwise Definition at line 506 of file Processor.java.
void ca.uqac.lif.cep.Processor.associateTo | ( | NodeFunction | f, |
int | out_stream_index, | ||
int | out_stream_pos | ||
) |
Associates a node function to a particular event of processor's output stream.
f | The node function |
out_stream_index | The index of the processor's output stream |
out_stream_pos | The position of the event in the output stream |
Definition at line 716 of file Processor.java.
void ca.uqac.lif.cep.Processor.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.
in_stream_index | The index of the processor's input stream |
in_stream_pos | The position of the event in the input stream |
out_stream_index | The index of the processor's output stream |
out_stream_pos | The position of the event in the output stream |
Definition at line 699 of file Processor.java.
void ca.uqac.lif.cep.Processor.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.
in_stream_index | The index of the processor's input stream |
in_stream_pos | The position of the event in the input stream |
out_stream_index | The index of the processor's output stream |
out_stream_pos | The position of the event in the output stream |
Definition at line 731 of file Processor.java.
void ca.uqac.lif.cep.Processor.copyInputQueue | ( | int | index, |
Collection< Object > | to | ||
) |
Copies the content of one of the processor's input queue to a collection.
index | The index of the input queue |
to | The collection where queue contents are copied to |
Definition at line 913 of file Processor.java.
void ca.uqac.lif.cep.Processor.copyOutputQueue | ( | int | index, |
Collection< Object > | to | ||
) |
Copies the content of one of the processor's output queue to a collection.
index | The index of the output queue |
to | The collection where queue contents are copied to |
Definition at line 924 of file Processor.java.
final Processor ca.uqac.lif.cep.Processor.duplicate | ( | ) |
Duplicates an object and sets it to its initial state.
This should be the same thing as calling duplicate(false)
.
Implements ca.uqac.lif.cep.DuplicableProcessor.
Definition at line 902 of file Processor.java.
|
abstract |
Duplicates an object.
Optionally, set the object into the same state as the source object.
with_state | Set to true to replicate the object's state, false to create a new copy in the initial state. |
Implements ca.uqac.lif.cep.Duplicable.
void ca.uqac.lif.cep.Processor.duplicateInto | ( | Processor | p | ) |
Copies the contents and state of the current processor into another.
p | The processor to copy contents into |
Definition at line 524 of file Processor.java.
final boolean ca.uqac.lif.cep.Processor.equals | ( | Object | o | ) |
Implementation of equals() specific to processors.
Since every processor has a unique ID, equality amounts to equality of the field m_uniqueId. This behavior cannot be overridden by descendants.
Definition at line 320 of file Processor.java.
Pushable ca.uqac.lif.cep.Processor.getAt | ( | int | index | ) |
Gets the Pushable object corresponding to the processor's input pipe for a given index.
Java programmers probably won't use this method, but users of the Groovy language can benefit from its operator overloading conventions, which map the construct p[x]
to p.getAt(x)
. Combined with the definition of or(Pushable), this can be used to easily pipe two processors together:
def p = (some processor)
def q = (some other processor)
p | q[1] // Connects p to pipe index 1 of q
index | The input pipe index |
Definition at line 1039 of file Processor.java.
final synchronized Object ca.uqac.lif.cep.Processor.getContext | ( | String | key | ) |
Retrieves an object from the processor's context.
key | The key associated to that object |
null
if no object exists with such key Definition at line 252 of file Processor.java.
synchronized Context ca.uqac.lif.cep.Processor.getContext | ( | ) |
Gets the context associated to this object.
Implements ca.uqac.lif.cep.Contextualizable.
Definition at line 262 of file Processor.java.
|
static |
Gets an instance of an empty event queue.
It is recommended that processors call this method to get a queue instance, rather than instantiate their own manually.
Definition at line 610 of file Processor.java.
final EventTracker ca.uqac.lif.cep.Processor.getEventTracker | ( | ) |
Gets the instance of event tracker associated to this processor.
null
of no event tracker is associated to this processor Definition at line 673 of file Processor.java.
final int ca.uqac.lif.cep.Processor.getId | ( | ) |
Fetches the processor instance's unique ID.
Definition at line 335 of file Processor.java.
final int ca.uqac.lif.cep.Processor.getInputArity | ( | ) |
Returns the processor's input arity.
Definition at line 481 of file Processor.java.
final int ca.uqac.lif.cep.Processor.getInputCount | ( | ) |
Gets the number of event fronts received so far by this processor.
Definition at line 766 of file Processor.java.
final Set<Class<?> > ca.uqac.lif.cep.Processor.getInputType | ( | int | index | ) |
Gets the type of events the processor accepts for its i-th input trace.
Note that this method returns a set, in the case where the processor accepts various types of objects (for example, a processor accepting Number
s, but also String
s it converts into numbers internally).
index | The index of the input to query |
index
it less than 0 or greater than the processor's declared input arity, the set will be empty. Definition at line 551 of file Processor.java.
void ca.uqac.lif.cep.Processor.getInputTypesFor | ( | Set< Class<?>> | classes, |
int | index | ||
) |
Populates the set of classes accepted by the processor for its i-th input.
By default, a processor returns the Connector.Variant type for all its inputs and all its outputs, meaning that the checking of types in Connector#connect(Processor...) will be skipped. A descendant of this class may choose to define specific types for its input and output, thereby activating runtime type checking.
classes | The set of to fill with classes |
index | The index of the input to query |
Definition at line 576 of file Processor.java.
|
static |
Gets the leaves of a provenance tree.
root | The root of the tree |
Definition at line 937 of file Processor.java.
|
staticprotected |
Accumulates the leaves of a provenance tree in a list.
root | The current node in the tree |
leaves | The list of leaves |
Definition at line 949 of file Processor.java.
final int ca.uqac.lif.cep.Processor.getOutputArity | ( | ) |
Returns the processor's output arity.
Definition at line 491 of file Processor.java.
final int ca.uqac.lif.cep.Processor.getOutputCount | ( | ) |
Gets the number of event fronts produced so far by this processor.
Definition at line 775 of file Processor.java.
Class<?> ca.uqac.lif.cep.Processor.getOutputType | ( | int | index | ) |
Returns the type of the events produced by the processor for its i-th output.
By default, a processor returns the Connector.Variant type for all its inputs and all its outputs, meaning that the checking of types in Connector#connect(Processor...) will be skipped. A descendant of this class may choose to define specific types for its input and output, thereby activating runtime type checking.
index | The index of the output to query |
index
it less than 0 or greater than the processor's declared output arity, this method may throw an IndexOutOfBoundsException. Definition at line 598 of file Processor.java.
synchronized Pullable ca.uqac.lif.cep.Processor.getPullableInput | ( | int | i | ) |
Returns the Pullable corresponding to the processor's i-th input.
i | The index of the input. Should be greater than 0 and less than the processor's output arity. Outside these bounds, an ArrayIndexOutOfBounds will be thrown. |
Definition at line 441 of file Processor.java.
|
abstract |
Returns the Pullable corresponding to the processor's i-th output trace.
index | The index. Should be between 0 and the processor's output arity - 1 (since indices start at 0). |
null
otherwise. final synchronized Pullable ca.uqac.lif.cep.Processor.getPullableOutput | ( | ) |
Returns the Pullable corresponding to the processor's first output trace.
Definition at line 412 of file Processor.java.
|
abstract |
Returns the Pushable corresponding to the processor's i-th input trace.
index | The index. Should be between 0 and the processor's input arity - 1 (since indices start at 0). |
final synchronized Pushable ca.uqac.lif.cep.Processor.getPushableInput | ( | ) |
Returns the Pushable corresponding to the processor's first input trace.
Definition at line 387 of file Processor.java.
synchronized Pushable ca.uqac.lif.cep.Processor.getPushableOutput | ( | int | i | ) |
Retrieves the Pushable associated to the processor's i-th output.
i | The index of the output. Should be greater than 0 (not checked) and less than the processor's output arity. Outside these bounds, an ArrayIndexOutOfBounds will be thrown. |
Definition at line 471 of file Processor.java.
final int ca.uqac.lif.cep.Processor.hashCode | ( | ) |
Implementation of hashCode() specific to processors.
Every processor instance in BeepBeep is given a unique ID; even a clone of a processor (created using Processor#duplicate() will be identical to the original, except for this ID. This behavior cannot be overridden by descendants.
Definition at line 308 of file Processor.java.
|
protected |
Creates a new empty context map.
Definition at line 240 of file Processor.java.
|
protected |
Allows to describe a specific behavior when the trace of input fronts has reached its end.
Called in "push mode" only. In "pull mode", implementing such a behavior can be done by using Pullable#hasNext() or Pullable#hasNextSoft().
outputs | A queue of arrays of objects. The processor should push arrays into this queue for every output front it produces. The size of each array should be equal to the processor's output arity, although this is not enforced. |
ProcessorException | An exception thrown when a problem occurs with the operation |
Definition at line 757 of file Processor.java.
Connects the first output pipe of this processor to the first input pipe of another processor.
Java programmers probably won't use this method, but users of the Groovy language can benefit from its operator overloading conventions, which map the construct p | q
to p.or(q)
. This can be used to easily pipe two processors together:
def p = (some processor)
def q = (some other processor)
p | q // Connects p to q
p | The other processor |
Definition at line 986 of file Processor.java.
Connects the output at index 0 of the current processor to the input of another processor.
Java programmers probably won't use this method. However, combined with the definition of getAt(int), users of the Groovy language can benefit from its operator overloading conventions, which map the construct p | q
to p.or(q)
. This can be used to easily pipe two processors together:
def p = (some processor)
def q = (some other processor)
p | q[1] // Connects p to pipe index 1 of q
The above example works because q[1]
returns q
's input pushable for pipe index 1.
p | The pushable object representing the input of the other processor to which the current output should be connected. |
Definition at line 1013 of file Processor.java.
final Object ca.uqac.lif.cep.Processor.print | ( | ObjectPrinter<?> | printer | ) | throws ProcessorException |
Prints the contents of this processor into an object printer.
printer | The printer to print this processor to |
Definition at line 787 of file Processor.java.
|
protected |
Produces an object that represents the state of the current processor.
A concrete processor should override this method to add whatever state information that needs to be preserved in the serialization process.
null
) Definition at line 825 of file Processor.java.
final Processor ca.uqac.lif.cep.Processor.read | ( | ObjectReader<?> | reader, |
Object | o | ||
) | throws ProcessorException |
Reads the content of a processor from a serialized object.
reader | An object reader |
o | The object to read from |
ProcessorException | If the read operation failed for some reason |
Definition at line 839 of file Processor.java.
|
protected |
Reads the state of a processor and uses it to create a new instance.
o | The object containing the processor's state |
Definition at line 896 of file Processor.java.
synchronized void ca.uqac.lif.cep.Processor.reset | ( | ) |
Resets the processor.
This has for effect of flushing the contents of all input and output event queues. If the processor has an internal state, this should also reset this state to its "initial" settings (whatever that means in your context).
Definition at line 346 of file Processor.java.
synchronized void ca.uqac.lif.cep.Processor.setContext | ( | String | key, |
Object | value | ||
) |
Adds an object to the object's context.
key | The key associated to that object |
value | The object |
Implements ca.uqac.lif.cep.Contextualizable.
Definition at line 274 of file Processor.java.
synchronized void ca.uqac.lif.cep.Processor.setContext | ( | Context | context | ) |
Adds a complete context to this object.
context | The context to add |
Implements ca.uqac.lif.cep.Contextualizable.
Definition at line 286 of file Processor.java.
Processor ca.uqac.lif.cep.Processor.setEventTracker | ( | EventTracker | tracker | ) |
Associates an event tracker to this processor.
tracker | The event tracker, or null to remove the association to an existing tracker |
Definition at line 686 of file Processor.java.
synchronized void ca.uqac.lif.cep.Processor.setPullableInput | ( | int | i, |
Pullable | p | ||
) |
Assigns a Pullable to the processor's i-th input.
i | The index of the input. An ArrayIndexOutOfBounds will be thrown if it is out of range. |
p | The pullable to assign it to |
Definition at line 426 of file Processor.java.
synchronized void ca.uqac.lif.cep.Processor.setPushableOutput | ( | int | i, |
Pushable | p | ||
) |
Assigns a Pushable to the processor's i-th output.
i | The index of the output. Should be greater than 0 and less than the processor's output arity. Outside these bounds, an ArrayIndexOutOfBounds will be thrown. |
p | The pushable to assign it to |
Definition at line 456 of file Processor.java.
void ca.uqac.lif.cep.Processor.start | ( | ) |
Starts the processor.
This has no effect, except for processors that use threads; in such a case, calling this method should start the thread.
Definition at line 619 of file Processor.java.
|
static |
Starts all processors given as an argument.
procs | The processors |
Definition at line 639 of file Processor.java.
void ca.uqac.lif.cep.Processor.stop | ( | ) |
Stops the processor.
This has no effect, except for processors that use threads; in such a case, calling this method should stop the thread.
Definition at line 628 of file Processor.java.
|
static |
Stops all processors given as an argument.
procs | The processors |
Definition at line 656 of file Processor.java.
|
protected |
The context in which the processor is instantiated.
Definition at line 149 of file Processor.java.
|
protected |
An object that keeps track of the relationship between input and output events.
Definition at line 98 of file Processor.java.
|
protected |
Indicates whether the processor has been notified of the end of trace or not.
Each input pushable has its own flag, and the end of trace signal is propagated only once all upstream processors have sent the notification.
Definition at line 165 of file Processor.java.
|
protected |
The processor's input arity, i.e.
the number of input events it requires to produce an output
Definition at line 75 of file Processor.java.
|
protected |
A counter incremented upon each input front processed.
Definition at line 122 of file Processor.java.
|
protected |
An array of Pullables, one for each input trace this processor receives.
Definition at line 111 of file Processor.java.
|
protected |
An array of input event queues.
This is where the input events will be stored before the processor consumes them. There are as many input queues as the input arity of the processor.
Definition at line 92 of file Processor.java.
|
protected |
The processor's output arity, i.e.
the number of output events it produces
Definition at line 80 of file Processor.java.
|
protected |
A counter incremented upon each output front processed.
Definition at line 127 of file Processor.java.
|
protected |
An array of Pushables, one for each output trace this processor produces.
Definition at line 117 of file Processor.java.
|
protected |
An array of output event queues.
This is where the output events will be stored when the processor does its computation. There are as many output queues as the output arity of the processor.
Definition at line 105 of file Processor.java.
|
static |
Number of times the Pullable#hasNext() method tries to produce an output from the input before giving up.
While in theory, the method tries "as long as necessary", in practice a bound was put on the number of attempts as a safeguard to avoid infinite loops.
Definition at line 157 of file Processor.java.
|
static |
A string used to identify the program's version.
Definition at line 85 of file Processor.java.