org.apache.pig.newplan
Class OperatorSubPlan

java.lang.Object
  extended by org.apache.pig.newplan.OperatorSubPlan
All Implemented Interfaces:
OperatorPlan

public class OperatorSubPlan
extends Object
implements OperatorPlan

Class to represent a view of a plan. The view contains a subset of the plan. All the operators returned from the view are the same objects to the operators in its base plan. It is used to represent match results.


Constructor Summary
OperatorSubPlan(OperatorPlan base)
           
 
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.
 void createSoftLink(Operator from, Operator to)
          Create an soft edge between two nodes.
 Pair<Integer,Integer> disconnect(Operator from, Operator to)
          Disconnect two operators in the plan.
 OperatorPlan getBasePlan()
           
 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> getSoftLinkPredecessors(Operator op)
          For a given operator, get all operators softly immediately before it in the plan.
 List<Operator> getSoftLinkSuccessors(Operator op)
          For a given operator, get all operators softly immediately after it.
 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.
 void insertBetween(Operator pred, Operator operatorToInsert, Operator succ)
          This method insert node operatorToInsert between pred and succ.
 boolean isEqual(OperatorPlan other)
          This is like a shallow comparison.
 boolean pathExists(Operator from, Operator to)
          check if there is a path in the plan graph between the load operator to the store operator.
 void remove(Operator op)
          Remove an operator from the plan.
 void removeAndReconnect(Operator operatorToRemove)
          This method remove a node operatorToRemove.
 void removeSoftLink(Operator from, Operator to)
          Remove an soft edge
 void replace(Operator oldOperator, Operator newOperator)
          This method replace the oldOperator with the newOperator, make all connection to the new operator in the place of old operator
 int size()
          Get number of nodes in the plan.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperatorSubPlan

public OperatorSubPlan(OperatorPlan base)
Method Detail

getBasePlan

public OperatorPlan getBasePlan()

add

public void add(Operator op)
Description copied from interface: OperatorPlan
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

connect

public void connect(Operator from,
                    int fromPos,
                    Operator to,
                    int toPos)
Description copied from interface: OperatorPlan
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)
Description copied from interface: OperatorPlan
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 FrontendException
Description copied from interface: OperatorPlan
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:
FrontendException - if the two operators aren't connected.

getSinks

public List<Operator> getSinks()
Description copied from interface: OperatorPlan
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.

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

getPredecessors

public List<Operator> getPredecessors(Operator op)
Description copied from interface: OperatorPlan
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 immediately before op, or an empty list if op is a root.

getSources

public List<Operator> getSources()
Description copied from interface: OperatorPlan
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.

getSuccessors

public List<Operator> getSuccessors(Operator op)
Description copied from interface: OperatorPlan
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 immediately after op, or an empty list if op is a leaf.

remove

public void remove(Operator op)
            throws FrontendException
Description copied from interface: OperatorPlan
Remove an operator from the plan.

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

size

public int size()
Description copied from interface: OperatorPlan
Get number of nodes in the plan.

Specified by:
size in interface OperatorPlan
Returns:
number of nodes in the plan

isEqual

public boolean isEqual(OperatorPlan other)
                throws FrontendException
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
Throws:
FrontendException

createSoftLink

public void createSoftLink(Operator from,
                           Operator to)
Description copied from interface: OperatorPlan
Create an soft edge between two nodes.

Specified by:
createSoftLink in interface OperatorPlan
Parameters:
from - Operator dependent upon
to - Operator having the dependency

removeSoftLink

public void removeSoftLink(Operator from,
                           Operator to)
Description copied from interface: OperatorPlan
Remove an soft edge

Specified by:
removeSoftLink in interface OperatorPlan
Parameters:
from - Operator dependent upon
to - Operator having the dependency

getSoftLinkPredecessors

public List<Operator> getSoftLinkPredecessors(Operator op)
Description copied from interface: OperatorPlan
For a given operator, get all operators softly immediately before it in the plan.

Specified by:
getSoftLinkPredecessors in interface OperatorPlan
Parameters:
op - operator to fetch predecessors of
Returns:
list of all operators immediately before op, or an empty list if op is a root.

getSoftLinkSuccessors

public List<Operator> getSoftLinkSuccessors(Operator op)
Description copied from interface: OperatorPlan
For a given operator, get all operators softly immediately after it.

Specified by:
getSoftLinkSuccessors in interface OperatorPlan
Parameters:
op - operator to fetch successors of
Returns:
list of all operators immediately after op, or an empty list if op is a leaf.

insertBetween

public void insertBetween(Operator pred,
                          Operator operatorToInsert,
                          Operator succ)
                   throws FrontendException
Description copied from interface: OperatorPlan
This method insert node operatorToInsert between pred and succ. Both pred and succ cannot be null

Specified by:
insertBetween in interface OperatorPlan
Parameters:
pred - predecessor of inserted node after this method
operatorToInsert - operato to insert
succ - successor of inserted node after this method
Throws:
FrontendException

removeAndReconnect

public void removeAndReconnect(Operator operatorToRemove)
                        throws FrontendException
Description copied from interface: OperatorPlan
This method remove a node operatorToRemove. It also Connect all its successors to predecessor/connect all it's predecessors to successor

Specified by:
removeAndReconnect in interface OperatorPlan
Parameters:
operatorToRemove - operator to remove
Throws:
FrontendException

replace

public void replace(Operator oldOperator,
                    Operator newOperator)
             throws FrontendException
Description copied from interface: OperatorPlan
This method replace the oldOperator with the newOperator, make all connection to the new operator in the place of old operator

Specified by:
replace in interface OperatorPlan
Parameters:
oldOperator - operator to be replaced
newOperator - operator to replace
Throws:
FrontendException

pathExists

public boolean pathExists(Operator from,
                          Operator to)
Description copied from interface: OperatorPlan
check if there is a path in the plan graph between the load operator to the store operator.

Specified by:
pathExists in interface OperatorPlan
Parameters:
from - load operator
to - store operator
Returns:
true if yes, no otherwise.


Copyright © 2007-2012 The Apache Software Foundation