[SPARK-2873] [SQL] using ExternalAppendOnlyMap to resolve OOM when aggregating

Using ExternalAppendOnlyMap to resolve OOM when aggregating.
Using "spark.shuffle.spill" to open it or not 
Hive udaf does not support yet for udaf need Serializable

Join has  the same problem. but using ExternalAppendOnlyMap as CoGroupedRDD  seems to reduce performance. i try another way by using ExternalAppendOnlyMap. but it needs testing .i will commit it in another batch.

You can access the private member directly here, as they are the same type. So the `getXXX` methods is not necessary.
e.g.
```
scala> class A(private var a: Int) {
     |   def add(v: A): A = {
     |     a = a + v.a
     |     this
     |   }
     |   override def toString = {a.toString}
     | }
defined class A

scala> val a = new A(11)
a: A = 11

scala> val b = new A(12)
b: A = 12

scala> val c = a.add(b)
c: A = 23
```