com.rapidminer.operator
Class ExecutionUnit

java.lang.Object
  extended by com.rapidminer.tools.AbstractObservable<ExecutionUnit>
      extended by com.rapidminer.operator.ExecutionUnit
All Implemented Interfaces:
Observable<ExecutionUnit>

public class ExecutionUnit
extends AbstractObservable<ExecutionUnit>

A process is a collection of operators whose ports can be wired. A process provides input and output ports to its contained operators. ExecutionUnit replaces the legacy OperatorChain. This class takes care of executing the operators in the correct order by sorting them topologically with respect to their dependencies.

Author:
Simon Fischer

Constructor Summary
ExecutionUnit(OperatorChain enclosingOperator, java.lang.String name)
           
 
Method Summary
 int addOperator(Operator operator)
          Same as addOperator(Operator, boolean).
 int addOperator(Operator operator, boolean registerWithProcess)
          Adds the operator to this execution unit.
 void addOperator(Operator operator, int index)
          Adds the operator to this execution unit.
 void autoWire(CompatibilityLevel level, boolean keepConnections, boolean recursive)
          Connects the ports automatically in a first-fit approach.
 void autoWireSingle(Operator operator, CompatibilityLevel level, boolean inputs, boolean outputs)
          Automatically wires inputs and outputs of a single operator in this execution unit.
 void bringToFront(java.util.Collection<Operator> movedOperators, Operator insertAfter)
          Re-arranges the execution order such that the specified operators immediately follow insertAfter.
 void clear(int clearFlags)
           
 void cloneExecutionUnitFrom(ExecutionUnit original, boolean forParallelExecution)
          Clones operators contained in original, adds them to this execution unit and wires them as they were originally.
protected  java.lang.String createProcessTree(int indent, java.lang.String selfPrefix, java.lang.String childPrefix, Operator markOperator, java.lang.String mark)
           
 void execute()
          Executes the inner operators.
 void freeMemory()
          Frees memory used by inner sinks.
 java.util.List<Operator> getAllInnerOperators()
          Recursively returns all nested operators.
 java.util.Collection<OutputPort> getAllOutputPorts()
          Returns a list of all available output ports within this process, including inner sources and output ports of enclosed operators.
 java.util.Collection<Operator> getChildOperators()
          Returns all nested operators.
 java.util.List<Operator> getEnabledOperators()
          Returns an unmodifiable view of the operators contained in this process.
 OperatorChain getEnclosingOperator()
          Returns the operator that contains this process as a subprocess.
 int getIndexOfOperator(Operator operator)
           
 InputPorts getInnerSinks()
           
 OutputPorts getInnerSources()
           
 java.lang.String getName()
           
 int getNumberOfOperators()
           
 Operator getOperatorByName(java.lang.String toOp)
           
 java.util.Enumeration<Operator> getOperatorEnumeration()
          Use this method only in cases where you are sure that you don't want a ConcurrentModificationException to occur when the list of operators is modified.
 java.util.List<Operator> getOperators()
          Returns an unmodifiable view of the operators contained in this process.
 boolean isExpanded()
          Returns true if this operator should be painted expanded.
 void moveToIndex(Operator op, int newIndex)
          Moves an operator to the given index.
 void processFinished()
           
 void processStarts()
           
protected  void removeOperator(Operator operator)
          Removes the given operator.
 void setExpanded(boolean expanded)
          Sets the expansion mode which indicates if this operator is drawn expanded or not.
 void setName(java.lang.String name)
           
 int stealOperatorsFrom(ExecutionUnit otherUnit)
          Moves the operators from this process to another process, keeping all connections intact.
 java.util.Vector<Operator> topologicalSort()
          Sorts the operators topologically, i.e. such that operator i in the returned ordering has dependencies (i.e. connected InputPorts) only from operators 0..i-1.
 void transformMetaData()
           
protected  void updateExecutionOrder()
           
 
Methods inherited from class com.rapidminer.tools.AbstractObservable
addObserver, addObserverAsFirst, fireUpdate, fireUpdate, removeObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutionUnit

public ExecutionUnit(OperatorChain enclosingOperator,
                     java.lang.String name)
Method Detail

getInnerSinks

public InputPorts getInnerSinks()

getInnerSources

public OutputPorts getInnerSources()

addOperator

public int addOperator(Operator operator)
Same as addOperator(Operator, boolean).


addOperator

public int addOperator(Operator operator,
                       boolean registerWithProcess)
Adds the operator to this execution unit.

Parameters:
registerWithProcess - Typically true. If false, the operator will not be registered with its parent process.
Returns:
the new index of the operator.

addOperator

public void addOperator(Operator operator,
                        int index)
Adds the operator to this execution unit. The operator at this index and all subsequent operators are shifted to the right. The operator is registered automatically.


getIndexOfOperator

public int getIndexOfOperator(Operator operator)

removeOperator

protected void removeOperator(Operator operator)
Removes the given operator. Don't call this method directly but call Operator.remove().


clear

public void clear(int clearFlags)

topologicalSort

public java.util.Vector<Operator> topologicalSort()
Sorts the operators topologically, i.e. such that operator i in the returned ordering has dependencies (i.e. connected InputPorts) only from operators 0..i-1.


updateExecutionOrder

protected void updateExecutionOrder()

transformMetaData

public void transformMetaData()

getOperators

public java.util.List<Operator> getOperators()
Returns an unmodifiable view of the operators contained in this process.


getOperatorEnumeration

public java.util.Enumeration<Operator> getOperatorEnumeration()
Use this method only in cases where you are sure that you don't want a ConcurrentModificationException to occur when the list of operators is modified.


getEnabledOperators

public java.util.List<Operator> getEnabledOperators()
Returns an unmodifiable view of the operators contained in this process.


getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getEnclosingOperator

public OperatorChain getEnclosingOperator()
Returns the operator that contains this process as a subprocess.


autoWire

public void autoWire(CompatibilityLevel level,
                     boolean keepConnections,
                     boolean recursive)
              throws PortException
Connects the ports automatically in a first-fit approach. Operators are connected in their ordering within the operators list. Every input of every operator is connected to the first compatible output of an operator "left" of this operator. This corresponds to the way, IOObjects were consumed in the pre-5.0 version. Disabled operators are skipped.

Parameters:
level - If level is CompatibilityLevel.VERSION_5, an input is considered compatible only if it satisfies all meta data constraints. For CompatibilityLevel.PRE_VERSION_5 we only consider the classes.
keepConnections - if true, don't unwire old connections before rewiring.
Throws:
PortException

autoWireSingle

public void autoWireSingle(Operator operator,
                           CompatibilityLevel level,
                           boolean inputs,
                           boolean outputs)
Automatically wires inputs and outputs of a single operator in this execution unit.

Parameters:
inputs - Wire inputs?
outputs - Wire outputs?

getAllOutputPorts

public java.util.Collection<OutputPort> getAllOutputPorts()
Returns a list of all available output ports within this process, including inner sources and output ports of enclosed operators.


getOperatorByName

public Operator getOperatorByName(java.lang.String toOp)

getNumberOfOperators

public int getNumberOfOperators()

cloneExecutionUnitFrom

public void cloneExecutionUnitFrom(ExecutionUnit original,
                                   boolean forParallelExecution)
Clones operators contained in original, adds them to this execution unit and wires them as they were originally.

Parameters:
forParallelExecution - Indicates whether this clone is supposed to be executed in parallel. If yes, the clone will not be registered with the parent process and will share its Operator.applyCount with the original.

getChildOperators

public java.util.Collection<Operator> getChildOperators()
Returns all nested operators.


getAllInnerOperators

public java.util.List<Operator> getAllInnerOperators()
Recursively returns all nested operators.


createProcessTree

protected java.lang.String createProcessTree(int indent,
                                             java.lang.String selfPrefix,
                                             java.lang.String childPrefix,
                                             Operator markOperator,
                                             java.lang.String mark)

execute

public void execute()
             throws OperatorException
Executes the inner operators.

Throws:
OperatorException

freeMemory

public void freeMemory()
Frees memory used by inner sinks.


setExpanded

public void setExpanded(boolean expanded)
Sets the expansion mode which indicates if this operator is drawn expanded or not.


isExpanded

public boolean isExpanded()
Returns true if this operator should be painted expanded.


processStarts

public void processStarts()
                   throws OperatorException
Throws:
OperatorException

processFinished

public void processFinished()
                     throws OperatorException
Throws:
OperatorException

stealOperatorsFrom

public int stealOperatorsFrom(ExecutionUnit otherUnit)
Moves the operators from this process to another process, keeping all connections intact. TODO: Test more rigorously. Do we register/unregister everything correctly?

Returns:
the number of ports the connections of which could not be restored

moveToIndex

public void moveToIndex(Operator op,
                        int newIndex)
Moves an operator to the given index. (If the old index is smaller than the new one, the new one will automatically be reduced by one.)


bringToFront

public void bringToFront(java.util.Collection<Operator> movedOperators,
                         Operator insertAfter)
Re-arranges the execution order such that the specified operators immediately follow insertAfter.



Copyright © 2001-2009 by Rapid-I