Issue #1366 - Fix to stats aggregator
Former-commit-id:359cffd60e
[formerly0dd8732067
] [formerly8ad3fa9b60
[formerly ae58feea5fb410725747ab106caa8d194b4b9f57]] Former-commit-id:8ad3fa9b60
Former-commit-id:1a399cf337
This commit is contained in:
parent
bf610cc4f3
commit
fe932e395c
5 changed files with 42 additions and 13 deletions
|
@ -665,12 +665,12 @@ public class StatsDisplayCanvas extends Canvas {
|
|||
|
||||
if (data != null) {
|
||||
// Loop over all group members
|
||||
List<DataPoint> dataMap = data.getData(key);
|
||||
List<DataPoint> dataList = data.getData();
|
||||
long startMillis = graphData.getTimeRange().getStart()
|
||||
.getTime();
|
||||
int lastXpix = -999;
|
||||
int lastYpix = -999;
|
||||
for (DataPoint point : dataMap) {
|
||||
for (DataPoint point : dataList) {
|
||||
long x = point.getX();
|
||||
double y;
|
||||
|
||||
|
@ -752,6 +752,7 @@ public class StatsDisplayCanvas extends Canvas {
|
|||
int x = e.x;
|
||||
int y = e.y;
|
||||
final String colon = ": ";
|
||||
final String nl = "\n";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
GraphData graphData = callback.getGraphData();
|
||||
if (graphData == null) {
|
||||
|
@ -765,11 +766,11 @@ public class StatsDisplayCanvas extends Canvas {
|
|||
// if true then data are on the graph
|
||||
if (rect.contains(x, y)) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append("\n");
|
||||
sb.append(nl);
|
||||
}
|
||||
sb.append(key).append(colon);
|
||||
DataPoint point = graphData.getStatsData(key)
|
||||
.getData(key).get(idx);
|
||||
.getData().get(idx);
|
||||
sb.append(point.getSampleText(view));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,6 +198,10 @@ public class GraphData {
|
|||
* @return
|
||||
*/
|
||||
public double getMinValue(Set<String> visibleDataSet, String view) {
|
||||
if (visibleDataSet.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double min = Double.MAX_VALUE;
|
||||
for (String key : statsDataMap.keySet()) {
|
||||
if (visibleDataSet.contains(key)) {
|
||||
|
@ -217,6 +221,9 @@ public class GraphData {
|
|||
* @return
|
||||
*/
|
||||
public double getMaxValue(Set<String> visibleDataSet, String view) {
|
||||
if (visibleDataSet.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
double max = Double.MIN_VALUE;
|
||||
for (String key : statsDataMap.keySet()) {
|
||||
if (visibleDataSet.contains(key)) {
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.raytheon.uf.common.stats.AggregateRecord;
|
|||
@DynamicSerialize
|
||||
public class StatsBin {
|
||||
/** Millisecond value for this bin */
|
||||
@DynamicSerializeElement
|
||||
private long binMillis;
|
||||
|
||||
/** List of AggregateRecords */
|
||||
|
|
|
@ -194,7 +194,7 @@ public class StatsData {
|
|||
* The key
|
||||
* @return List of DataPoint objects
|
||||
*/
|
||||
public List<DataPoint> getData(String key) {
|
||||
public List<DataPoint> getData() {
|
||||
Collections.sort(pointList);
|
||||
return pointList;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ public class StatsData {
|
|||
/**
|
||||
* Accumulates the AggregateRecord objects into the correct bins.
|
||||
*/
|
||||
public void accumulate(String key) {
|
||||
public void accumulate() {
|
||||
pointList.clear();
|
||||
for (AggregateRecord record : recordList) {
|
||||
Date startDate = record.getStartDate().getTime();
|
||||
|
@ -267,7 +267,7 @@ public class StatsData {
|
|||
}
|
||||
}
|
||||
|
||||
createPoints(key);
|
||||
createPoints();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,7 +275,7 @@ public class StatsData {
|
|||
*
|
||||
* @param dataKey
|
||||
*/
|
||||
private void createPoints(String dataKey) {
|
||||
private void createPoints() {
|
||||
// Bins are created, now make the graph group member and point objects
|
||||
// convert the data values before storing in the data object
|
||||
double conversion = unitUtils.getConversion();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.uf.edex.stats.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
@ -30,12 +31,17 @@ import java.util.TreeSet;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.stats.AggregateRecord;
|
||||
import com.raytheon.uf.common.stats.data.GraphData;
|
||||
import com.raytheon.uf.common.stats.data.StatsBin;
|
||||
import com.raytheon.uf.common.stats.data.StatsData;
|
||||
import com.raytheon.uf.common.stats.data.StatsLabelData;
|
||||
import com.raytheon.uf.common.stats.util.UnitUtils;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
|
||||
|
@ -57,11 +63,14 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
|||
*/
|
||||
|
||||
public class StatsDataAccumulator {
|
||||
private final Pattern COLON_PATTERN = Pattern.compile(":");
|
||||
private static final Pattern COLON_PATTERN = Pattern.compile(":");
|
||||
|
||||
private final Pattern DASH_PATTERN = Pattern.compile("-");
|
||||
private static final Pattern DASH_PATTERN = Pattern.compile("-");
|
||||
|
||||
private final String COLON = ":";
|
||||
private static final String COLON = ":";
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(StatsDataAccumulator.class);
|
||||
|
||||
/** List of records */
|
||||
private AggregateRecord[] records;
|
||||
|
@ -241,13 +250,24 @@ public class StatsDataAccumulator {
|
|||
* @param groups
|
||||
* List of groups
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void gather(UnitUtils unitUtils, List<String> groups) {
|
||||
createStatsDataMap(unitUtils, groups);
|
||||
calculateBins();
|
||||
for (String key : statsDataMap.keySet()) {
|
||||
Map<Long, StatsBin> newMap = Collections.emptyMap();
|
||||
try {
|
||||
newMap = SerializationUtil.transformFromThrift(Map.class,
|
||||
SerializationUtil.transformToThrift(bins));
|
||||
} catch (SerializationException e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Error serializing/deserializing StatsBin data. Skipping...",
|
||||
e);
|
||||
}
|
||||
StatsData data = statsDataMap.get(key);
|
||||
data.setBins(bins);
|
||||
data.accumulate(key);
|
||||
data.setBins(newMap);
|
||||
data.accumulate();
|
||||
statsDataMap.put(key, data);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue