Class LongAccumulator

Object
org.apache.spark.util.AccumulatorV2<Long,Long>
org.apache.spark.util.LongAccumulator
All Implemented Interfaces:
Serializable, scala.Serializable

public class LongAccumulator extends AccumulatorV2<Long,Long>
An accumulator for computing sum, count, and average of 64-bit integers.

Since:
2.0.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(long v)
    Adds v to the accumulator, i.e. increment sum by v and count by 1.
    void
    add(Long v)
    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.
    Creates a new copy of this accumulator.
    long
    Returns the number of elements added to the accumulator.
    boolean
    Returns false if this accumulator has had any values added to it or the sum is non-zero.
    void
    Merges another same-type accumulator into this one and update its state, i.e. this should be merge-in-place.
    void
    Resets this accumulator, which is zero value. i.e. call isZero must return true.
    long
    sum()
    Returns the sum of elements added to the accumulator.
    Defines the current value of this accumulator

    Methods inherited from class org.apache.spark.util.AccumulatorV2

    copyAndReset, id, isRegistered, name, toString

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LongAccumulator

      public LongAccumulator()
  • Method Details

    • add

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

      public LongAccumulator copy()
      Description copied from class: AccumulatorV2
      Creates a new copy of this accumulator.
      Specified by:
      copy in class AccumulatorV2<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 non-zero.

      Specified by:
      isZero in class AccumulatorV2<Long,Long>
      Returns:
      (undocumented)
      Since:
      2.0.0
    • merge

      public void merge(AccumulatorV2<Long,Long> 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<Long,Long>
      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<Long,Long>
    • sum

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

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