}
static DataBag EvaluateOperator(LogicalOperator logOp, LineageTracer lineageTracer, Map<LogicalOperator, DataBag> derivedData, Map<OperatorKey, OperatorKey> logicalToPhysicalKeys, Map<OperatorKey, ExecPhysicalOperator> physicalOpTable) throws IOException {
//We have the compiled physical plan. We just replace the inputs to the physical operator corresponding to the supplied logical
//operator by POReads reading from databags from the derivedData
PhysicalOperator pOp = (PhysicalOperator)physicalOpTable.get(logicalToPhysicalKeys.get(logOp.getOperatorKey()));
if(lineageTracer != null) {
pOp.setLineageTracer(lineageTracer);
}
OperatorKey[] origInputs = new OperatorKey[pOp.inputs.length];
for(int i = 0; i < origInputs.length; ++i) {
origInputs[i] = pOp.inputs[i];
}
for(int i = 0; i < pOp.inputs.length; ++i) {
PORead read = new PORead(logOp.getScope(),
NodeIdGenerator.getGenerator().getNextNodeId(logOp.getScope()),
physicalOpTable,
LogicalOperator.FIXED,
derivedData.get(logOp.getOpTable().get(logOp.getInputs().get(i))));
pOp.inputs[i] = read.getOperatorKey();
}
//get the output data
DataBag outputData = BagFactory.getInstance().newDefaultBag();
pOp.open();
Tuple t = pOp.getNext();
while(t != null) {
outputData.add(t);
t = pOp.getNext();
}
pOp.close();
//restore the physical operator to its previous form
pOp.setLineageTracer(null);
for(int i = 0; i < origInputs.length; ++i) {
physicalOpTable.remove(pOp.inputs[i]);
pOp.inputs[i] = origInputs[i];
}