https://www.nitendratech.com/spark/udaf-apache-spark/
User-Defined Aggregate Functions(UDAF) Using Apache Spark