@Override public void agg(Object newVal){
  if (newVal instanceof byte[]) {
    ByteBuffer buffer=ByteBuffer.wrap((byte[])newVal);
    buffer.rewind();
    while (buffer.hasRemaining()) {
      aggVal+=buffer.getLong();
      count+=buffer.getDouble();
      firstTime=false;
    }
    return;
  }
  aggVal+=(Long)newVal;
  count++;
  firstTime=false;
}

@ Override public void agg ( Object newVal ) { if ( newVal instanceof byte [ ] ) { ByteBuffer buffer = ByteBuffer . wrap ( ( byte [ ] ) newVal ) ; buffer . rewind ( ) ; while ( buffer . hasRemaining ( ) ) { aggVal += buffer . getLong ( ) ; count += buffer . getDouble ( ) ; firstTime = false ; } return ; } aggVal += ( Long ) newVal ; count ++ ; firstTime = false ; }
average aggregate function which will add all the aggregate values and it will increment the total count every time , for average value
