Hello,
I have been trying to implement a custom accumulator as below
import org.apache.spark._
class VectorNew1(val data: Array[Double]) {}
implicit object VectorAP extends AccumulatorParam[VectorNew1] {
def zero(v: VectorNew1) = new VectorNew1(new Array(v.data.size))
def addInPlace(v1: VectorNew1, v2: VectorNew1) = {
for (i <- 0 to v1.data.size - 1) v1.data(i) += v2.data(i)
v1
}
}
// Create an accumulator counter of length = Number of columns which is in
turn derived from the header
val actualCounters1 = sc.accumulator(new
VectorNew1(Array.fill[Double](2)(0)))
onlySplitFile.foreach(oneRow => {
// println("Here")
// println(oneRow(0))
// for(eachColumnValue <- oneRow)
// {
actualCounters1 += new VectorNew1(Array(1,1))
// }
})
I am receiving the following error
Error: type mismatch;
Found : VectorNew1
Required : vectorNew1
actualCounters1 += new VectorNew1(Array(1,1))
Could someone help me with this?
Thank You
Vinay