au.csiro.sparkle.spark.Counter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of variant-spark_2.11 Show documentation
Show all versions of variant-spark_2.11 Show documentation
Genomic variants interpretation toolkit
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);
}
}