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

Method removeAndReconnect

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

Remove a node in a way that connects the node's predecessor (if any) with the node's successor (if any). This function does not handle the case where the node has multiple predecessors or successors. @param node Node to be removed @throws PlanException if the node has more than one predecessor or s

(E node)

Source from the content-addressed store, hash-verified

732 * successor.
733 */
734 public void removeAndReconnect(E node) throws PlanException {
735 List<E> preds = getPredecessors(node);
736 E pred = null;
737 if (preds != null) {
738 if (preds.size() > 1) {
739 int errCode = 1095;
740 String msg = "Attempt to remove " +
741 " and reconnect for node with multiple predecessors.";
742 PlanException pe = new PlanException(msg, errCode, PigException.INPUT);
743 throw pe;
744 }
745 pred = preds.get(0);
746 disconnect(pred, node);
747 }
748
749 int oldPos = -1;
750 int newPos = -1;
751
752 List<E> succs = getSuccessors(node);
753 E succ = null;
754 if (succs != null) {
755 if (succs.size() > 1) {
756 int errCode = 1095;
757 String msg = "Attempt to remove " +
758 " and reconnect for node with multiple successors.";
759 PlanException pe = new PlanException(msg, errCode, PigException.INPUT);
760 throw pe;
761 }
762 succ = succs.get(0);
763 List<E> plst = getPredecessors(succ);
764 for (int i=0; i<plst.size(); i++) {
765 if (plst.get(i).equals(node)) {
766 oldPos = i;
767 }
768 }
769 disconnect(node, succ);
770 }
771
772 remove(node);
773 if (pred != null && succ != null) {
774 connect(pred, succ);
775 List<E> plst = getPredecessors(succ);
776 for (int i=0; i<plst.size(); i++) {
777 if (plst.get(i).equals(pred)) {
778 newPos = i;
779 }
780 }
781
782 if (oldPos < 0 || newPos < 0) {
783 throw new PlanException("Invalid position index: " + oldPos
784 + " : " + newPos);
785 }
786
787 if (oldPos != newPos) {
788 List<E> nlst = new ArrayList<E>();
789 for (int i=0; i<plst.size(); i++) {
790 E nod = plst.get(i);
791 if (i == oldPos) {

Callers

nothing calls this directly

Calls 12

getPredecessorsMethod · 0.95
disconnectMethod · 0.95
getSuccessorsMethod · 0.95
removeMethod · 0.95
connectMethod · 0.95
removeKeyMethod · 0.80
rewireMethod · 0.80
sizeMethod · 0.65
getMethod · 0.65
addMethod · 0.65
equalsMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected