org.apache.pig.experimental.plan
Class BaseOperatorPlan

java.lang.Object
  extended by org.apache.pig.experimental.plan.BaseOperatorPlan
All Implemented Interfaces:
OperatorPlan
Direct Known Subclasses:
LogicalExpressionPlan, LogicalPlan

public abstract class BaseOperatorPlan
extends Object
implements OperatorPlan


Field Summary
protected  PlanEdge fromEdges
           
protected static org.apache.commons.logging.Log log
           
protected  Set<Operator> ops
           
protected  PlanEdge toEdges
           
 
Constructor Summary
BaseOperatorPlan()
           
 
Method Summary
 void add(Operator op)
          Add a new operator to the plan.
 void connect(Operator from, int fromPos, Operator to, int toPos)
          Connect two operators in the plan, controlling which position in the edge lists that the from and to edges are placed.
 void connect(Operator from, Operator to)
          Connect two operators in the plan.
 Pair<Integer,Integer> disconnect(Operator from, Operator to)
          Disconnect two operators in the plan.
 void explain(PrintStream ps, String format, boolean verbose)
           
 Iterator<Operator> getOperators()
          Get an iterator of all operators in this plan
 List<Operator> getPredecessors(Operator op)
          For a given operator, get all operators immediately before it in the plan.
 List<Operator> getSinks()
          Get all operators in the plan that have no successors.
 List<Operator> getSources()
          Get all operators in the plan that have no predecessors.
 List<Operator> getSuccessors(Operator op)
          For a given operator, get all operators immediately after it.
 boolean isEqual(OperatorPlan other)
          This is like a shallow comparison.
protected static boolean isEqual(OperatorPlan p1, OperatorPlan p2)
           
 void remove(Operator op)
          Remove an operator from the plan.
 int size()
          Get number of nodes in the plan.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ops

protected Set<Operator> ops

fromEdges

protected PlanEdge fromEdges

toEdges

protected PlanEdge toEdges

log

protected static final org.apache.commons.logging.Log log
Constructor Detail

BaseOperatorPlan

public BaseOperatorPlan()
Method Detail

size

public int size()
Get number of nodes in the plan.

Specified by:
size in interface OperatorPlan

getSources

public List<Operator> getSources()
Get all operators in the plan that have no predecessors.

Specified by:
getSources in interface OperatorPlan
Returns:
all operators in the plan that have no predecessors, or an empty list if the plan is empty.

getSinks

public List<Operator> getSinks()
Get all operators in the plan that have no successors.

Specified by:
getSinks in interface OperatorPlan
Returns:
all operators in the plan that have no successors, or an empty list if the plan is empty.

getPredecessors

public List<Operator> getPredecessors(Operator op)
                               throws IOException
For a given operator, get all operators immediately before it in the plan.

Specified by:
getPredecessors in interface OperatorPlan
Parameters:
op - operator to fetch predecessors of
Returns:
list of all operators imeediately before op, or an empty list if op is a root.
Throws:
IOException - if op is not in the plan.

getSuccessors

public List<Operator> getSuccessors(Operator op)
                             throws IOException
For a given operator, get all operators immediately after it.

Specified by:
getSuccessors in interface OperatorPlan
Parameters:
op - operator to fetch successors of
Returns:
list of all operators imeediately after op, or an empty list if op is a leaf.
Throws:
IOException - if op is not in the plan.

add

public void add(Operator op)
Add a new operator to the plan. It will not be connected to any existing operators.

Specified by:
add in interface OperatorPlan
Parameters:
op - operator to add

remove

public void remove(Operator op)
            throws IOException
Remove an operator from the plan.

Specified by:
remove in interface OperatorPlan
Parameters:
op - Operator to be removed
Throws:
IOException - if the remove operation attempts to remove an operator that is still connected to other operators.

connect

public void connect(Operator from,
                    int fromPos,
                    Operator to,
                    int toPos)
Connect two operators in the plan, controlling which position in the edge lists that the from and to edges are placed.

Specified by:
connect in interface OperatorPlan
Parameters:
from - Operator edge will come from
fromPos - Position in the array for the from edge
to - Operator edge will go to
toPos - Position in the array for the to edge

connect

public void connect(Operator from,
                    Operator to)
Connect two operators in the plan.

Specified by:
connect in interface OperatorPlan
Parameters:
from - Operator edge will come from
to - Operator edge will go to

disconnect

public Pair<Integer,Integer> disconnect(Operator from,
                                        Operator to)
                                 throws IOException
Disconnect two operators in the plan.

Specified by:
disconnect in interface OperatorPlan
Parameters:
from - Operator edge is coming from
to - Operator edge is going to
Returns:
pair of positions, indicating the position in the from and to arrays.
Throws:
IOException - if the two operators aren't connected.

getOperators

public Iterator<Operator> getOperators()
Description copied from interface: OperatorPlan
Get an iterator of all operators in this plan

Specified by:
getOperators in interface OperatorPlan
Returns:
an iterator of all operators in this plan

isEqual

public boolean isEqual(OperatorPlan other)
Description copied from interface: OperatorPlan
This is like a shallow comparison. Two plans are equal if they have equivalent operators and equivalent structure.

Specified by:
isEqual in interface OperatorPlan
Parameters:
other - object to compare
Returns:
boolean if both the plans are equivalent

isEqual

protected static boolean isEqual(OperatorPlan p1,
                                 OperatorPlan p2)

explain

public void explain(PrintStream ps,
                    String format,
                    boolean verbose)
             throws IOException
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


Copyright © ${year} The Apache Software Foundation