Skip to content
Snippets Groups Projects
Commit 16bf2a81 authored by Lorenz Boguhn's avatar Lorenz Boguhn
Browse files

Add combine and deduct function to aggregator

parent 9a68b8eb
No related branches found
No related tags found
1 merge request!208Add benchmark implementations for Hazelcast Jet
......@@ -53,6 +53,27 @@ public class AggregatedActivePowerRecordAccumulator {
this.averageInW = sumInW / count;
}
/**
* Adds the records from another aggregator.
*/
public void addInputs(final double sumInW, final long count, final long timestamp) {
this.sumInW += sumInW;
this.count += count;
this.timestamp = Math.max(this.timestamp, timestamp);
this.averageInW = this.sumInW / this.count;
}
/**
* Removes the values of another aggreagator.
* Not a complete reset since the old timestamp is lost.
*/
public void removeInputs(final double sumInW, final long count) {
this.sumInW -= sumInW;
this.count -= count;
this.averageInW = this.count == 0 ? 0.0 : this.sumInW / this.count;
this.timestamp = -1L;
}
public long getCount() {
return count;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment