throws SemanticException {
Task<? extends Serializable> task = (Task<? extends Serializable>) nd;
// create a the context for walking operators
ParseContext parseContext = physicalContext.getParseContext();
WalkerCtx walkerCtx = new WalkerCtx();
for (MapWork mapWork: task.getMapWork()) {
LOG.debug("Looking at: "+mapWork.getName());
Collection<Operator<? extends OperatorDesc>> topOperators
= mapWork.getAliasToWork().values();
if (topOperators.size() == 0) {
LOG.debug("No top operators");
return null;
}
LOG.info("Looking for table scans where optimization is applicable");
// The dispatcher fires the processor corresponding to the closest
// matching rule and passes the context along
Dispatcher disp = new DefaultRuleDispatcher(null, rules, walkerCtx);
GraphWalker ogw = new PreOrderWalker(disp);
// Create a list of topOp nodes
ArrayList<Node> topNodes = new ArrayList<Node>();
// Get the top Nodes for this task
for (Operator<? extends OperatorDesc>
workOperator : topOperators) {
if (parseContext.getTopOps().values().contains(workOperator)) {
topNodes.add(workOperator);
}
}
Operator<? extends OperatorDesc> reducer = task.getReducer(mapWork);
if (reducer != null) {
topNodes.add(reducer);
}
ogw.startWalking(topNodes, null);
LOG.info(String.format("Found %d null table scans",
walkerCtx.getMetadataOnlyTableScans().size()));
Iterator<TableScanOperator> iterator
= walkerCtx.getMetadataOnlyTableScans().iterator();
while (iterator.hasNext()) {
TableScanOperator tso = iterator.next();
tso.getConf().setIsMetadataOnly(true);
String alias = getAliasForTableScanOperator(mapWork, tso);