Skip to content

Commit 0bb0e33

Browse files
committed
Remove "display" variable and assume display = name.isDefined
1 parent 0ec4ac7 commit 0bb0e33

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

core/src/main/scala/org/apache/spark/Accumulators.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,20 @@ import org.apache.spark.serializer.JavaSerializer
3636
*
3737
* @param initialValue initial value of accumulator
3838
* @param param helper object defining how to add elements of type `R` and `T`
39-
* @param _name human-readable name for use in Spark's web UI
40-
* @param display whether to show accumulator values Spark's web UI
39+
* @param name human-readable name for use in Spark's web UI
4140
* @tparam R the full accumulated data (result type)
4241
* @tparam T partial data that can be added in
4342
*/
4443
class Accumulable[R, T] (
4544
@transient initialValue: R,
4645
param: AccumulableParam[R, T],
47-
_name: Option[String],
48-
val display: Boolean)
46+
val name: Option[String])
4947
extends Serializable {
5048

5149
def this(@transient initialValue: R, param: AccumulableParam[R, T]) =
52-
this(initialValue, param, None, true)
50+
this(initialValue, param, None)
5351

5452
val id: Long = Accumulators.newId
55-
val name = _name.getOrElse(s"accumulator_$id")
5653

5754
@transient private var value_ = initialValue // Current value on master
5855
val zero = param.zero(initialValue) // Zero value to be passed to workers
@@ -228,9 +225,9 @@ GrowableAccumulableParam[R <% Growable[T] with TraversableOnce[T] with Serializa
228225
* @param param helper object defining how to add elements of type `T`
229226
* @tparam T result type
230227
*/
231-
class Accumulator[T](@transient initialValue: T, param: AccumulatorParam[T], name: Option[String],
232-
display: Boolean) extends Accumulable[T,T](initialValue, param, name, display) {
233-
def this(initialValue: T, param: AccumulatorParam[T]) = this(initialValue, param, None, false)
228+
class Accumulator[T](@transient initialValue: T, param: AccumulatorParam[T], name: Option[String])
229+
extends Accumulable[T,T](initialValue, param, name) {
230+
def this(initialValue: T, param: AccumulatorParam[T]) = this(initialValue, param, None)
234231
}
235232

236233
/**

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ class SparkContext(config: SparkConf) extends Logging {
763763
* driver can access the accumulator's `value`.
764764
*/
765765
def accumulator[T](initialValue: T, name: String)(implicit param: AccumulatorParam[T]) = {
766-
new Accumulator(initialValue, param, Some(name), true)
766+
new Accumulator(initialValue, param, Some(name))
767767
}
768768

769769
/**
@@ -783,7 +783,7 @@ class SparkContext(config: SparkConf) extends Logging {
783783
* @tparam R type that can be added to the accumulator
784784
*/
785785
def accumulable[T, R](initialValue: T, name: String)(implicit param: AccumulableParam[T, R]) =
786-
new Accumulable(initialValue, param, Some(name), true)
786+
new Accumulable(initialValue, param, Some(name))
787787

788788
/**
789789
* Create an accumulator from a "mutable collection" type.

core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,12 @@ class DAGScheduler(
819819
Accumulators.add(event.accumUpdates) // TODO: do this only if task wasn't resubmitted
820820
event.accumUpdates.foreach { case (id, partialValue) =>
821821
val acc = Accumulators.originals(id).asInstanceOf[Accumulable[Any, Any]]
822-
val name = acc.name
823822
// To avoid UI cruft, ignore cases where value wasn't updated
824-
if (partialValue != acc.zero) {
823+
if (acc.name.isDefined && partialValue != acc.zero) {
824+
val name = acc.name.get
825825
val stringPartialValue = "%s".format(partialValue)
826826
val stringValue = "%s".format(acc.value)
827-
stageToInfos(stage).accumulables(id) = AccumulableInfo(id, acc.name, stringValue)
827+
stageToInfos(stage).accumulables(id) = AccumulableInfo(id, name, stringValue)
828828
event.taskInfo.accumulables +=
829829
AccumulableInfo(id, name, Some(stringPartialValue), stringValue)
830830
}

0 commit comments

Comments
 (0)