|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pig.impl.plan.OperatorPlan<E>
public abstract class OperatorPlan<E extends Operator>
A generic graphing class for use by LogicalPlan, PhysicalPlan, etc. One important aspect of this package is that it guarantees that once a graph is constructed, manipulations on that graph will maintain the ordering of inputs and outputs for a given node. That is, if a node has two inputs, 0 and 1, it is guaranteed that everytime it asks for its inputs, it will receive them in the same order. This allows operators that need to distinguish their inputs (such as binary operators that need to know left from right) to work without needing to store their inputs themselves. This is an extra burden on the graph package and not in line with the way graphs are generally understood mathematically. But it greatly reducing the need for graph manipulators (such as the validators and optimizers) to understand the internals of various nodes.
Nested Class Summary | |
---|---|
static class |
OperatorPlan.IndexHelper<E>
|
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
log
|
protected MultiMap<E,E> |
mFromEdges
|
protected Map<OperatorKey,E> |
mKeys
|
protected Map<E,OperatorKey> |
mOps
|
protected MultiMap<E,E> |
mSoftFromEdges
|
protected MultiMap<E,E> |
mSoftToEdges
|
protected MultiMap<E,E> |
mToEdges
|
Constructor Summary | |
---|---|
OperatorPlan()
|
Method Summary | |
---|---|
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(PrintStream ps)
|
Map<OperatorKey,E> |
getKeys()
Get the map of operator key and associated operators |
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. |
List<E> |
getPredecessors(E op)
Find all of the nodes that have edges to the indicated node from themselves. |
List<E> |
getRoots()
Get a list of all nodes in the graph that are roots. |
List<E> |
getSoftLinkPredecessors(E op)
Find all of the nodes that have soft edges to the indicated node from themselves. |
List<E> |
getSoftLinkSuccessors(E op)
Find all of the nodes that have soft edges from the indicated node to themselves. |
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()
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map<E extends Operator,OperatorKey> mOps
protected Map<OperatorKey,E extends Operator> mKeys
protected MultiMap<E extends Operator,E extends Operator> mFromEdges
protected MultiMap<E extends Operator,E extends Operator> mToEdges
protected MultiMap<E extends Operator,E extends Operator> mSoftFromEdges
protected MultiMap<E extends Operator,E extends Operator> mSoftToEdges
protected static final org.apache.commons.logging.Log log
Constructor Detail |
---|
public OperatorPlan()
Method Detail |
---|
public List<E> getRoots()
public List<E> getLeaves()
public OperatorKey getOperatorKey(E op)
op
- Logical operator.
public E getOperator(OperatorKey opKey)
opKey
- OperatorKey
public 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 List<E> getPredecessors(E op)
op
- Node to look to
public List<E> getSuccessors(E op)
op
- Node to look from
public List<E> getSoftLinkPredecessors(E op)
op
- Node to look to
public List<E> getSoftLinkSuccessors(E op)
op
- Node to look from
public boolean pathExists(E from, E to)
from
- the start node for checkingto
- the end node for checking
public Iterator<E> iterator()
iterator
in interface Iterable<E extends Operator>
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 before
PlanException
- 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 oldNode
PlanException
public void removeAndReconnect(E node) throws PlanException
node
- Node to be removed
PlanException
- if the node has more than one predecessor or
successor.public void removeAndReconnectMultiSucc(E node) throws PlanException
node
- Node to be removed
PlanException
- if the node has more than one predecessorpublic void dump(PrintStream ps)
public void swap(E first, E second) throws PlanException
first
- operatorsecond
- operator
PlanException
- 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 operator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |