![]() |
0.11.4
|
Queries events on one of a processor's outputs.
For a processor with an output arity n, there exists n distinct pullables, namely one for each output pipe. Every pullable works roughly like a classical Iterator: it is possible to check whether new output events are available, and get one new output event.
However, contrarily to iterators, Pullables have two versions of each method: a soft and a hard version.
hasNextSoft() will return a special value (MAYBE), and pullSoft() will return null. Soft methods can be seen a doing "one turn of the crank" on the whole chain of processors –whether or not this outputs something. pull() may consume more than one event from a processor's input. Therefore, calls to hasNext() never return MAYBE (only YES or NO), and pull() throws NoSuchElementException only if no event will ever be output in the future (this occurs, for example, when pulling events from a file, and the end of the file has been reached). The lifecycle of a Pullable object is as follows:
Processor#getPullableOutput(int), or implicitly, for example through every call to Connector#connect(Processor...). hasNextSoft() (or hasNext() to check if events are available - One calls pullSoft() (or pull() to produce the next available output event. The Pullable interface extends the Iterator and Iterable interfaces. This means that an instance of Pullable can also be iterated over like this:
Pullable p = ...; for (Object o : p) { // Do something }
Note however that if p refers to a processor producing an infinite number of events, this loop will never terminate by itself.
For the same processor, mixing calls to soft and hard methods is discouraged. As a matter of fact, the Pullable's behaviour in such a situation is left undefined.
Definition at line 85 of file Pullable.java.
Classes | |
| class | PullableException |
| A runtime exception indicating that something went wrong when attempting to check if a next event exists. More... | |
| class | PullNotSupported |
Pullable object that throws an UnsupportedOperationException upon every call to each of its methods (except getProcessor()). More... | |
| enum | NextStatus |
The "next" status of a Pullable object. More... | |
Public Member Functions | |
| Object | pullSoft () |
| Attempts to pull an event from the source. | |
| Object | pull () |
| Attempts to pull an event from the source. | |
| Object | next () |
| Attempts to obtain an event from the source. | |
| NextStatus | hasNextSoft () |
| Determines if an event can be pulled from the output. | |
| boolean | hasNext () |
Determines if an event can be pulled from the output, by trying "harder" than hasNextSoft(). | |
| Processor | getProcessor () |
| Gets the processor instance this Pullable is linked to. | |
| int | getPosition () |
| Gets the position this Pullable is associated to: 0 is the first input (or output), 1 the second, etc. | |
| void | start () |
| Starts the pullable. | |
| void | stop () |
| Stops the pullable. | |
| void | dispose () |
Tells this pullable that methods pull(), pullSoft(), hasNext() and hasNextSoft() will not be called anymore. | |
| void ca.uqac.lif.cep.Pullable.dispose | ( | ) |
Tells this pullable that methods pull(), pullSoft(), hasNext() and hasNextSoft() will not be called anymore.
For some types of pullables, this can be used as a cue to free some resources (such as threads). The behaviour of these four methods after dispose() has been called is undefined. In future versions, it is possible that an exception will be thrown in such a case.
Implemented in ca.uqac.lif.cep.AsynchronousProcessor.OutputPullable, ca.uqac.lif.cep.functions.ApplyFunctionPartial.OutputPullable, ca.uqac.lif.cep.GroupProcessor.ProxyPullable, ca.uqac.lif.cep.Pullable.PullNotSupported, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable, ca.uqac.lif.cep.tmf.Divert.DivertPullable, ca.uqac.lif.cep.tmf.Multiplex.MuxPullable, ca.uqac.lif.cep.tmf.Tank.QueuePullable, ca.uqac.lif.cep.TypedPullable< T >, and ca.uqac.lif.cep.UniformProcessor.UnaryPullable.
| int ca.uqac.lif.cep.Pullable.getPosition | ( | ) |
Gets the position this Pullable is associated to: 0 is the first input (or output), 1 the second, etc.
Implemented in ca.uqac.lif.cep.AsynchronousProcessor.OutputPullable, ca.uqac.lif.cep.functions.ApplyFunctionPartial.OutputPullable, ca.uqac.lif.cep.GroupProcessor.ProxyPullable, ca.uqac.lif.cep.Pullable.PullNotSupported, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable, ca.uqac.lif.cep.tmf.Divert.DivertPullable, ca.uqac.lif.cep.tmf.Multiplex.MuxPullable, ca.uqac.lif.cep.tmf.Tank.QueuePullable, ca.uqac.lif.cep.TypedPullable< T >, and ca.uqac.lif.cep.UniformProcessor.UnaryPullable.
| Processor ca.uqac.lif.cep.Pullable.getProcessor | ( | ) |
Gets the processor instance this Pullable is linked to.
Implemented in ca.uqac.lif.cep.AsynchronousProcessor.OutputPullable, ca.uqac.lif.cep.functions.ApplyFunctionPartial.OutputPullable, ca.uqac.lif.cep.GroupProcessor.ProxyPullable, ca.uqac.lif.cep.Pullable.PullNotSupported, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable, ca.uqac.lif.cep.tmf.Divert.DivertPullable, ca.uqac.lif.cep.tmf.Multiplex.MuxPullable, ca.uqac.lif.cep.tmf.Tank.QueuePullable, ca.uqac.lif.cep.TypedPullable< T >, and ca.uqac.lif.cep.UniformProcessor.UnaryPullable.
| boolean ca.uqac.lif.cep.Pullable.hasNext | ( | ) |
Determines if an event can be pulled from the output, by trying "harder" than hasNextSoft().
Depending on what happens, the possible return values are:
hasNextSoft(), returns "no" hasNextSoft(), and an event is produced with the given inputs, returns "yes" hasNext() on the inputs as long as they don't answer "no", and will try to produce an output event until one is produced. Processor#MAX_PULL_RETRIES. Implemented in ca.uqac.lif.cep.AsynchronousProcessor.OutputPullable, ca.uqac.lif.cep.functions.ApplyFunctionPartial.OutputPullable, ca.uqac.lif.cep.GroupProcessor.ProxyPullable, ca.uqac.lif.cep.Pullable.PullNotSupported, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable, ca.uqac.lif.cep.tmf.Divert.DivertPullable, ca.uqac.lif.cep.tmf.Insert.InsertPullable, ca.uqac.lif.cep.tmf.Multiplex.MuxPullable, ca.uqac.lif.cep.tmf.Tank.QueuePullable, ca.uqac.lif.cep.TypedPullable< T >, and ca.uqac.lif.cep.UniformProcessor.UnaryPullable.
| NextStatus ca.uqac.lif.cep.Pullable.hasNextSoft | ( | ) |
Determines if an event can be pulled from the output.
Depending on what happens, the possible return values are:
hasNextSoft(), returns "no" hasNextSoft(), returns "maybe" hasNextSoft(), but no event is produced with the given inputs, returns "maybe" Therefore, the method is lazy in that it asks events from its input only once, and attempts to produce an output event only once.
Implemented in ca.uqac.lif.cep.AsynchronousProcessor.OutputPullable, ca.uqac.lif.cep.functions.ApplyFunctionPartial.OutputPullable, ca.uqac.lif.cep.GroupProcessor.ProxyPullable, ca.uqac.lif.cep.Pullable.PullNotSupported, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable, ca.uqac.lif.cep.tmf.Divert.DivertPullable, ca.uqac.lif.cep.tmf.Multiplex.MuxPullable, ca.uqac.lif.cep.tmf.Tank.QueuePullable, ca.uqac.lif.cep.TypedPullable< T >, and ca.uqac.lif.cep.UniformProcessor.UnaryPullable.
| Object ca.uqac.lif.cep.Pullable.next | ( | ) |
Attempts to obtain an event from the source.
An event is returned if hasNext() returns YES, and java.util.NoSuchElementException is thrown otherwise.
| java.util.NoSuchElementException | if the iteration has no more elements |
Implemented in ca.uqac.lif.cep.AsynchronousProcessor.OutputPullable, ca.uqac.lif.cep.functions.ApplyFunctionPartial.OutputPullable, ca.uqac.lif.cep.GroupProcessor.ProxyPullable, ca.uqac.lif.cep.Pullable.PullNotSupported, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable, ca.uqac.lif.cep.tmf.Divert.DivertPullable, ca.uqac.lif.cep.tmf.Multiplex.MuxPullable, ca.uqac.lif.cep.tmf.Tank.QueuePullable, ca.uqac.lif.cep.TypedPullable< T >, and ca.uqac.lif.cep.UniformProcessor.UnaryPullable.
| Object ca.uqac.lif.cep.Pullable.pull | ( | ) |
Attempts to pull an event from the source.
An event is returned if hasNext() returns YES, and java.util.NoSuchElementException is thrown otherwise.
| java.util.NoSuchElementException | if the iteration has no more elements |
Implemented in ca.uqac.lif.cep.AsynchronousProcessor.OutputPullable, ca.uqac.lif.cep.functions.ApplyFunctionPartial.OutputPullable, ca.uqac.lif.cep.GroupProcessor.ProxyPullable, ca.uqac.lif.cep.Pullable.PullNotSupported, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable, ca.uqac.lif.cep.tmf.Divert.DivertPullable, ca.uqac.lif.cep.tmf.Multiplex.MuxPullable, ca.uqac.lif.cep.tmf.Tank.QueuePullable, ca.uqac.lif.cep.TypedPullable< T >, and ca.uqac.lif.cep.UniformProcessor.UnaryPullable.
| Object ca.uqac.lif.cep.Pullable.pullSoft | ( | ) |
Attempts to pull an event from the source.
An event is returned if hasNextSoft() returns YES, and null is returned otherwise.
null if none could be retrieved Implemented in ca.uqac.lif.cep.AsynchronousProcessor.OutputPullable, ca.uqac.lif.cep.functions.ApplyFunctionPartial.OutputPullable, ca.uqac.lif.cep.GroupProcessor.ProxyPullable, ca.uqac.lif.cep.Pullable.PullNotSupported, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable, ca.uqac.lif.cep.tmf.Divert.DivertPullable, ca.uqac.lif.cep.tmf.Multiplex.MuxPullable, ca.uqac.lif.cep.tmf.Tank.QueuePullable, ca.uqac.lif.cep.TypedPullable< T >, and ca.uqac.lif.cep.UniformProcessor.UnaryPullable.
| void ca.uqac.lif.cep.Pullable.start | ( | ) |
Starts the pullable.
This may be useful for multi-threaded pullables.
Implemented in ca.uqac.lif.cep.AsynchronousProcessor.OutputPullable, ca.uqac.lif.cep.functions.ApplyFunctionPartial.OutputPullable, ca.uqac.lif.cep.GroupProcessor.ProxyPullable, ca.uqac.lif.cep.Pullable.PullNotSupported, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable, ca.uqac.lif.cep.tmf.Divert.DivertPullable, ca.uqac.lif.cep.tmf.Multiplex.MuxPullable, ca.uqac.lif.cep.tmf.Tank.QueuePullable, ca.uqac.lif.cep.TypedPullable< T >, and ca.uqac.lif.cep.UniformProcessor.UnaryPullable.
| void ca.uqac.lif.cep.Pullable.stop | ( | ) |
Stops the pullable.
This may be useful for multi-threaded pullables.
Implemented in ca.uqac.lif.cep.AsynchronousProcessor.OutputPullable, ca.uqac.lif.cep.functions.ApplyFunctionPartial.OutputPullable, ca.uqac.lif.cep.GroupProcessor.ProxyPullable, ca.uqac.lif.cep.Pullable.PullNotSupported, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable, ca.uqac.lif.cep.tmf.Divert.DivertPullable, ca.uqac.lif.cep.tmf.Multiplex.MuxPullable, ca.uqac.lif.cep.tmf.Tank.QueuePullable, ca.uqac.lif.cep.TypedPullable< T >, and ca.uqac.lif.cep.UniformProcessor.UnaryPullable.