title: How to write a Spark UDAF which simply do row collection?
body: <p>For my specific requirement, I want to write a UDAF, which simply collect all the input rows.</p>
  
  <p>The input is a two column rows, Double Type;</p>
  
  <p>The Intermediate Schema, "I thought", is ArrayList (correct me if I was wrong)</p>
  
  <p>The returned data type is the ArrayList</p>
  
  <p>I wrote an "idea" of my UDAF, but I wish someone to help me finish it.</p>
  
  <pre><code>class CollectorUDAF() extends UserDefinedAggregateFunction {
  
    // Input Data Type Schema
    def inputSchema: StructType = StructType(Array(StructField("value", DoubleType), StructField("y", DoubleType)))
  
    // Intermediate Schema
    def bufferSchema = util.ArrayList[Array(StructField("value", DoubleType), StructField("y", DoubleType)]
  
    // Returned Data Type .
    def dataType: DataType = util.ArrayList[Array(StructField("value", DoubleType), StructField("y", DoubleType)]
  
    // Self-explaining
    def deterministic = true
  
    // This function is called whenever key changes
    def initialize(buffer: MutableAggregationBuffer) = {
  
    }
  
    // Iterate over each entry of a group
    def update(buffer: MutableAggregationBuffer, input: Row) = {
  
  
    }
  
    // Called after all the entries are exhausted.
    def evaluate(buffer: Row) = {
  
    }
  
    def merge(buffer1: MutableAggregationBuffer, buffer2: Row): Unit = {
  
    }
  
  }
  </code></pre>