From 16bf2a8155a0bf95e8a0cb59de32df888b107cb7 Mon Sep 17 00:00:00 2001 From: lorenz <stu203404@mail.uni-kiel.de> Date: Mon, 28 Feb 2022 16:14:10 +0100 Subject: [PATCH] Add combine and deduct function to aggregator --- ...ggregatedActivePowerRecordAccumulator.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/theodolite-benchmarks/uc4-hazelcastjet/src/main/java/theodolite/uc4/application/uc4specifics/AggregatedActivePowerRecordAccumulator.java b/theodolite-benchmarks/uc4-hazelcastjet/src/main/java/theodolite/uc4/application/uc4specifics/AggregatedActivePowerRecordAccumulator.java index 7ccda5474..90a2f2844 100644 --- a/theodolite-benchmarks/uc4-hazelcastjet/src/main/java/theodolite/uc4/application/uc4specifics/AggregatedActivePowerRecordAccumulator.java +++ b/theodolite-benchmarks/uc4-hazelcastjet/src/main/java/theodolite/uc4/application/uc4specifics/AggregatedActivePowerRecordAccumulator.java @@ -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; } -- GitLab