public void transform(List<LogicalOperator> nodes)
throws OptimizerException {
if((nodes == null) || (nodes.size() <= 0)) {
int errCode = 2177;
String msg = "Cannot retrieve operator from null or empty list.";
throw new OptimizerException(msg, errCode, PigException.BUG);
}
try {
LogicalOperator lo = nodes.get(0);
if (lo == null || !(lo instanceof LOForEach || lo instanceof LOSplit)) {
int errCode = 2178;
String msg = "Expected " + LOForEach.class.getSimpleName() + " or " + LOSplit.class.getSimpleName();
throw new OptimizerException(msg, errCode, PigException.BUG);
}
// Check if we have saved requiredInfo, if so, we will use that as required output fields for that operator;
// Otherwise means we require every output field
RequiredInfo requiredOutputInfo = cachedRequiredInfo.get(lo);
if (requiredOutputInfo==null)
{
List<RequiredFields> requiredOutputFieldsList = new ArrayList<RequiredFields>();
List<LogicalOperator> successors = mPlan.getSuccessors(lo);
if (successors==null)
{
requiredOutputFieldsList.add(new RequiredFields(true));
}
else
{
// The only case requiredOutputFieldsList more than 1 element is when the current
// operator is LOSplit
for (int i=0;i<successors.size();i++)
{
requiredOutputFieldsList.add(new RequiredFields(true));
}
}
requiredOutputInfo = new RequiredInfo(requiredOutputFieldsList);
}
processNode(lo, requiredOutputInfo);
} catch (OptimizerException oe) {
throw oe;
} catch (Exception e) {
int errCode = 2181;
String msg = "Unable to prune columns.";
throw new OptimizerException(msg, errCode, PigException.BUG, e);
}
}