All Downloads are FREE. Search and download functionalities are using the official Maven repository.

au.csiro.sparkle.spark.Counter Maven / Gradle / Ivy

The newest version!
package au.csiro.sparkle.spark;

import java.io.Serializable;

import org.apache.spark.Accumulator;

// TODO: (Update) to use V2
// import org.apache.spark.util.AccumulatorV2;

public class Counter implements Serializable {
	
    private static final long serialVersionUID = 1L;

    private final Accumulator accumulator;

	public Counter(Accumulator accumulator) {
	    this.accumulator = accumulator;
    }

	public  T inc(T t) {
		accumulator.add(1);
		return t;
	}

	
	public long value() {
		return accumulator.value();
    }

	public void add(int value) {
		accumulator.add(value);
	}

	public void set(int newValue) {
		accumulator.setValue(newValue);
    }
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy