@Override
    public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
      Object rowExprVal = ObjectInspectorUtils.copyToStandardObject(parameters[0], inputOI[0]);
      Object defaultVal = parameters.length > 2 ? ObjectInspectorUtils.copyToStandardObject(
              defaultValueConverter.convert(parameters[2]), inputOI[0]) : null;
      ((LeadLagBuffer) agg).addRow(rowExprVal, defaultVal);
    }
abstract class for Lead &amp; lag UDAFs GenericUDAFLeadLag.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFLeadLag.java