You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ey...@apache.org on 2009/02/27 22:48:52 UTC
svn commit: r748714 - in /hadoop/core/trunk/src/contrib/chukwa/src:
java/org/apache/hadoop/chukwa/hicc/Chart.java
java/org/apache/hadoop/chukwa/hicc/DatasetMapper.java
web/hicc/js/jquery.flot.pack.js
Author: eyang
Date: Fri Feb 27 21:48:52 2009
New Revision: 748714
URL: http://svn.apache.org/viewvc?rev=748714&view=rev
Log:
HADOOP-5035.
- Improved Y axis ticker labelling.
- Used TreeMap to build non-time series data for charting.
- Improved handling of "not a number "values.
Modified:
hadoop/core/trunk/src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/hicc/Chart.java
hadoop/core/trunk/src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/hicc/DatasetMapper.java
hadoop/core/trunk/src/contrib/chukwa/src/web/hicc/js/jquery.flot.pack.js
Modified: hadoop/core/trunk/src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/hicc/Chart.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/hicc/Chart.java?rev=748714&r1=748713&r2=748714&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/hicc/Chart.java (original)
+++ hadoop/core/trunk/src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/hicc/Chart.java Fri Feb 27 21:48:52 2009
@@ -227,12 +227,20 @@
"return val.toFixed(axis.tickDecimals) + \" %\"; }";
} else {
output = output + "tickFormatter: function(val, axis) { " +
- "if (val > 1000000000000000) return (val / 1000000000000000).toFixed(axis.tickDecimals) + \"PB\";" +
- "else if (val > 1000000000000) return (val / 1000000000000).toFixed(axis.tickDecimals) + \"TB\";" +
- "else if (val > 1000000000) return (val / 1000000000).toFixed(axis.tickDecimals) + \"GB\";" +
- "else if (val > 1000000) return (val / 1000000).toFixed(axis.tickDecimals) + \"MB\";" +
- "else if (val > 1000) return (val / 1000).toFixed(axis.tickDecimals) + \"KB\";" +
- "else return val.toFixed(axis.tickDecimals) + \"B\"; }";
+ "if (val >= 1000000000000000) return (val / 1000000000000000).toFixed(2) + \"x10<sup>15</sup>\";" +
+ "else if (val >= 100000000000000) return (val / 100000000000000).toFixed(2) + \"x10<sup>14</sup>\";" +
+ "else if (val >= 10000000000000) return (val / 10000000000000).toFixed(2) + \"x10<sup>13</sup>\";" +
+ "else if (val >= 1000000000000) return (val / 1000000000000).toFixed(2) + \"x10<sup>12</sup>\";" +
+ "else if (val >= 100000000000) return (val / 100000000000).toFixed(2) + \"x10<sup>11</sup>\";" +
+ "else if (val >= 10000000000) return (val / 10000000000).toFixed(2) + \"x10<sup>10</sup>\";" +
+ "else if (val >= 1000000000) return (val / 1000000000).toFixed(2) + \"x10<sup>9</sup>\";" +
+ "else if (val >= 100000000) return (val / 100000000).toFixed(2) + \"x10<sup>8</sup>\";" +
+ "else if (val >= 10000000) return (val / 10000000).toFixed(2) + \"x10<sup>7</sup>\";" +
+ "else if (val >= 1000000) return (val / 1000000).toFixed(2) + \"x10<sup>6</sup>\";" +
+ "else if (val >= 100000) return (val / 100000).toFixed(2) + \"x10<sup>5</sup>\";" +
+ "else if (val >= 10000) return (val / 10000).toFixed(2) + \"x10<sup>4</sup>\";" +
+ "else if (val >= 2000) return (val / 1000).toFixed(2) + \"x10<sup>3</sup>\";" +
+ "else return val.toFixed(2) + \"\"; }";
}
if(userDefinedMax) {
output = output + ", min:0, max:"+this.max;
@@ -323,14 +331,26 @@
output+=",";
}
if(xLabel.equals("Time")) {
- output+="[\""+dp+"\","+data.get(dp)+"]";
+ if(data.get(dp)==Double.NaN) {
+ output+="[\""+dp+"\",NULL]";
+ } else {
+ output+="[\""+dp+"\","+data.get(dp)+"]";
+ }
} else {
long value = xLabelRangeHash.get(dp);
- output+="[\""+value+"\","+data.get(dp)+"]";
+ if(data.get(dp)==Double.NaN) {
+ output+="[\""+dp+"\",NULL]";
+ } else {
+ output+="[\""+value+"\","+data.get(dp)+"]";
+ }
}
counter2++;
}
- output+="], min:0, max:"+this.max+"}";
+ output+="], min:0";
+ if(this.userDefinedMax) {
+ output+=", max:"+this.max;
+ }
+ output+="}";
counter++;
}
i++;
Modified: hadoop/core/trunk/src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/hicc/DatasetMapper.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/hicc/DatasetMapper.java?rev=748714&r1=748713&r2=748714&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/hicc/DatasetMapper.java (original)
+++ hadoop/core/trunk/src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/hicc/DatasetMapper.java Fri Feb 27 21:48:52 2009
@@ -75,8 +75,12 @@
HashMap<String, Integer> xAxisMap = new HashMap<String, Integer>();
while (rs.next()) {
String label = "";
- long time = rs.getTimestamp(1).getTime();
- label = ""+time;
+ if(rmeta.getColumnType(1)==java.sql.Types.TIMESTAMP) {
+ long time = rs.getTimestamp(1).getTime();
+ label = ""+time;
+ } else {
+ label = rs.getString(1);
+ }
if(!xAxisMap.containsKey(label)) {
xAxisMap.put(label, i);
labels.add(label);
@@ -85,34 +89,37 @@
if(groupBySecondColumn) {
String item = rs.getString(2);
// Get the data from the row using the series column
- data = dataset.get(item);
- if(data == null) {
- data = new java.util.TreeMap<String, Double>();
- }
- if(calculateSlope) {
- double current = rs.getDouble(3);
- double tmp = 0L;
- if(data.size()>1) {
- tmp = current - previousHash.get(item).doubleValue();
- } else {
- tmp = 0;
- }
- if(tmp<0) {
- tmp=0;
- }
- if(tmp>max) {
- max=tmp;
+ for(int j=3;j<=col;j++) {
+ item = rs.getString(2) + " " + rmeta.getColumnName(j);
+ data = dataset.get(item);
+ if(data == null) {
+ data = new java.util.TreeMap<String, Double>();
+ }
+ if(calculateSlope) {
+ double current = rs.getDouble(j);
+ double tmp = 0L;
+ if(data.size()>1) {
+ tmp = current - previousHash.get(item).doubleValue();
+ } else {
+ tmp = 0;
+ }
+ if(tmp<0) {
+ tmp=Double.NaN;
+ }
+ previousHash.put(item,current);
+ if(tmp>max) {
+ max=tmp;
+ }
+ data.put(label, tmp);
+ } else {
+ double current = rs.getDouble(3);
+ if(current>max) {
+ max=current;
+ }
+ data.put(label, current);
+ }
+ dataset.put(item,data);
}
- previousHash.put(item,current);
- data.put(label, tmp);
- } else {
- double current = rs.getDouble(3);
- if(current>max) {
- max=current;
- }
- data.put(label, current);
- }
- dataset.put(item,data);
} else {
for(int j=2;j<=col;j++) {
String item = rmeta.getColumnName(j);
@@ -126,19 +133,19 @@
data = new java.util.TreeMap<String, Double>();
}
if(calculateSlope) {
- double tmp = rs.getDouble(j);
- if(data.size()>1) {
- tmp = tmp - previousArray[j];
- } else {
- tmp = 0.0;
- }
- previousArray[j]=current;
- if(tmp<0) {
- tmp=0;
- }
- data.put(label, tmp);
+ double tmp = current;
+ if(data.size()>1) {
+ tmp = tmp - previousArray[j];
+ } else {
+ tmp = 0.0;
+ }
+ if(tmp<0) {
+ tmp=Double.NaN;
+ }
+ previousArray[j]=current;
+ data.put(label, tmp);
} else {
- data.put(label, current);
+ data.put(label, current);
}
dataset.put(item,data);
}
Modified: hadoop/core/trunk/src/contrib/chukwa/src/web/hicc/js/jquery.flot.pack.js
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/chukwa/src/web/hicc/js/jquery.flot.pack.js?rev=748714&r1=748713&r2=748714&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/chukwa/src/web/hicc/js/jquery.flot.pack.js (original)
+++ hadoop/core/trunk/src/contrib/chukwa/src/web/hicc/js/jquery.flot.pack.js Fri Feb 27 21:48:52 2009
@@ -277,7 +277,9 @@
continue;
if(!this.processed && options.yaxis.mode=='stack' && i>0) {
- data[j][1]=data[j][1]+series[i-1].data[j][1];
+ if(series[i-1].data[j]) {
+ data[j][1]=data[j][1]+series[i-1].data[j][1];
+ }
}
var x = data[j][0], y = data[j][1];