MCPcopy Create free account
hub / github.com/apache/pig / replace

Method replace

src/org/apache/pig/impl/plan/OperatorPlan.java:670–695  ·  view source on GitHub ↗

Replace an existing node in the graph with a new node. The new node will be connected to all the nodes the old node was. The old node will be removed. The new node is assumed to have no incoming or outgoing edges @param oldNode Node to be replaced @param newNode Node to add in place of oldNode @th

(E oldNode, E newNode)

Source from the content-addressed store, hash-verified

668 * @throws PlanException
669 */
670 public void replace(E oldNode, E newNode) throws PlanException {
671 checkInPlan(oldNode);
672 add(newNode);
673 List<E> oldNodeSuccs = (getSuccessors(oldNode) == null? null : new ArrayList<E>(getSuccessors(oldNode)));
674 List<IndexHelper<E>> indexHelpers = new ArrayList<IndexHelper<E>>();
675 if(oldNodeSuccs != null) {
676 for(int i = 0; i < oldNodeSuccs.size(); ++i) {
677 E oldNodeSucc = oldNodeSuccs.get(i);
678 indexHelpers.add(new IndexHelper<E>(new ArrayList<E>(getPredecessors(oldNodeSucc))));
679 }
680 }
681
682
683 mToEdges = generateNewMap(oldNode, newNode, mToEdges);
684 mFromEdges = generateNewMap(oldNode, newNode, mFromEdges);
685
686 //ensure that the oldNode's successors are rewired
687 if(oldNodeSuccs != null) {
688 for(int i = 0; i < oldNodeSuccs.size(); ++i) {
689 E oldNodeSucc = oldNodeSuccs.get(i);
690 oldNodeSucc.rewire(oldNode, indexHelpers.get(i).getIndex(oldNode), newNode, true);
691 }
692 }
693 remove(oldNode);
694
695 }
696
697 private MultiMap<E, E> generateNewMap(
698 E oldNode,

Callers

nothing calls this directly

Calls 11

checkInPlanMethod · 0.95
addMethod · 0.95
getSuccessorsMethod · 0.95
getPredecessorsMethod · 0.95
generateNewMapMethod · 0.95
removeMethod · 0.95
rewireMethod · 0.80
sizeMethod · 0.65
getMethod · 0.65
addMethod · 0.65
getIndexMethod · 0.45

Tested by

no test coverage detected