org.apache.pig.impl.plan
Class Operator<V extends PlanVisitor>

java.lang.Object
  extended by org.apache.pig.impl.plan.Operator<V>
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Operator>
Direct Known Subclasses:
DotMRPrinter.InnerOperator, MapReduceOper, PhysicalOperator

public abstract class Operator<V extends PlanVisitor>
extends Object
implements Serializable, Comparable<Operator>, Cloneable

Base class for all types of operators.

See Also:
Serialized Form

Field Summary
protected  OperatorKey mKey
          OperatorKey associated with this operator.
 
Constructor Summary
Operator(OperatorKey k)
           
 
Method Summary
protected  Object clone()
           
 int compareTo(Operator o)
           
 boolean equals(Object obj)
          Compares to Operators based on their opKey
 OperatorKey getOperatorKey()
          Get the operator key for this operator.
 ProjectionMap getProjectionMap()
          Produce a map describing how this operator modifies its projection.
 int hashCode()
          Needed to ensure that the list iterators' outputs are deterministic.
abstract  String name()
           
 ProjectionMap regenerateProjectionMap()
          Regenerate the projection map by unsetting and getting the projection map
 void rewire(Operator<V> oldPred, int oldPredIndex, Operator<V> newPred, boolean useOldPred)
          Make any necessary changes to a node based on a change of position in the plan.
abstract  boolean supportsMultipleInputs()
          Indicates whether this operator supports multiple inputs.
abstract  boolean supportsMultipleOutputs()
          Indicates whether this operator supports multiple outputs.
 String toString()
           
 void unsetProjectionMap()
          Unset the projection map as if it had not been calculated.
abstract  void visit(V v)
          Visit this node with the provided visitor.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mKey

protected OperatorKey mKey
OperatorKey associated with this operator. This key is used to find the operator in an OperatorPlan.

Constructor Detail

Operator

public Operator(OperatorKey k)
Parameters:
k - Operator key to assign to this node.
Method Detail

getOperatorKey

public OperatorKey getOperatorKey()
Get the operator key for this operator.


visit

public abstract void visit(V v)
                    throws VisitorException
Visit this node with the provided visitor. This should only be called by the visitor class itself, never directly.

Parameters:
v - Visitor to visit with.
Throws:
VisitorException - if the visitor has a problem.

supportsMultipleInputs

public abstract boolean supportsMultipleInputs()
Indicates whether this operator supports multiple inputs.

Returns:
true if it does, otherwise false.

supportsMultipleOutputs

public abstract boolean supportsMultipleOutputs()
Indicates whether this operator supports multiple outputs.

Returns:
true if it does, otherwise false.

name

public abstract String name()

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Compares to Operators based on their opKey

Overrides:
equals in class Object

hashCode

public int hashCode()
Needed to ensure that the list iterators' outputs are deterministic. Without this we are totally at object id's mercy.

Overrides:
hashCode in class Object

compareTo

public int compareTo(Operator o)
Specified by:
compareTo in interface Comparable<Operator>

clone

protected Object clone()
                throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException
See Also:
Do not use the clone method directly. Operators are cloned when logical plans are cloned using {@link LogicalPlanCloner}

getProjectionMap

public ProjectionMap getProjectionMap()
Produce a map describing how this operator modifies its projection.

Returns:
ProjectionMap null indicates it does not know how the projection changes, for example a join of two inputs where one input does not have a schema.

unsetProjectionMap

public void unsetProjectionMap()
Unset the projection map as if it had not been calculated. This is used by anyone who reorganizes the tree and needs to have projection maps recalculated.


regenerateProjectionMap

public ProjectionMap regenerateProjectionMap()
Regenerate the projection map by unsetting and getting the projection map


rewire

public void rewire(Operator<V> oldPred,
                   int oldPredIndex,
                   Operator<V> newPred,
                   boolean useOldPred)
            throws PlanException
Make any necessary changes to a node based on a change of position in the plan. This allows operators to rewire their projections, etc. when they are relocated in a plan.

Parameters:
oldPred - Operator that was previously the predecessor.
oldPredIndex - position of the old predecessor in the list of predecessors
newPred - Operator that will now be the predecessor.
useOldPred - If true use oldPred's projection map for the rewire; otherwise use newPred's projection map
Throws:
PlanException


Copyright © ${year} The Apache Software Foundation