Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
//TODO Code it

Nilesh Injulkar injulkarnilesh

:octocat:
//TODO Code it
View GitHub Profile
@lovasoa
lovasoa / VectorMean.scala
Created Feb 15, 2018
spark UDAF for computing the mean of vectors
View VectorMean.scala
import org.apache.spark.ml.linalg.SQLDataTypes.VectorType
import org.apache.spark.ml.linalg.{Vector, Vectors}
import org.apache.spark.sql.Row
import org.apache.spark.sql.expressions.{MutableAggregationBuffer, UserDefinedAggregateFunction}
import org.apache.spark.sql.types._
class VectorMean extends UserDefinedAggregateFunction {
// This is the input fields for your aggregate function.