everybody! I'm coding a spark project mixing scala and java languages. Some classes were coding in Java, while i'm handling the Spark in Scala. I need use custom accumulator class (BagAccum extends AccumulatorV2[Int, Bag]) with Int as type in and Bag as type out. The Bag type is a java class in the project. The compiler show me the error:
BagAccum needs to be abstract, since method value in class AccumulatorV2 of type => structure.Bag is not defined main.scala /BagGraph/src line 75 Scala Problem
In this case, how i can define the Bag class? Below, the complete code for BagAccum scala class.
This is my code, declaring the BagAccum class.
class BagAccum extends AccumulatorV2[Int, Bag] {
private var bag:Bag = new Bag
override def isZero: Boolean = bag.empty()
override def copy(): BagAccum = {
val newBag = new BagAccum
newBag.bag = this.bag
newBag
}
override def reset(): Unit = bag = null
override def add(v: Int): Unit ={
bag.insert(v)
}
override def merge(other: AccumulatorV2[Int, Bag]): Unit = bag.merge(other.value)
def size():Int = bag.size()
}