Package org.apache.spark.util
Class LongAccumulator
 All Implemented Interfaces:
Serializable
,scala.Serializable
An
accumulator
for computing sum, count, and average of 64bit integers.
 Since:
 2.0.0
 See Also:

Constructor Summary

Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long v) Adds v to the accumulator, i.e. increment sum by v and count by 1.void
Adds v to the accumulator, i.e. increment sum by v and count by 1.double
avg()
Returns the average of elements added to the accumulator.copy()
Creates a new copy of this accumulator.long
count()
Returns the number of elements added to the accumulator.boolean
isZero()
Returns false if this accumulator has had any values added to it or the sum is nonzero.void
merge
(AccumulatorV2<Long, Long> other) Merges another sametype accumulator into this one and update its state, i.e. this should be mergeinplace.void
reset()
Resets this accumulator, which is zero value. i.e. callisZero
must return true.long
sum()
Returns the sum of elements added to the accumulator.value()
Defines the current value of this accumulatorMethods inherited from class org.apache.spark.util.AccumulatorV2
copyAndReset, id, isRegistered, name, toString

Constructor Details

LongAccumulator
public LongAccumulator()


Method Details

add
Adds v to the accumulator, i.e. increment sum by v and count by 1. Specified by:
add
in classAccumulatorV2<Long,
Long>  Parameters:
v
 (undocumented) Since:
 2.0.0

add
public void add(long v) Adds v to the accumulator, i.e. increment sum by v and count by 1. Parameters:
v
 (undocumented) Since:
 2.0.0

avg
public double avg()Returns the average of elements added to the accumulator. Returns:
 (undocumented)
 Since:
 2.0.0

copy
Description copied from class:AccumulatorV2
Creates a new copy of this accumulator. Specified by:
copy
in classAccumulatorV2<Long,
Long>  Returns:
 (undocumented)

count
public long count()Returns the number of elements added to the accumulator. Returns:
 (undocumented)
 Since:
 2.0.0

isZero
public boolean isZero()Returns false if this accumulator has had any values added to it or the sum is nonzero. Specified by:
isZero
in classAccumulatorV2<Long,
Long>  Returns:
 (undocumented)
 Since:
 2.0.0

merge
Description copied from class:AccumulatorV2
Merges another sametype accumulator into this one and update its state, i.e. this should be mergeinplace. Specified by:
merge
in classAccumulatorV2<Long,
Long>  Parameters:
other
 (undocumented)

reset
public void reset()Description copied from class:AccumulatorV2
Resets this accumulator, which is zero value. i.e. callisZero
must return true. Specified by:
reset
in classAccumulatorV2<Long,
Long>

sum
public long sum()Returns the sum of elements added to the accumulator. Returns:
 (undocumented)
 Since:
 2.0.0

value
Description copied from class:AccumulatorV2
Defines the current value of this accumulator Specified by:
value
in classAccumulatorV2<Long,
Long>  Returns:
 (undocumented)
