You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/03/13 04:24:09 UTC

[incubator-iotdb] branch support_text_in_grafana created (now cde20e6)

This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a change to branch support_text_in_grafana
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at cde20e6  add text support for grafana

This branch includes the following new commits:

     new cde20e6  add text support for grafana

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-iotdb] 01/01: add text support for grafana

Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch support_text_in_grafana
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit cde20e6392903d878cc035a717027f02e3ff5662
Author: qiaojialin <64...@qq.com>
AuthorDate: Fri Mar 13 12:23:47 2020 +0800

    add text support for grafana
---
 .../org/apache/iotdb/web/grafana/bean/TimeValues.java   |  6 +++---
 .../grafana/controller/DatabaseConnectController.java   |  2 +-
 .../apache/iotdb/web/grafana/dao/impl/BasicDaoImpl.java | 17 ++++-------------
 3 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/grafana/src/main/java/org/apache/iotdb/web/grafana/bean/TimeValues.java b/grafana/src/main/java/org/apache/iotdb/web/grafana/bean/TimeValues.java
index 9d09030..dd5d5a1 100644
--- a/grafana/src/main/java/org/apache/iotdb/web/grafana/bean/TimeValues.java
+++ b/grafana/src/main/java/org/apache/iotdb/web/grafana/bean/TimeValues.java
@@ -24,7 +24,7 @@ package org.apache.iotdb.web.grafana.bean;
 public class TimeValues {
 
   private long time;
-  private float value;
+  private Object value;
 
   @Override
   public String toString() {
@@ -39,11 +39,11 @@ public class TimeValues {
     this.time = time;
   }
 
-  public float getValue() {
+  public Object getValue() {
     return value;
   }
 
-  public void setValue(float value) {
+  public void setValue(Object value) {
     this.value = value;
   }
 }
diff --git a/grafana/src/main/java/org/apache/iotdb/web/grafana/controller/DatabaseConnectController.java b/grafana/src/main/java/org/apache/iotdb/web/grafana/controller/DatabaseConnectController.java
index b4dee8b..2643c1f 100644
--- a/grafana/src/main/java/org/apache/iotdb/web/grafana/controller/DatabaseConnectController.java
+++ b/grafana/src/main/java/org/apache/iotdb/web/grafana/controller/DatabaseConnectController.java
@@ -173,7 +173,7 @@ public class DatabaseConnectController {
     JSONArray dataPoints = new JSONArray();
     for (TimeValues tv : timeValues) {
       long time = tv.getTime();
-      float value = tv.getValue();
+      Object value = tv.getValue();
       JSONArray jsonArray = new JSONArray();
       jsonArray.add(value);
       jsonArray.add(time);
diff --git a/grafana/src/main/java/org/apache/iotdb/web/grafana/dao/impl/BasicDaoImpl.java b/grafana/src/main/java/org/apache/iotdb/web/grafana/dao/impl/BasicDaoImpl.java
index a1b7af7..eef7689 100644
--- a/grafana/src/main/java/org/apache/iotdb/web/grafana/dao/impl/BasicDaoImpl.java
+++ b/grafana/src/main/java/org/apache/iotdb/web/grafana/dao/impl/BasicDaoImpl.java
@@ -123,8 +123,6 @@ public class BasicDaoImpl implements BasicDao {
 
   static class TimeValuesRowMapper implements RowMapper<TimeValues> {
 
-    static final String TRUE_STR = "true";
-    static final String FALSE_STR = "false";
     String columnName;
 
     TimeValuesRowMapper(String columnName) {
@@ -137,17 +135,10 @@ public class BasicDaoImpl implements BasicDao {
       tv.setTime(resultSet.getLong("Time") / TIMESTAMP_RADIX);
       String valueString = resultSet.getString(columnName);
       if (valueString != null) {
-        if (TRUE_STR.equalsIgnoreCase(valueString)) {
-          tv.setValue(1);
-        } else if (FALSE_STR.equalsIgnoreCase(valueString)) {
-          tv.setValue(0);
-        } else {
-          try {
-            tv.setValue(Float.parseFloat(resultSet.getString(columnName)));
-          } catch (Exception e) {
-            logger.error("Can not parse the value {}", resultSet.getString(columnName));
-            tv.setValue(0);
-          }
+        try {
+          tv.setValue(Float.parseFloat(resultSet.getString(columnName)));
+        } catch (Exception e) {
+          tv.setValue(resultSet.getString(columnName));
         }
       }
       return tv;