return flags;
}
private static void pruneReduceSinkOperator(boolean[] retainFlags,
ReduceSinkOperator reduce, ColumnPrunerProcCtx cppCtx) throws SemanticException {
ReduceSinkDesc reduceConf = reduce.getConf();
Map<String, ExprNodeDesc> oldMap = reduce.getColumnExprMap();
Map<String, ExprNodeDesc> newMap = new HashMap<String, ExprNodeDesc>();
ArrayList<ColumnInfo> sig = new ArrayList<ColumnInfo>();
RowResolver oldRR = cppCtx.getOpToParseCtxMap().get(reduce).getRowResolver();
RowResolver newRR = new RowResolver();
ArrayList<String> originalValueOutputColNames = reduceConf
.getOutputValueColumnNames();
java.util.ArrayList<ExprNodeDesc> originalValueEval = reduceConf
.getValueCols();
ArrayList<String> newOutputColNames = new ArrayList<String>();
java.util.ArrayList<ExprNodeDesc> newValueEval = new ArrayList<ExprNodeDesc>();
for (int i = 0; i < retainFlags.length; i++) {
if (retainFlags[i]) {
newValueEval.add(originalValueEval.get(i));
String outputCol = originalValueOutputColNames.get(i);
newOutputColNames.add(outputCol);
String[] nm = oldRR.reverseLookup(outputCol);
if (nm == null) {
outputCol = Utilities.ReduceField.VALUE.toString() + "." + outputCol;
nm = oldRR.reverseLookup(outputCol);
}
newMap.put(outputCol, oldMap.get(outputCol));
ColumnInfo colInfo = oldRR.get(nm[0], nm[1]);
newRR.put(nm[0], nm[1], colInfo);
sig.add(colInfo);
}
}
ArrayList<ExprNodeDesc> keyCols = reduceConf.getKeyCols();
List<String> keys = new ArrayList<String>();
RowResolver parResover = cppCtx.getOpToParseCtxMap().get(
reduce.getParentOperators().get(0)).getRowResolver();
for (int i = 0; i < keyCols.size(); i++) {
keys = Utilities.mergeUniqElems(keys, keyCols.get(i).getCols());
}
for (int i = 0; i < keys.size(); i++) {
String outputCol = keys.get(i);
String[] nm = parResover.reverseLookup(outputCol);
ColumnInfo colInfo = oldRR.get(nm[0], nm[1]);
if (colInfo != null) {
String internalName=colInfo.getInternalName();
newMap.put(internalName, oldMap.get(internalName));
newRR.put(nm[0], nm[1], colInfo);
}
}
cppCtx.getOpToParseCtxMap().get(reduce).setRowResolver(newRR);
reduce.setColumnExprMap(newMap);
reduce.getSchema().setSignature(sig);
reduceConf.setOutputValueColumnNames(newOutputColNames);
reduceConf.setValueCols(newValueEval);
TableDesc newValueTable = PlanUtils.getReduceValueTableDesc(PlanUtils
.getFieldSchemasFromColumnList(reduceConf.getValueCols(),
newOutputColNames, 0, ""));
reduceConf.setValueSerializeInfo(newValueTable);
}