public void rewire(Operator<LOVisitor> oldPred, int oldPredIndex, Operator<LOVisitor> newPred, boolean useOldPred) throws PlanException {
super.rewire(oldPred, oldPredIndex, newPred, useOldPred);
if(newPred == null) {
int errCode = 1097;
String msg = "Replacement node cannot be null.";
throw new PlanException(msg, errCode, PigException.INPUT);
}
LogicalOperator previous = (LogicalOperator) oldPred;
LogicalOperator current = (LogicalOperator) newPred;
Set<LogicalOperator> cogroupInputs = new HashSet<LogicalOperator>(mGroupByPlans.keySet());
for(LogicalOperator input: cogroupInputs) {
if(input.equals(previous)) {
//replace the references to the key(i.e., previous) in the values with current
for(LogicalPlan plan: mGroupByPlans.get(input)) {
try {
ProjectFixerUpper projectFixer = new ProjectFixerUpper(
plan, previous, oldPredIndex, current, useOldPred, this);
projectFixer.visit();
} catch (VisitorException ve) {
int errCode = 2144;
String msg = "Problem while fixing project inputs during rewiring.";
throw new PlanException(msg, errCode, PigException.BUG, ve);
}
}
//remove the key and the values
List<LogicalPlan> plans = (List<LogicalPlan>)mGroupByPlans.get(previous);
mGroupByPlans.removeKey(previous);