return;
}
List<String> childColLists = cppCtx.genColLists((Operator<? extends Serializable>)op);
RowResolver joinRR = cppCtx.getOpToParseCtxMap().get(op).getRR();
RowResolver newJoinRR = new RowResolver();
ArrayList<String> outputCols = new ArrayList<String>();
Vector<ColumnInfo> rs = new Vector<ColumnInfo>();
Map<String, exprNodeDesc> newColExprMap = new HashMap<String, exprNodeDesc>();
for (int i = 0; i < conf.getOutputColumnNames().size(); i++) {
String internalName = conf.getOutputColumnNames().get(i);
exprNodeDesc desc = columnExprMap.get(internalName);
Byte tag = conf.getReversedExprs().get(internalName);
if (!childColLists.contains(internalName)) {
int index = conf.getExprs().get(tag).indexOf(desc);
if (index < 0)
continue;
conf.getExprs().get(tag).remove(desc);
if (retainMap != null)
retainMap.get(tag).remove(index);
} else {
List<String> prunedRSList = prunedColLists.get(tag);
if (prunedRSList == null) {
prunedRSList = new ArrayList<String>();
prunedColLists.put(tag, prunedRSList);
}
prunedRSList = Utilities.mergeUniqElems(prunedRSList, desc.getCols());
outputCols.add(internalName);
newColExprMap.put(internalName, desc);
}
}
if (mapJoin) {
// regenerate the valueTableDesc
List<tableDesc> valueTableDescs = new ArrayList<tableDesc>();
for (int pos = 0; pos < op.getParentOperators().size(); pos++) {
List<exprNodeDesc> valueCols = conf.getExprs()
.get(new Byte((byte) pos));
StringBuilder keyOrder = new StringBuilder();
for (int i = 0; i < valueCols.size(); i++) {
keyOrder.append("+");
}
tableDesc valueTableDesc = PlanUtils
.getMapJoinValueTableDesc(PlanUtils
.getFieldSchemasFromColumnList(valueCols, "mapjoinvalue"));
valueTableDescs.add(valueTableDesc);
}
((mapJoinDesc) conf).setValueTblDescs(valueTableDescs);
Set<Map.Entry<Byte, List<exprNodeDesc>>> exprs = ((mapJoinDesc) conf)
.getKeys().entrySet();
Iterator<Map.Entry<Byte, List<exprNodeDesc>>> iters = exprs.iterator();
while (iters.hasNext()) {
Map.Entry<Byte, List<exprNodeDesc>> entry = iters.next();
List<exprNodeDesc> lists = entry.getValue();
for (int j = 0; j < lists.size(); j++) {
exprNodeDesc desc = lists.get(j);
Byte tag = entry.getKey();
List<String> cols = prunedColLists.get(tag);
cols = Utilities.mergeUniqElems(cols, desc.getCols());
prunedColLists.put(tag, cols);
}
}
}
for (Operator<? extends Serializable> child : childOperators) {
if (child instanceof ReduceSinkOperator) {
boolean[] flags = getPruneReduceSinkOpRetainFlags(childColLists,
(ReduceSinkOperator) child);
pruneReduceSinkOperator(flags, (ReduceSinkOperator) child, cppCtx);
}
}
for (int i = 0; i < outputCols.size(); i++) {
String internalName = outputCols.get(i);
String[] nm = joinRR.reverseLookup(internalName);
ColumnInfo col = joinRR.get(nm[0], nm[1]);
newJoinRR.put(nm[0], nm[1], col);
rs.add(col);
}
op.setColumnExprMap(newColExprMap);
conf.setOutputColumnNames(outputCols);