LogicalOperator lo = nodes.get(0);
if (lo == null || !(lo instanceof LOStream)) {
throw new RuntimeException("Expected stream, got " +
lo.getClass().getName());
}
LOStream stream = (LOStream)lo;
if(mOptimizeLoad) {
// we have verified in check() that the predecessor was load
LOLoad load = (LOLoad)mPlan.getPredecessors(lo).get(0);
FileSpec loadFileSpec = load.getInputFile();
load.setInputFile(new FileSpec(loadFileSpec.getFileName(), new FuncSpec(BinaryStorage.class.getName())));
stream.setOptimizedSpec(Handle.INPUT, BinaryStorage.class.getName());
}
if(mOptimizeStore) {
// we have verified in check() that the predecessor was load
LOStore store = (LOStore)mPlan.getSuccessors(lo).get(0);
FileSpec storeFileSpec = store.getOutputFile();
store.setOutputFile(new FileSpec(storeFileSpec.getFileName(), new FuncSpec(BinaryStorage.class.getName())));
stream.setOptimizedSpec(Handle.OUTPUT, BinaryStorage.class.getName());
}
} catch (Exception e) {
int errCode = 2014;
String msg = "Unable to optimize load-stream-store optimization";
throw new OptimizerException(msg, errCode, PigException.BUG, e);