for(Map.Entry<LOUserFunc, Pair<LogicalPlan, LogicalOperator>> scalarEntry: scalarMap.entrySet()) {
FileSpec fileSpec;
String alias = scalarEntry.getKey().getImplicitReferencedOperator().getAlias();
LogicalOperator store;
LogicalPlan referredPlan = g.getAliases().get(g.getAliasOp().get(alias));
// If referredPlan already has a store,
// we just use it instead of adding one from our pocket
store = referredPlan.getLeaves().get(0);
if(store instanceof LOStore
&&
((LOStore)store).getOutputFile().getFuncName().equals(
InterStorage.class.getName())
) {
// use this store
fileSpec = ((LOStore)store).getOutputFile();
}
else {
// add new store
FuncSpec funcSpec = new FuncSpec(InterStorage.class.getName());
fileSpec = new FileSpec(FileLocalizer.getTemporaryPath(pigContext).toString(), funcSpec);
store = new LOStore(referredPlan, new OperatorKey(scope, NodeIdGenerator.getGenerator().getNextNodeId(scope)),
fileSpec, alias);
referredPlan.addAsLeaf(store);
((LOStore)store).setTmpStore(true);
scalarEntry.getKey().setImplicitReferencedOperator(store);
}
lp.mergeSharedPlan(referredPlan);
// Attach a constant operator to the ReadScalar func
LogicalPlan innerPlan = scalarEntry.getValue().first;
LOConst rconst = new LOConst(innerPlan, new OperatorKey(scope, NodeIdGenerator.getGenerator().getNextNodeId(scope)), fileSpec.getFileName());
rconst.setType(DataType.CHARARRAY);
innerPlan.add(rconst);
innerPlan.connect(rconst, scalarEntry.getKey());
if (lp.getSoftLinkSuccessors(store)==null || !lp.getSoftLinkSuccessors(store).contains(scalarEntry.getValue().second))
lp.createSoftLink(store, scalarEntry.getValue().second);
}
} catch (IOException ioe) {