}
@Override
protected void visit(LOStore store) throws VisitorException {
LogicalOperator storePred = store.getPlan().getPredecessors(store).get(0);
if(storePred == null){
int errCode = 2051;
String msg = "Did not find a predecessor for Store." ;
throw new VisitorException(msg, errCode, PigException.BUG);
}
SortInfo sortInfo = null;
if(storePred instanceof LOLimit) {
storePred = store.getPlan().getPredecessors(storePred).get(0);
} else if (storePred instanceof LOSplitOutput) {
LOSplitOutput splitOutput = (LOSplitOutput)storePred;
// We assume this is the LOSplitOutput we injected for this case:
// b = order a by $0; store b into '1'; store b into '2';
// In this case, we should mark both '1' and '2' as sorted
LogicalPlan conditionPlan = splitOutput.getConditionPlan();
if (conditionPlan.getRoots().size()==1) {
LogicalOperator root = conditionPlan.getRoots().get(0);
if (root instanceof LOConst) {
Object value = ((LOConst)root).getValue();
if (value instanceof Boolean && (Boolean)value==true) {
LogicalOperator split = splitOutput.getPlan().getPredecessors(splitOutput).get(0);
if (split instanceof LOSplit)
storePred = store.getPlan().getPredecessors(split).get(0);
}
}
}