I have an assignment in Scala, so far, so good. Everything compiles except this:
@transient val aggs = msgs.transform { rdd =>
val ts = rdd.map(quote => quote.ts).max() /// maximum of timestamp in the rdd
rdd.map{ q =>
((q.symbol,q.ts),(q.price,ts)) /// ((String, Long), (Double, Long)) structure
}
}
.reduceByKey{ (x,y) => (x._1 + y._1, x._2 + y._2) } // returns (Double, Long)
.mapValues( (x: Double,y: Long) => (y.toDouble / x.toDouble) ) // (Double, Long) => (Double)
.map{ case ((s,t),v) => (s,t,v)}
The piece I'm stuck on is the anonymous function in mapValues()
:95: error: type mismatch;
found : (Double, Long) => Double
required: ((Double, Long)) => ?
Can anyone point me in the right direction ?