Order order)
throws HiveException
{
ArrayList<Object> vals = new ArrayList<Object>();
GenericUDAFEvaluator fEval = wFnDef.getWFnEval();
Object[] args = new Object[wFnDef.getArgs() == null ? 0 : wFnDef.getArgs().size()];
for(int i=0; i < iPart.size(); i++)
{
AggregationBuffer aggBuffer = fEval.getNewAggregationBuffer();
Range rng = getRange(wFnDef, i, iPart, order);
PTFPartitionIterator<Object> rItr = rng.iterator();
PTFOperator.connectLeadLagFunctionsToPartition(ptfDesc, rItr);
while(rItr.hasNext())
{
Object row = rItr.next();
int j = 0;
if ( wFnDef.getArgs() != null ) {
for(PTFExpressionDef arg : wFnDef.getArgs())
{
args[j++] = arg.getExprEvaluator().evaluate(row);
}
}
fEval.aggregate(aggBuffer, args);
}
Object out = fEval.evaluate(aggBuffer);
out = ObjectInspectorUtils.copyToStandardObject(out, wFnDef.getOI());
vals.add(out);
}
return vals;
}