Class DoubleAccumulator

Object
org.apache.spark.util.AccumulatorV2<Double,Double>
org.apache.spark.util.DoubleAccumulator
All Implemented Interfaces:
Serializable

public class DoubleAccumulator extends AccumulatorV2<Double,Double>
An accumulator for computing sum, count, and averages for double precision floating numbers.

Since:
2.0.0
See Also:
  • Constructor Details

    • DoubleAccumulator

      public DoubleAccumulator()
  • Method Details

    • add

      public void add(Double v)
      Adds v to the accumulator, i.e. increment sum by v and count by 1.
      Specified by:
      add in class AccumulatorV2<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

      public DoubleAccumulator copy()
      Description copied from class: AccumulatorV2
      Creates a new copy of this accumulator.
      Specified by:
      copy in class AccumulatorV2<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 class AccumulatorV2<Double,Double>
      Returns:
      (undocumented)
    • merge

      public void merge(AccumulatorV2<Double,Double> other)
      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 class AccumulatorV2<Double,Double>
      Parameters:
      other - (undocumented)
    • reset

      public void reset()
      Description copied from class: AccumulatorV2
      Resets this accumulator, which is zero value. i.e. call isZero must return true.
      Specified by:
      reset in class AccumulatorV2<Double,Double>
    • sum

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

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