Package org.apache.spark.util
Class DoubleAccumulator
- All Implemented Interfaces:
Serializable
An
accumulator
for computing sum, count, and averages for double precision
floating numbers.
- Since:
- 2.0.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double v) Adds v to the accumulator, i.e.void
Adds v to the accumulator, i.e.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 non-zero.void
merge
(AccumulatorV2<Double, Double> other) Merges another same-type accumulator into this one and update its state, i.e.void
reset()
Resets this accumulator, which is zero value.double
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
-
DoubleAccumulator
public DoubleAccumulator()
-
-
Method Details
-
add
Adds v to the accumulator, i.e. increment sum by v and count by 1.- Specified by:
add
in classAccumulatorV2<Double,
Double> - Parameters:
v
- (undocumented)- Since:
- 2.0.0
-
add
public void add(double 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<Double,
Double> - 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 non-zero.- Specified by:
isZero
in classAccumulatorV2<Double,
Double> - Returns:
- (undocumented)
-
merge
Description copied from class:AccumulatorV2
Merges another same-type accumulator into this one and update its state, i.e. this should be merge-in-place.- Specified by:
merge
in classAccumulatorV2<Double,
Double> - 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<Double,
Double>
-
sum
public double 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<Double,
Double> - Returns:
- (undocumented)
-