Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ class LongAccumulator extends AccumulatorV2[jl.Long, jl.Long] {
private var _count = 0L

/**
* Adds v to the accumulator, i.e. increment sum by v and count by 1.
* Returns false if this accumulator has had any values added to it or the sum is non-zero.
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this duplicates the doc from AccumulatorV2.isZero. Can we simply remove this wrong doc and revert other changes so that we can reuse inherited doc from AccumulatorV2.isZero in all places?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current documentation for AccumulatorV2.isZero would be misleading for the behaviour shown when values have been added to the accumulator, but the sum is zero. This still would return false, even though it is a non-count accumulator. I don't believe that any of the implementations in this file actually behave exactly as described by AccumulatorV2.isZero.

* @since 2.0.0
*/
override def isZero: Boolean = _sum == 0L && _count == 0
Expand Down Expand Up @@ -368,6 +369,9 @@ class DoubleAccumulator extends AccumulatorV2[jl.Double, jl.Double] {
private var _sum = 0.0
private var _count = 0L

/**
* Returns false if this accumulator has had any values added to it or the sum is non-zero.
*/
override def isZero: Boolean = _sum == 0.0 && _count == 0

override def copy(): DoubleAccumulator = {
Expand Down Expand Up @@ -441,6 +445,9 @@ class DoubleAccumulator extends AccumulatorV2[jl.Double, jl.Double] {
class CollectionAccumulator[T] extends AccumulatorV2[T, java.util.List[T]] {
private val _list: java.util.List[T] = Collections.synchronizedList(new ArrayList[T]())

/**
* Returns false if this accumulator instance has any values in it.
*/
override def isZero: Boolean = _list.isEmpty

override def copyAndReset(): CollectionAccumulator[T] = new CollectionAccumulator
Expand Down