Swap two operators in a plan. Both of the operators must have single inputs and single outputs. @param first operator @param second operator @throws PlanException if either operator is not single input and output.
(E first, E second)
| 1074 | * @throws PlanException if either operator is not single input and output. |
| 1075 | */ |
| 1076 | public void swap(E first, E second) throws PlanException { |
| 1077 | E firstNode = first; |
| 1078 | E secondNode = second; |
| 1079 | |
| 1080 | if(firstNode == null) { |
| 1081 | int errCode = 1092; |
| 1082 | String msg = "First operator in swap is null. Cannot swap null operators."; |
| 1083 | throw new PlanException(msg, errCode, PigException.INPUT); |
| 1084 | } |
| 1085 | |
| 1086 | if(secondNode == null) { |
| 1087 | int errCode = 1092; |
| 1088 | String msg = "Second operator in swap is null. Cannot swap null operators."; |
| 1089 | throw new PlanException(msg, errCode, PigException.INPUT); |
| 1090 | } |
| 1091 | |
| 1092 | checkInPlan(firstNode); |
| 1093 | checkInPlan(secondNode); |
| 1094 | |
| 1095 | List<E> firstNodePredecessors = (ArrayList<E>)mToEdges.get(firstNode); |
| 1096 | |
| 1097 | if(firstNodePredecessors != null && firstNodePredecessors.size() > 1) { |
| 1098 | int errCode = 1093; |
| 1099 | String msg = "Swap supports swap of operators with at most one input." |
| 1100 | + " Found first operator with " + firstNodePredecessors.size() + " inputs."; |
| 1101 | throw new PlanException(msg, errCode, PigException.INPUT); |
| 1102 | } |
| 1103 | |
| 1104 | List<E> firstNodeSuccessors = (ArrayList<E>)mFromEdges.get(firstNode); |
| 1105 | |
| 1106 | if(firstNodeSuccessors != null && firstNodeSuccessors.size() > 1) { |
| 1107 | int errCode = 1093; |
| 1108 | String msg = "Swap supports swap of operators with at most one output." |
| 1109 | + " Found first operator with " + firstNodeSuccessors.size() + " outputs."; |
| 1110 | throw new PlanException(msg, errCode, PigException.INPUT); |
| 1111 | } |
| 1112 | |
| 1113 | List<E> secondNodePredecessors = (ArrayList<E>)mToEdges.get(secondNode); |
| 1114 | |
| 1115 | if(secondNodePredecessors != null && secondNodePredecessors.size() > 1) { |
| 1116 | int errCode = 1093; |
| 1117 | String msg = "Swap supports swap of operators with at most one input." |
| 1118 | + " Found second operator with " + secondNodePredecessors.size() + " inputs."; |
| 1119 | throw new PlanException(msg, errCode, PigException.INPUT); |
| 1120 | } |
| 1121 | |
| 1122 | List<E> secondNodeSuccessors = (ArrayList<E>)mFromEdges.get(secondNode); |
| 1123 | |
| 1124 | if(secondNodeSuccessors != null && secondNodeSuccessors.size() > 1) { |
| 1125 | int errCode = 1093; |
| 1126 | String msg = "Swap supports swap of operators with at most one output." |
| 1127 | + " Found second operator with " + secondNodeSuccessors.size() + " outputs."; |
| 1128 | throw new PlanException(msg, errCode, PigException.INPUT); |
| 1129 | } |
| 1130 | |
| 1131 | E firstNodePredecessor = null; |
| 1132 | E firstNodeSuccessor = null; |
| 1133 | E secondNodePredecessor = null; |
nothing calls this directly
no test coverage detected