// put into one bag and the next half into another. Then these two
// bags are provided as inputs to two separate calls of <Agg>Intermediate.
// The outputs from the two calls to <Agg>Intermediate are put into a bag
// and sent as input to <Agg>Final
DataBag intermediateInputBg1 = bagFactory.newDefaultBag();
DataBag intermediateInputBg2 = bagFactory.newDefaultBag();
Tuple outputTuple = null;
for(int i = 0; i < 10; i++) {
// create empty bag input to be provided as input
// argument to the "Initial" function
DataBag initialInputBg = bagFactory.newDefaultBag();
Tuple initialInputTuple = tupleFactory.newTuple(initialInputBg);
if(i < 5) {
outputTuple = (Tuple)aggInitial.exec(initialInputTuple);
// check that output is null for all aggs except COUNT
// COUNT will give an output of 0 for empty bag input
checkZeroOrNull(aggInitial, outputTuple.get(0));
intermediateInputBg1.add(outputTuple);
} else {
outputTuple = (Tuple)aggInitial.exec(initialInputTuple);
// check that output is null for all aggs except COUNT
// COUNT will give an output of 0 for empty bag input
checkZeroOrNull(aggInitial, outputTuple.get(0));
intermediateInputBg2.add(outputTuple);
}
}
EvalFunc<?> aggIntermediate = evalFuncMap.get(aggIntermediateTypes[k]);
DataBag finalInputBg = bagFactory.newDefaultBag();
Tuple intermediateInputTuple = tupleFactory.newTuple(intermediateInputBg1);
outputTuple = (Tuple)aggIntermediate.exec(intermediateInputTuple);
// check that output is null for all aggs except COUNT
// COUNT will give an output of 0 for empty bag input
checkZeroOrNull(aggIntermediate, outputTuple.get(0));
finalInputBg.add(outputTuple);
intermediateInputTuple = tupleFactory.newTuple(intermediateInputBg2);
outputTuple = (Tuple)aggIntermediate.exec(intermediateInputTuple);
// check that output is null for all aggs except COUNT
// COUNT will give an output of 0 for empty bag input
checkZeroOrNull(aggIntermediate, outputTuple.get(0));
finalInputBg.add(outputTuple);
Tuple finalInputTuple = tupleFactory.newTuple(finalInputBg);
EvalFunc<?> aggFinal = evalFuncMap.get(aggFinalTypes[k]);
Object output = aggFinal.exec(finalInputTuple);