feproj2.setStar(false);
feproj2.setOverloaded(false);
fep2.add(feproj2);
List<PhysicalPlan> fePlans = Arrays.asList(fep1, fep2);
POForEach poForEach = new POForEach(new OperatorKey(scope, nodeGen.getNextNodeId(scope)), -1, fePlans, flattenLst);
List<LogicalExpressionPlan> rankPlans = loRank.getRankColPlans();
byte[] newTypes = new byte[rankPlans.size()];
for(int i = 0; i < rankPlans.size(); i++) {
LogicalExpressionPlan loep = rankPlans.get(i);
Iterator<Operator> inpOpers = loep.getOperators();
while(inpOpers.hasNext()) {
Operator oper = inpOpers.next();
newTypes[i] = ((ProjectExpression) oper).getType();
}
}
List<PhysicalPlan> newPhysicalPlan = new ArrayList<PhysicalPlan>();
List<Boolean> newOrderPlan = new ArrayList<Boolean>();
for(int i = 0; i < loRank.getRankColPlans().size(); i++) {
PhysicalPlan fep3 = new PhysicalPlan();
POProject feproj3 = new POProject(new OperatorKey(scope, nodeGen.getNextNodeId(scope)), -1);
feproj3.addOriginalLocation(loRank.getAlias(), loRank.getLocation());
feproj3.setColumn(i);
feproj3.setResultType(newTypes[i]);
feproj3.setStar(false);
feproj3.setOverloaded(false);
fep3.add(feproj3);
newPhysicalPlan.add(fep3);
newOrderPlan.add(loRank.getAscendingCol().get(i));
}
POSort poSort;
poSort = new POSort(new OperatorKey(scope, nodeGen
.getNextNodeId(scope)), -1, null,
newPhysicalPlan, newOrderPlan, null);
poSort.addOriginalLocation(loRank.getAlias(), loRank.getLocation());
poCounter = new POCounter(
new OperatorKey(scope, nodeGen
.getNextNodeId(scope)), -1 , null,
newPhysicalPlan, newOrderPlan);
poCounter.addOriginalLocation(loRank.getAlias(), loRank.getLocation());
poCounter.setResultType(DataType.TUPLE);
poCounter.setIsRowNumber(loRank.isRowNumber());
poCounter.setIsDenseRank(loRank.isDenseRank());
poCounter.setOperationID(String.valueOf(operationID));
poRank = new PORank(
new OperatorKey(scope, nodeGen
.getNextNodeId(scope)), -1 , null,
newPhysicalPlan, newOrderPlan);
poRank.addOriginalLocation(loRank.getAlias(), loRank.getLocation());
poRank.setResultType(DataType.TUPLE);
poRank.setOperationID(String.valueOf(operationID));
List<Boolean> flattenLst2 = Arrays.asList(false, true);
PhysicalPlan fep12 = new PhysicalPlan();
POProject feproj12 = new POProject(new OperatorKey(scope, nodeGen.getNextNodeId(scope)), -1);
feproj12.addOriginalLocation(loRank.getAlias(), loRank.getLocation());
feproj12.setColumn(0);
feproj12.setResultType(DataType.LONG);
feproj12.setStar(false);
feproj12.setOverloaded(false);
fep12.add(feproj12);
PhysicalPlan fep22 = new PhysicalPlan();
POProject feproj22 = new POProject(new OperatorKey(scope, nodeGen.getNextNodeId(scope)), -1);
feproj22.addOriginalLocation(loRank.getAlias(), loRank.getLocation());
feproj22.setColumn(loRank.getRankColPlans().size()+1);
feproj22.setResultType(DataType.BAG);
feproj22.setStar(false);
feproj22.setOverloaded(false);
fep22.add(feproj22);
List<PhysicalPlan> fePlans2 = Arrays.asList(fep12, fep22);
POForEach poForEach2 = new POForEach(new OperatorKey(scope, nodeGen.getNextNodeId(scope)), -1, fePlans2, flattenLst2);
currentPlan.add(poForEach);
currentPlan.add(poSort);
currentPlan.add(poCounter);
currentPlan.add(poRank);