spark-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Zhemzhitsky <>
Subject Accumulators of Spark 1.x no longer work with Spark 2.x
Date Thu, 15 Mar 2018 21:55:10 GMT
Hi there,

I've noticed that accumulators of Spark 1.x no longer work with Spark
2.x failing with
java.lang.AssertionError: assertion failed: copyAndReset must return a
zero value copy

It happens while serializing an accumulator here [1] although
copyAndReset returns zero-value copy for sure, just consider the
accumulator below

val concatParam = new AccumulatorParam[jl.StringBuilder] {
  override def zero(initialValue: jl.StringBuilder): jl.StringBuilder
= new jl.StringBuilder()
  override def addInPlace(r1: jl.StringBuilder, r2: jl.StringBuilder):
jl.StringBuilder = r1.append(r2)

So, Spark treats zero value as non-zero due to how isZero [2] is
implemented in LegacyAccumulatorWrapper

override def isZero: Boolean = _value ==

All this means, that the values to be accumulated must implement
equals and hashCode, otherwise isZero is very likely to always return

So I'm wondering why this assertion is necessary and whether it can be
safely removed from there?


To unsubscribe e-mail:

View raw message