From: Sasa M. <sa...@us...> - 2004-11-21 13:25:55
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14051/org/jrobin/core Modified Files: FetchData.java Removed Files: FetchDataStats.java RpnCalculator.java Log Message: org.jrobin.data package introduction --- RpnCalculator.java DELETED --- Index: FetchData.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/FetchData.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** FetchData.java 19 Nov 2004 13:43:52 -0000 1.12 --- FetchData.java 21 Nov 2004 13:25:38 -0000 1.13 *************** *** 26,29 **** --- 26,32 ---- package org.jrobin.core; + import org.jrobin.data.DataStats; + import org.jrobin.data.RpnCalculator; + import java.io.IOException; import java.io.OutputStream; *************** *** 327,331 **** public double getAggregate(String dsName, String consolFun, String rpnExpression) throws RrdException { ! FetchDataStats stats = getStats(dsName, rpnExpression); if (consolFun.equals(CF_MAX)) { return stats.getMax(); --- 330,334 ---- public double getAggregate(String dsName, String consolFun, String rpnExpression) throws RrdException { ! DataStats stats = getStats(dsName, rpnExpression); if (consolFun.equals(CF_MAX)) { return stats.getMax(); *************** *** 359,363 **** * @throws RrdException Thrown if the given datasource name cannot be found in fetched data. */ ! public FetchDataStats getStats(String dsName) throws RrdException { return getStats(dsName, null); } --- 362,366 ---- * @throws RrdException Thrown if the given datasource name cannot be found in fetched data. */ ! public DataStats getStats(String dsName) throws RrdException { return getStats(dsName, null); } *************** *** 379,414 **** * @throws RrdException Thrown if the given datasource name cannot be found in fetched data */ ! public FetchDataStats getStats(String dsName, String rpnExpression) throws RrdException { ! double[] values = getValues(dsName); ! long totalSecs = 0; ! double totalValue = 0.0, min = Double.NaN, max = Double.NaN; ! RpnCalculator rpnCalculator = null; if (rpnExpression != null) { ! rpnCalculator = new RpnCalculator(rpnExpression); ! } ! for (int i = 0; i < values.length - 1; i++) { ! long t1 = Math.max(request.getFetchStart(), timestamps[i]); ! long t2 = Math.min(request.getFetchEnd(), timestamps[i + 1]); ! double value = values[i + 1]; ! if (rpnCalculator != null) { ! rpnCalculator.setValue(value); ! rpnCalculator.setTimestamp(t2); ! value = rpnCalculator.calculate(); ! } ! if (!Double.isNaN(value)) { ! totalSecs += (t2 - t1); ! totalValue += (t2 - t1) * value; } - min = Util.min(min, value); - max = Util.max(max, value); } ! FetchDataStats stats = new FetchDataStats(); ! stats.setFirst(values[1]); ! stats.setLast(values[values.length - 1]); ! stats.setMax(max); ! stats.setMin(min); ! stats.setSeconds(totalSecs); ! stats.setTotal(totalValue); ! return stats; } --- 382,398 ---- * @throws RrdException Thrown if the given datasource name cannot be found in fetched data */ ! public DataStats getStats(String dsName, String rpnExpression) throws RrdException { ! double[] values = getValues(dsName), calculatedValues = values; if (rpnExpression != null) { ! calculatedValues = new double[values.length]; ! RpnCalculator rpnCalculator = new RpnCalculator(rpnExpression); ! for (int i = 0; i < values.length; i++) { ! rpnCalculator.setValue(values[i]); ! rpnCalculator.setTimestamp(timestamps[i]); ! calculatedValues[i] = rpnCalculator.calculate(); } } ! return new DataStats(timestamps, calculatedValues, ! request.getFetchStart(), request.getFetchEnd()); } --- FetchDataStats.java DELETED --- |