protected Object calcFunctionValue(PTFPartitionIterator<Object> pItr, LeadLagInfo leadLagInfo)
      throws HiveException {
    // To handle the case like SUM(LAG(f)) over(), aggregation function includes
    // LAG/LEAD call
    PTFOperator.connectLeadLagFunctionsToPartition(leadLagInfo, pItr);

    AggregationBuffer aggBuffer = wrappedEvaluator.getNewAggregationBuffer();
    if (isCountEvaluator && parameters == null) {
      // count(*) specific optimisation, where record count would be equal to itr count
      // No need to iterate through entire iterator and read rowContainer again
      return ObjectInspectorUtils.copyToStandardObject(new LongWritable(pItr.count()), outputOI);
    }

    Object[] argValues = new Object[parameters == null ? 0 : parameters.size()];
    while(pItr.hasNext()) {
      Object row = pItr.next();
      int i = 0;
      if ( parameters != null ) {
        for(PTFExpressionDef param : parameters)
        {
          argValues[i++] = param.getExprEvaluator().evaluate(row);
        }
      }
      wrappedEvaluator.aggregate(aggBuffer, argValues);
    }

    // The object is reused during evaluating, make a copy here
    return ObjectInspectorUtils.copyToStandardObject(wrappedEvaluator.evaluate(aggBuffer), outputOI);
  }
Given a partition iterator, calculate the function value
@param pItr  the partition pointer
@return      the function value
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/BasePartitionEvaluator.java