org.apache.pig.newplan
Interface OperatorPlan

All Known Implementing Classes:
BaseOperatorPlan, LogicalExpressionPlan, LogicalPlan, OperatorSubPlan, PatternPlan, PigStats.JobGraph

@InterfaceAudience.Private
@InterfaceStability.Unstable
public interface OperatorPlan

An interface that defines graph operations on plans. Plans are modeled as graphs with restrictions on the types of connections and operations allowed.


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.
 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 load, Operator store)
          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.
 

Method Detail

size

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

Returns:
number of nodes in the plan

getSources

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

Returns:
all operators in the plan that have no predecessors, or an empty list if the plan is empty.

getSinks

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

Returns:
all operators in the plan that have no successors, or an empty list if the plan is empty.

getPredecessors

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

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

getSuccessors

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

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

getSoftLinkPredecessors

List<Operator> getSoftLinkPredecessors(Operator op)
For a given operator, get all operators softly immediately before it in the plan.

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

List<Operator> getSoftLinkSuccessors(Operator op)
For a given operator, get all operators softly immediately after it.

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

add

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

Parameters:
op - operator to add

remove

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

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

connect

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.

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

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

Parameters:
from - Operator edge will come from
to - Operator edge will go to

createSoftLink

void createSoftLink(Operator from,
                    Operator to)
Create an soft edge between two nodes.

Parameters:
from - Operator dependent upon
to - Operator having the dependency

removeSoftLink

void removeSoftLink(Operator from,
                    Operator to)
Remove an soft edge

Parameters:
from - Operator dependent upon
to - Operator having the dependency

disconnect

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

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.

getOperators

Iterator<Operator> getOperators()
Get an iterator of all operators in this plan

Returns:
an iterator of all operators in this plan

isEqual

boolean isEqual(OperatorPlan other)
                throws FrontendException
This is like a shallow comparison. Two plans are equal if they have equivalent operators and equivalent structure.

Parameters:
other - object to compare
Returns:
boolean if both the plans are equivalent
Throws:
FrontendException

replace

void replace(Operator oldOperator,
             Operator newOperator)
             throws FrontendException
This method replace the oldOperator with the newOperator, make all connection to the new operator in the place of old operator

Parameters:
oldOperator - operator to be replaced
newOperator - operator to replace
Throws:
FrontendException

removeAndReconnect

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

Parameters:
operatorToRemove - operator to remove
Throws:
FrontendException

insertBetween

void insertBetween(Operator pred,
                   Operator operatorToInsert,
                   Operator succ)
                   throws FrontendException
This method insert node operatorToInsert between pred and succ. Both pred and succ cannot be null

Parameters:
pred - predecessor of inserted node after this method
operatorToInsert - operato to insert
succ - successor of inserted node after this method
Throws:
FrontendException

pathExists

boolean pathExists(Operator load,
                   Operator store)
check if there is a path in the plan graph between the load operator to the store operator.

Parameters:
load - load operator
store - store operator
Returns:
true if yes, no otherwise.


Copyright © ${year} The Apache Software Foundation