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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidadd(double v) Adds v to the accumulator, i.e.voidAdds v to the accumulator, i.e.doubleavg()Returns the average of elements added to the accumulator.copy()Creates a new copy of this accumulator.longcount()Returns the number of elements added to the accumulator.booleanisZero()Returns false if this accumulator has had any values added to it or the sum is non-zero.voidmerge(AccumulatorV2<Double, Double> other) Merges another same-type accumulator into this one and update its state, i.e.voidreset()Resets this accumulator, which is zero value.doublesum()Returns the sum of elements added to the accumulator.value()Defines the current value of this accumulatorMethods inherited from class org.apache.spark.util.AccumulatorV2copyAndReset, excludeFromHeartbeat, id, isRegistered, name, toString
- 
Constructor Details- 
DoubleAccumulatorpublic DoubleAccumulator()
 
- 
- 
Method Details- 
addAdds v to the accumulator, i.e. increment sum by v and count by 1.- Specified by:
- addin class- AccumulatorV2<Double,- Double> 
- Parameters:
- v- (undocumented)
- Since:
- 2.0.0
 
- 
addpublic 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
 
- 
avgpublic double avg()Returns the average of elements added to the accumulator.- Returns:
- (undocumented)
- Since:
- 2.0.0
 
- 
copyDescription copied from class:AccumulatorV2Creates a new copy of this accumulator.- Specified by:
- copyin class- AccumulatorV2<Double,- Double> 
- Returns:
- (undocumented)
 
- 
countpublic long count()Returns the number of elements added to the accumulator.- Returns:
- (undocumented)
- Since:
- 2.0.0
 
- 
isZeropublic boolean isZero()Returns false if this accumulator has had any values added to it or the sum is non-zero.- Specified by:
- isZeroin class- AccumulatorV2<Double,- Double> 
- Returns:
- (undocumented)
 
- 
mergeDescription copied from class:AccumulatorV2Merges another same-type accumulator into this one and update its state, i.e. this should be merge-in-place.- Specified by:
- mergein class- AccumulatorV2<Double,- Double> 
- Parameters:
- other- (undocumented)
 
- 
resetpublic void reset()Description copied from class:AccumulatorV2Resets this accumulator, which is zero value. i.e. callisZeromust return true.- Specified by:
- resetin class- AccumulatorV2<Double,- Double> 
 
- 
sumpublic double sum()Returns the sum of elements added to the accumulator.- Returns:
- (undocumented)
- Since:
- 2.0.0
 
- 
valueDescription copied from class:AccumulatorV2Defines the current value of this accumulator- Specified by:
- valuein class- AccumulatorV2<Double,- Double> 
- Returns:
- (undocumented)
 
 
-