spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Mocanu <>
Subject closures & moving averages (state)
Date Wed, 26 Mar 2014 15:34:31 GMT
I'm passing a moving average function during the map phase like this:
  val average= new Sma(window=3)> average.addNumber(x))

  class Sma extends Serializable { .. }

I also tried to put creation of object average in an object like I saw in another post:
 object Average {
    val smaFn = new VSRTXYSimpleMovingAverage[(String, Long)](3)
Every time  average.addNumber is called it is a new instance.
How can I preserve state of average object?


View raw message