question: @ Override public void agg ( Object newVal ) { if ( newVal instanceof byte [ ] ) { ByteBuffer buffer = ByteBuffer . wrap ( ( byte [ ] ) newVal ) ; buffer . rewind ( ) ; while ( buffer . hasRemaining ( ) ) { byte [ ] valueByte = new byte [ buffer . getInt ( ) ] ; buffer . get ( valueByte ) ; BigDecimal valueBigDecimal = DataTypeUtil . byteToBigDecimal ( valueByte ) ; aggVal = aggVal . add ( valueBigDecimal ) ; count += buffer . getDouble ( ) ; firstTime = false ; } return ; } if ( firstTime ) { aggVal = ( BigDecimal ) newVal ; firstTime = false ; } else { aggVal = aggVal . add ( ( BigDecimal ) newVal ) ; } count ++ ; }
target:  Average Aggregate function which will add all the aggregate values and it will increment the total count every time, for average value