From e88c7f79377e03a92eb8623857b406f7df80446c Mon Sep 17 00:00:00 2001
From: Florian Fittkau <ffi@informatik.uni-kiel.de>
Date: Wed, 18 Mar 2015 13:11:46 +0100
Subject: [PATCH] WiP

---
 .../TraceReconstructionBuffer.java            |  2 +-
 .../reduction/TracesSummarizationBuffer.java  | 11 ++++++----
 .../reduction/TracesSummarizationFilter.java  | 22 +++++++++++--------
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/src/explorviz/live_trace_processing/filter/reconstruction/TraceReconstructionBuffer.java b/src/explorviz/live_trace_processing/filter/reconstruction/TraceReconstructionBuffer.java
index 185ce58..c1b0bb6 100644
--- a/src/explorviz/live_trace_processing/filter/reconstruction/TraceReconstructionBuffer.java
+++ b/src/explorviz/live_trace_processing/filter/reconstruction/TraceReconstructionBuffer.java
@@ -113,7 +113,7 @@ class TraceReconstructionBuffer {
 				// reconstruction
 				final RuntimeStatisticInformation runtimeStatisticInformation = runtimeStatisticInformationList
 						.get(0);
-				if (runtimeStatisticInformation.getAverage() < 0) {
+				if (!runtimeStatisticInformation.isInitialized()) {
 					runtimeStatisticInformation.set(1, methodDuration, methodDuration
 							* methodDuration);
 				}
diff --git a/src/explorviz/live_trace_processing/filter/reduction/TracesSummarizationBuffer.java b/src/explorviz/live_trace_processing/filter/reduction/TracesSummarizationBuffer.java
index a87fe4c..a40b233 100644
--- a/src/explorviz/live_trace_processing/filter/reduction/TracesSummarizationBuffer.java
+++ b/src/explorviz/live_trace_processing/filter/reduction/TracesSummarizationBuffer.java
@@ -64,23 +64,26 @@ class TracesSummarizationBuffer {
 									.get(indexInHostList1);
 							final RuntimeStatisticInformation runtime2 = runtimeList2.get(j);
 
-							if ((runtimeList1.size() == 1) && (runtimeList2.size() == 1)) {
+							if (!runtime2.isInitialized()) {
 								runtime1.merge(runtime2,
 										getRightObjectId(abstractBeforeEventRecord2));
 							} else {
 								runtime1.merge(runtime2);
 							}
 						} else {
-							// not found, so insert and merge later
+							// not found, so insert later
 							toAdd.put(host2, runtimeList2.get(j));
-							System.out.println("not found...");
 						}
 					}
 
 					for (final Entry<HostApplicationMetaDataRecord, RuntimeStatisticInformation> entry : toAdd
 							.entrySet()) {
 						hostMetaList1.add(entry.getKey());
-						runtimeList1.add(entry.getValue());
+						final RuntimeStatisticInformation runtime2 = entry.getValue();
+						if (!runtime2.isInitialized()) {
+							runtime2.makeAccumulator(getRightObjectId(abstractBeforeEventRecord2));
+						}
+						runtimeList1.add(runtime2);
 					}
 				} else {
 					final List<HostApplicationMetaDataRecord> hostMetaList1 = event
diff --git a/src/explorviz/live_trace_processing/filter/reduction/TracesSummarizationFilter.java b/src/explorviz/live_trace_processing/filter/reduction/TracesSummarizationFilter.java
index bd7c981..1a439f3 100644
--- a/src/explorviz/live_trace_processing/filter/reduction/TracesSummarizationFilter.java
+++ b/src/explorviz/live_trace_processing/filter/reduction/TracesSummarizationFilter.java
@@ -76,24 +76,28 @@ public class TracesSummarizationFilter extends AbstractFilter {
 		traceAggregationBuffer.insertTrace(trace);
 	}
 
-	public void makeTraceElementsAccumulator(final Trace trace) {
+	private void makeTraceElementsAccumulator(final Trace trace) {
 		final List<AbstractEventRecord> traceEvents = trace.getTraceEvents();
 
 		for (final AbstractEventRecord event : traceEvents) {
 			if (event instanceof AbstractBeforeEventRecord) {
 				final AbstractBeforeEventRecord abstractBeforeEventRecord = (AbstractBeforeEventRecord) event;
 
-				int objectId = 0;
-
-				if (abstractBeforeEventRecord instanceof AbstractBeforeOperationEventRecord) {
-					final AbstractBeforeOperationEventRecord abstractBeforeOperationEventRecord = (AbstractBeforeOperationEventRecord) abstractBeforeEventRecord;
-					objectId = abstractBeforeOperationEventRecord.getObjectId();
-				}
-
 				final List<RuntimeStatisticInformation> runtimeStatisticInformationList = abstractBeforeEventRecord
 						.getRuntimeStatisticInformationList();
 				if (runtimeStatisticInformationList.size() == 1) {
-					runtimeStatisticInformationList.get(0).makeAccumulator(objectId);
+					final RuntimeStatisticInformation runtimeStatisticInformation = runtimeStatisticInformationList
+							.get(0);
+					if (!runtimeStatisticInformation.isInitialized()) {
+						int objectId = 0;
+
+						if (abstractBeforeEventRecord instanceof AbstractBeforeOperationEventRecord) {
+							final AbstractBeforeOperationEventRecord abstractBeforeOperationEventRecord = (AbstractBeforeOperationEventRecord) abstractBeforeEventRecord;
+							objectId = abstractBeforeOperationEventRecord.getObjectId();
+						}
+
+						runtimeStatisticInformation.makeAccumulator(objectId);
+					}
 				}
 			}
 		}
-- 
GitLab