|
18 | 18 | package org.apache.spark |
19 | 19 |
|
20 | 20 | import java.io.{ObjectInputStream, Serializable} |
21 | | -import java.util.concurrent.atomic.AtomicLong |
22 | | -import java.lang.ThreadLocal |
23 | 21 |
|
24 | 22 | import scala.collection.generic.Growable |
25 | 23 | import scala.collection.mutable.Map |
@@ -109,7 +107,7 @@ class Accumulable[R, T] ( |
109 | 107 | * The typical use of this method is to directly mutate the local value, eg., to add |
110 | 108 | * an element to a Set. |
111 | 109 | */ |
112 | | - def localValue = value_ |
| 110 | + def localValue: R = value_ |
113 | 111 |
|
114 | 112 | /** |
115 | 113 | * Set the accumulator's value; only allowed on master. |
@@ -137,7 +135,7 @@ class Accumulable[R, T] ( |
137 | 135 | Accumulators.register(this, false) |
138 | 136 | } |
139 | 137 |
|
140 | | - override def toString = if (value_ == null) "null" else value_.toString |
| 138 | + override def toString: String = if (value_ == null) "null" else value_.toString |
141 | 139 | } |
142 | 140 |
|
143 | 141 | /** |
@@ -257,22 +255,22 @@ object AccumulatorParam { |
257 | 255 |
|
258 | 256 | implicit object DoubleAccumulatorParam extends AccumulatorParam[Double] { |
259 | 257 | def addInPlace(t1: Double, t2: Double): Double = t1 + t2 |
260 | | - def zero(initialValue: Double) = 0.0 |
| 258 | + def zero(initialValue: Double): Double = 0.0 |
261 | 259 | } |
262 | 260 |
|
263 | 261 | implicit object IntAccumulatorParam extends AccumulatorParam[Int] { |
264 | 262 | def addInPlace(t1: Int, t2: Int): Int = t1 + t2 |
265 | | - def zero(initialValue: Int) = 0 |
| 263 | + def zero(initialValue: Int): Int = 0 |
266 | 264 | } |
267 | 265 |
|
268 | 266 | implicit object LongAccumulatorParam extends AccumulatorParam[Long] { |
269 | | - def addInPlace(t1: Long, t2: Long) = t1 + t2 |
270 | | - def zero(initialValue: Long) = 0L |
| 267 | + def addInPlace(t1: Long, t2: Long): Long = t1 + t2 |
| 268 | + def zero(initialValue: Long): Long = 0L |
271 | 269 | } |
272 | 270 |
|
273 | 271 | implicit object FloatAccumulatorParam extends AccumulatorParam[Float] { |
274 | | - def addInPlace(t1: Float, t2: Float) = t1 + t2 |
275 | | - def zero(initialValue: Float) = 0f |
| 272 | + def addInPlace(t1: Float, t2: Float): Float = t1 + t2 |
| 273 | + def zero(initialValue: Float): Float = 0f |
276 | 274 | } |
277 | 275 |
|
278 | 276 | // TODO: Add AccumulatorParams for other types, e.g. lists and strings |
@@ -351,6 +349,7 @@ private[spark] object Accumulators extends Logging { |
351 | 349 | } |
352 | 350 | } |
353 | 351 |
|
354 | | - def stringifyPartialValue(partialValue: Any) = "%s".format(partialValue) |
355 | | - def stringifyValue(value: Any) = "%s".format(value) |
| 352 | + def stringifyPartialValue(partialValue: Any): String = "%s".format(partialValue) |
| 353 | + |
| 354 | + def stringifyValue(value: Any): String = "%s".format(value) |
356 | 355 | } |
0 commit comments