popWalker();
}
currentPlan = currentPlans.pop();
// get the physical operator for sort
POSort poSort;
if (sort.getUserFunc() == null) {
poSort = new POSort(new OperatorKey(scope, nodeGen
.getNextNodeId(scope)), sort.getRequestedParallelisam(), null,
sortPlans, sort.getAscendingCols(), null);
} else {
POUserComparisonFunc comparator = new POUserComparisonFunc(new OperatorKey(
scope, nodeGen.getNextNodeId(scope)), sort
.getRequestedParallelisam(), null, sort.getUserFunc());
poSort = new POSort(new OperatorKey(scope, nodeGen
.getNextNodeId(scope)), sort.getRequestedParallelisam(), null,
sortPlans, sort.getAscendingCols(), comparator);
}
poSort.setAlias(sort.getAlias());
poSort.setLimit(sort.getLimit());
// sort.setRequestedParallelism(s.getType());
logToPhyMap.put(sort, poSort);
currentPlan.add(poSort);
List<Operator> op = sort.getPlan().getPredecessors(sort);
PhysicalOperator from;
if(op != null) {
from = logToPhyMap.get(op.get(0));
} else {
int errCode = 2051;
String msg = "Did not find a predecessor for Sort." ;
throw new LogicalToPhysicalTranslatorException(msg, errCode, PigException.BUG);
}
try {
currentPlan.connect(from, poSort);
} catch (PlanException e) {
int errCode = 2015;
String msg = "Invalid physical operators in the physical plan" ;
throw new LogicalToPhysicalTranslatorException(msg, errCode, PigException.BUG, e);
}
poSort.setResultType(DataType.BAG);
poSort.setSortInfo(sort.getSortInfo());
}