public abstract class OperatorPlan<E extends Operator>
extends java.lang.Object
implements java.lang.Iterable<E>, java.io.Serializable, java.lang.Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
OperatorPlan.IndexHelper<E> |
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
log |
protected MultiMap<E,E> |
mFromEdges |
protected java.util.Map<OperatorKey,E> |
mKeys |
protected java.util.Map<E,OperatorKey> |
mOps |
protected MultiMap<E,E> |
mSoftFromEdges |
protected MultiMap<E,E> |
mSoftToEdges |
protected MultiMap<E,E> |
mToEdges |
Constructor and Description |
---|
OperatorPlan() |
Modifier and Type | Method and Description |
---|---|
void |
add(E op)
Insert an operator into the plan.
|
void |
addAsLeaf(E leaf)
Utility method heavily used in the MRCompiler
Adds the leaf operator to the plan and connects
all existing leaves to the new leaf
|
void |
connect(E from,
E to)
Create an edge between two nodes.
|
void |
createSoftLink(E from,
E to)
Create an soft edge between two nodes.
|
boolean |
disconnect(E from,
E to)
Remove an edge from between two nodes.
|
void |
doInsertBetween(E after,
E newNode,
E before,
boolean rewire) |
void |
dump(java.io.PrintStream ps) |
java.util.Map<OperatorKey,E> |
getKeys()
Get the map of operator key and associated operators
|
java.util.List<E> |
getLeaves()
Get a list of all nodes in the graph that are leaves.
|
E |
getOperator(OperatorKey opKey)
Given an OperatorKey, find the associated operator.
|
OperatorKey |
getOperatorKey(E op)
Given an operator, find its OperatorKey.
|
java.util.List<E> |
getPredecessors(E op)
Find all of the nodes that have edges to the indicated node from
themselves.
|
java.util.List<E> |
getRoots()
Get a list of all nodes in the graph that are roots.
|
java.util.List<E> |
getSoftLinkPredecessors(E op)
Find all of the nodes that have soft edges to the indicated node from
themselves.
|
java.util.List<E> |
getSoftLinkSuccessors(E op)
Find all of the nodes that have soft edges from the indicated node to
themselves.
|
java.util.List<E> |
getSuccessors(E op)
Find all of the nodes that have edges from the indicated node to
themselves.
|
void |
insertBetween(E after,
E newNode,
E before)
Given two connected nodes add another node between them.
|
boolean |
isSingleLeafPlan() |
java.util.Iterator<E> |
iterator() |
OperatorPlan<E> |
merge(OperatorPlan<E> inpPlan)
Merges the operators in the incoming operPlan with
this plan's operators.
|
OperatorPlan<E> |
mergeSharedPlan(OperatorPlan<E> inpPlan)
Merges the operators in the incoming plan with this plan's operators.
|
boolean |
pathExists(E from,
E to)
A method to check if there is a path from a given node to another node
|
void |
pushAfter(E first,
E second,
int outputNum)
Push one operator after another.
|
void |
pushBefore(E first,
E second,
int inputNum)
Push one operator in front of another.
|
void |
remove(E op)
Remove an operator from the plan.
|
void |
removeAndReconnect(E node)
Remove a node in a way that connects the node's predecessor (if any)
with the node's successor (if any).
|
void |
removeAndReconnectMultiSucc(E node)
Remove a node in a way that connects the node's predecessor (if any)
with the node's successors (if any).
|
void |
removeSoftLink(E from,
E to)
Remove an soft edge
|
void |
replace(E oldNode,
E newNode)
Replace an existing node in the graph with a new node.
|
int |
size() |
void |
swap(E first,
E second)
Swap two operators in a plan.
|
void |
trimAbove(E op)
Trim everything above a given operator.
|
void |
trimBelow(E op)
Trim everything below a given operator.
|
protected java.util.Map<E extends Operator,OperatorKey> mOps
protected java.util.Map<OperatorKey,E extends Operator> mKeys
protected static final org.apache.commons.logging.Log log
public java.util.List<E> getRoots()
public java.util.List<E> getLeaves()
public OperatorKey getOperatorKey(E op)
op
- Logical operator.public E getOperator(OperatorKey opKey)
opKey
- OperatorKeypublic java.util.Map<OperatorKey,E> getKeys()
public void add(E op)
op
- Operator to add to the plan.public void connect(E from, E to) throws PlanException
from
- Operator data will flow from.to
- Operator data will flow to.PlanException
- if this edge will create multiple inputs for an
operator that does not support multiple inputs or create multiple outputs
for an operator that does not support multiple outputs.public void createSoftLink(E from, E to) throws PlanException
from
- Operator dependent upon.to
- Operator having the dependency.PlanException
- if the nodes is not in planpublic void removeSoftLink(E from, E to)
from
- Operator dependent uponto
- Operator having the dependencypublic boolean disconnect(E from, E to)
insertBetween(Operator, Operator, Operator)
if disconnect is used in the process of inserting a new node between two nodes
by calling disconnect followed by a connect.from
- Operator data would flow from.to
- Operator data would flow to.public void remove(E op)
op
- Operator to remove.public void trimBelow(E op)
op
- Operator to trim everything after.public void trimAbove(E op)
op
- Operator to trim everything before.public java.util.List<E> getPredecessors(E op)
op
- Node to look topublic java.util.List<E> getSuccessors(E op)
op
- Node to look frompublic java.util.List<E> getSoftLinkPredecessors(E op)
op
- Node to look topublic java.util.List<E> getSoftLinkSuccessors(E op)
op
- Node to look frompublic boolean pathExists(E from, E to)
from
- the start node for checkingto
- the end node for checkingpublic java.util.Iterator<E> iterator()
public OperatorPlan<E> merge(OperatorPlan<E> inpPlan) throws PlanException
inpPlan
- PlanException
public OperatorPlan<E> mergeSharedPlan(OperatorPlan<E> inpPlan) throws PlanException
inpPlan
- PlanException
public void addAsLeaf(E leaf) throws PlanException
leaf
- PlanException
public boolean isSingleLeafPlan()
public int size()
public void insertBetween(E after, E newNode, E before) throws PlanException
after
- Node to insert this node afternewNode
- new node to insert. This node must have already been
added to the plan.before
- Node to insert this node beforePlanException
- if it encounters trouble disconnecting or
connecting nodes.public void doInsertBetween(E after, E newNode, E before, boolean rewire) throws PlanException
PlanException
public void replace(E oldNode, E newNode) throws PlanException
oldNode
- Node to be replacednewNode
- Node to add in place of oldNodePlanException
public void removeAndReconnect(E node) throws PlanException
node
- Node to be removedPlanException
- if the node has more than one predecessor or
successor.public void removeAndReconnectMultiSucc(E node) throws PlanException
node
- Node to be removedPlanException
- if the node has more than one predecessorpublic void dump(java.io.PrintStream ps)
public void swap(E first, E second) throws PlanException
first
- operatorsecond
- operatorPlanException
- if either operator is not single input and output.public void pushBefore(E first, E second, int inputNum) throws PlanException
first
- operator, assumed to have multiple inputs.second
- operator, will be pushed in front of firstinputNum
- indicates which input of the first operator the second
operator will be pushed onto. Numbered from 0.PlanException
- if inputNum does not exist for first operatorpublic void pushAfter(E first, E second, int outputNum) throws PlanException
first
- operator, assumed to have multiple outputssecond
- operator, will be pushed after the first operatoroutputNum
- indicates which output of the first operator the second
operator will be pushed onto. Numbered from 0.PlanException
- if outputNum does not exist for first operatorCopyright © 2007-2012 The Apache Software Foundation