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

Method pushBefore

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

Push one operator in front of another. This function is for use when the first operator has multiple inputs. The caller can specify which input of the first operator the second operator should be pushed to. @param first operator, assumed to have multiple inputs. @param second operator, will be pus

(E first, E second, int inputNum)

Source from the content-addressed store, hash-verified

1230 * @throws PlanException if inputNum does not exist for first operator
1231 */
1232 public void pushBefore(E first, E second, int inputNum) throws PlanException {
1233 E firstNode = first;
1234 E secondNode = second;
1235
1236 if(firstNode == null) {
1237 int errCode = 1085;
1238 String msg = "First operator in pushBefore is null. Cannot pushBefore null operators.";
1239 throw new PlanException(msg, errCode, PigException.INPUT);
1240 }
1241
1242 if(secondNode == null) {
1243 int errCode = 1085;
1244 String msg = "Second operator in pushBefore is null. Cannot pushBefore null operators.";
1245 throw new PlanException(msg, errCode, PigException.INPUT);
1246 }
1247
1248 checkInPlan(firstNode);
1249 checkInPlan(secondNode);
1250
1251 List<E> firstNodePredecessors = (mToEdges.get(firstNode) == null? null : new ArrayList<E>(mToEdges.get(firstNode)));
1252
1253 if(firstNodePredecessors == null || firstNodePredecessors.size() <= 1) {
1254 int size = (firstNodePredecessors == null ? 0 : firstNodePredecessors.size());
1255 int errCode = 1086;
1256 String msg = "First operator in pushBefore should have multiple inputs."
1257 + " Found first operator with " + size + " inputs.";
1258 throw new PlanException(msg, errCode, PigException.INPUT);
1259 }
1260
1261 if(inputNum >= firstNodePredecessors.size()) {
1262 int errCode = 1087;
1263 String msg = "The inputNum " + inputNum + " should be lesser than the number of inputs of the first operator."
1264 + " Found first operator with " + firstNodePredecessors.size() + " inputs.";
1265 throw new PlanException(msg, errCode, PigException.INPUT);
1266 }
1267
1268 List<E> firstNodeSuccessors = (mFromEdges.get(firstNode) == null? null : new ArrayList<E>(mFromEdges.get(firstNode)));
1269
1270 if(firstNodeSuccessors == null) {
1271 int errCode = 1088;
1272 String msg = "First operator in pushBefore should have at least one output."
1273 + " Found first operator with no outputs.";
1274 throw new PlanException(msg, errCode, PigException.INPUT);
1275 }
1276
1277 List<E> secondNodePredecessors = (mToEdges.get(secondNode) == null? null : new ArrayList<E>(mToEdges.get(secondNode)));
1278
1279 if(secondNodePredecessors == null || secondNodePredecessors.size() > 1) {
1280 int size = (secondNodePredecessors == null ? 0 : secondNodePredecessors.size());
1281 int errCode = 1088;
1282 String msg = "Second operator in pushBefore should have one input."
1283 + " Found second operator with " + size + " inputs.";
1284 throw new PlanException(msg, errCode, PigException.INPUT);
1285 }
1286
1287 List<E> secondNodeSuccessors = (mFromEdges.get(secondNode) == null? null : new ArrayList<E>(mFromEdges.get(secondNode)));
1288
1289 //check for multiple edges from first to second

Callers

nothing calls this directly

Calls 9

checkInPlanMethod · 0.95
reconnectSuccessorsMethod · 0.95
doInsertBetweenMethod · 0.95
markDirtyMethod · 0.95
rewireMethod · 0.80
getMethod · 0.65
sizeMethod · 0.65

Tested by

no test coverage detected