Operator refOp = expr.getImplicitReferencedOperator();
Operator attachedOp = expr.getAttachedLogicalOperator();
LogicalPlan lp = (LogicalPlan) attachedOp.getPlan();
List<Operator> succs = lp.getSuccessors( refOp );
LOStore store = null;
if( succs != null ) {
for( Operator succ : succs ) {
if( succ instanceof LOStore ) {
store = (LOStore)succ;
break;
}
}
}
if( store == null ) {
FuncSpec funcSpec = new FuncSpec(InterStorage.class.getName());
FileSpec fileSpec;
try {
fileSpec = new FileSpec( FileLocalizer.getTemporaryPath( pigContext ).toString(), funcSpec ); // TODO: need to hookup the pigcontext.
} catch (IOException e) {
throw new PlanValidationException( expr, "Failed to process scalar" + e);
}
store = new LOStore( lp, fileSpec );
store.setTmpStore(true);
lp.add( store );
lp.connect( refOp, store );
expr.setImplicitReferencedOperator(store);
}
filenameConst.setValue( store.getOutputSpec().getFileName() );
if( lp.getSoftLinkSuccessors( store ) == null ||
!lp.getSoftLinkSuccessors( store ).contains( attachedOp ) ) {
lp.createSoftLink( store, attachedOp );
}