ReduceSinkOperator op = (ReduceSinkOperator)nd;
ColumnPrunerProcCtx cppCtx = (ColumnPrunerProcCtx)ctx;
HashMap<Operator<? extends Serializable>, OpParseContext> opToParseCtxMap =
cppCtx.getOpToParseCtxMap();
RowResolver redSinkRR = opToParseCtxMap.get(op).getRR();
reduceSinkDesc conf = op.getConf();
List<Operator<? extends Serializable>> childOperators = op.getChildOperators();
List<Operator<? extends Serializable>> parentOperators = op.getParentOperators();
List<String> childColLists = new ArrayList<String>();
for(Operator<? extends Serializable> child: childOperators)
childColLists = Utilities.mergeUniqElems(childColLists, cppCtx.getPrunedColLists().get(child));
List<String> colLists = new ArrayList<String>();
ArrayList<exprNodeDesc> keys = conf.getKeyCols();
for (exprNodeDesc key : keys)
colLists = Utilities.mergeUniqElems(colLists, key.getCols());
if ((childOperators.size() == 1) && (childOperators.get(0) instanceof JoinOperator)) {
assert parentOperators.size() == 1;
Operator<? extends Serializable> par = parentOperators.get(0);
RowResolver parRR = opToParseCtxMap.get(par).getRR();
RowResolver childRR = opToParseCtxMap.get(childOperators.get(0)).getRR();
for (String childCol : childColLists) {
String [] nm = childRR.reverseLookup(childCol);
ColumnInfo cInfo = redSinkRR.get(nm[0],nm[1]);
if (cInfo != null) {
cInfo = parRR.get(nm[0], nm[1]);
if (!colLists.contains(cInfo.getInternalName()))
colLists.add(cInfo.getInternalName());
}
}
}
else {
// Reduce Sink contains the columns needed - no need to aggregate from children
ArrayList<exprNodeDesc> vals = conf.getValueCols();
for (exprNodeDesc val : vals)
colLists = Utilities.mergeUniqElems(colLists, val.getCols());
}
cppCtx.getPrunedColLists().put(op, colLists);