org.apache.pig.experimental.plan
Class OperatorSubPlan

java.lang.Object
  extended by org.apache.pig.experimental.plan.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.
 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> 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.
 void remove(Operator op)
          Remove an operator from the plan.
 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 IOException
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:
IOException - 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)
                               throws IOException
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.
Throws:
IOException - if op is not in the plan.

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)
                             throws IOException
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.
Throws:
IOException - if op is not in the plan.

remove

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

size

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

Specified by:
size in interface OperatorPlan

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


Copyright © ${year} The Apache Software Foundation