You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2020/05/05 01:30:59 UTC
[incubator-iotdb] branch rel/0.9 updated (f9606b0 -> 515ea6b)
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a change to branch rel/0.9
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.
from f9606b0 Added workaround when doing Aggregation over boolean Series.
new bea678f fix grafana connect does not use correct time unit
new 515ea6b fix sonar code smell
The 2 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.
Summary of changes:
.../UserGuide/7-Ecosystem Integration/1-Grafana.md | 2 +-
.../iotdb/web/grafana/dao/impl/BasicDaoImpl.java | 43 +++++++++++++---------
grafana/src/main/resources/application.properties | 3 +-
3 files changed, 28 insertions(+), 20 deletions(-)
[incubator-iotdb] 02/02: fix sonar code smell
Posted by hx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch rel/0.9
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 515ea6b1e420f08cbf7dace964edd9c1d4978c0d
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Sun May 3 11:10:40 2020 +0800
fix sonar code smell
---
.../iotdb/web/grafana/dao/impl/BasicDaoImpl.java | 37 ++++++++++++----------
1 file changed, 20 insertions(+), 17 deletions(-)
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 c43ca72..34279bc 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
@@ -41,7 +41,6 @@ import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Properties;
@Repository
@PropertySource("classpath:application.properties")
@@ -53,7 +52,7 @@ public class BasicDaoImpl implements BasicDao {
private final JdbcTemplate jdbcTemplate;
- private static long TIMESTAMP_RADIX = -1L;
+ private static long timestampRadioX = -1L;
@Value("${timestamp_precision}")
private String timestampPrecision;
@@ -91,6 +90,20 @@ public class BasicDaoImpl implements BasicDao {
return (List<String>) jdbcTemplate.execute(connectionCallback);
}
+ private static void setTimestampRadioX(String timestampPrecision) {
+ switch (timestampPrecision) {
+ case "us":
+ timestampRadioX = 1000;
+ break;
+ case "ns":
+ timestampRadioX = 1000_000;
+ break;
+ default:
+ timestampRadioX = 1;
+ }
+ logger.info("Use timestamp precision {}", timestampPrecision);
+ }
+
/**
* Note: If the query fails this could be due to AGGREGATIION like AVG on booleayn field.
* Thus, we then do a retry with FIRST aggregation.
@@ -98,18 +111,8 @@ public class BasicDaoImpl implements BasicDao {
*/
@Override
public List<TimeValues> querySeries(String s, Pair<ZonedDateTime, ZonedDateTime> timeRange) {
- if(TIMESTAMP_RADIX == -1) {
- switch (timestampPrecision) {
- case "us":
- TIMESTAMP_RADIX = 1000;
- break;
- case "ns":
- TIMESTAMP_RADIX = 1000_000;
- break;
- default:
- TIMESTAMP_RADIX = 1;
- }
- logger.info("Use timestamp precision {}", timestampPrecision);
+ if(timestampRadioX == -1) {
+ setTimestampRadioX(timestampPrecision);
}
try {
return querySeriesInternal(s, timeRange, function);
@@ -132,7 +135,7 @@ public class BasicDaoImpl implements BasicDao {
List<TimeValues> rows = null;
String sql = String.format("SELECT %s FROM root.%s WHERE time > %d and time < %d",
s.substring(s.lastIndexOf('.') + 1), s.substring(0, s.lastIndexOf('.')),
- from * TIMESTAMP_RADIX, to * TIMESTAMP_RADIX);
+ from * timestampRadioX, to * timestampRadioX);
String columnName = "root." + s;
if (isDownSampling && (hours > 1)) {
if (hours < 30 * 24 && hours > 24) {
@@ -144,8 +147,8 @@ public class BasicDaoImpl implements BasicDao {
"SELECT " + function
+ "(%s) FROM root.%s WHERE time > %d and time < %d group by (%s, [%d, %d])",
s.substring(s.lastIndexOf('.') + 1), s.substring(0, s.lastIndexOf('.')),
- from * TIMESTAMP_RADIX, to * TIMESTAMP_RADIX,
- interval, from * TIMESTAMP_RADIX, to * TIMESTAMP_RADIX);
+ from * timestampRadioX, to * timestampRadioX,
+ interval, from * timestampRadioX, to * timestampRadioX);
columnName = function + "(root." + s + ")";
}
logger.info(sql);
[incubator-iotdb] 01/02: fix grafana connect does not use correct
time unit
Posted by hx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch rel/0.9
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit bea678fd41b3bddbfd6f04906718dd485c2ddd18
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Sat May 2 22:34:28 2020 +0800
fix grafana connect does not use correct time unit
---
.../UserGuide/7-Ecosystem Integration/1-Grafana.md | 2 +-
.../iotdb/web/grafana/dao/impl/BasicDaoImpl.java | 36 ++++++++++++----------
grafana/src/main/resources/application.properties | 3 +-
3 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/docs/UserGuide/7-Ecosystem Integration/1-Grafana.md b/docs/UserGuide/7-Ecosystem Integration/1-Grafana.md
index 5ad4e9b..2ba605f 100644
--- a/docs/UserGuide/7-Ecosystem Integration/1-Grafana.md
+++ b/docs/UserGuide/7-Ecosystem Integration/1-Grafana.md
@@ -153,7 +153,7 @@ isDownSampling=true
# defaut sampling intervals
interval=1m
# aggregation function to use to downsampling the data
-# COUNT, FIRST_VALUE, LAST_VALUE, MAX_TIME, MAX_VALUE, AVG, MIN_TIME, MIN_VALUE, NOW, SUM
+# COUNT, FIRST, LAST, MAX_TIME, MAX_VALUE, AVG, MIN_TIME, MIN_VALUE, NOW, SUM
function=avg
```
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 dde404f..c43ca72 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
@@ -53,7 +53,10 @@ public class BasicDaoImpl implements BasicDao {
private final JdbcTemplate jdbcTemplate;
- private static long TIMESTAMP_RADIX = 1L;
+ private static long TIMESTAMP_RADIX = -1L;
+
+ @Value("${timestamp_precision}")
+ private String timestampPrecision;
@Value("${isDownSampling}")
private boolean isDownSampling;
@@ -68,19 +71,6 @@ public class BasicDaoImpl implements BasicDao {
@Autowired
public BasicDaoImpl(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
- Properties properties = new Properties();
- String tsPrecision = properties.getProperty("timestamp_precision", "ms");
- switch (tsPrecision) {
- case "us":
- TIMESTAMP_RADIX = 1000;
- break;
- case "ns":
- TIMESTAMP_RADIX = 1000_000;
- break;
- default:
- TIMESTAMP_RADIX = 1;
- }
- logger.info("Use timestamp precision {}", tsPrecision);
}
@Override
@@ -108,6 +98,19 @@ public class BasicDaoImpl implements BasicDao {
*/
@Override
public List<TimeValues> querySeries(String s, Pair<ZonedDateTime, ZonedDateTime> timeRange) {
+ if(TIMESTAMP_RADIX == -1) {
+ switch (timestampPrecision) {
+ case "us":
+ TIMESTAMP_RADIX = 1000;
+ break;
+ case "ns":
+ TIMESTAMP_RADIX = 1000_000;
+ break;
+ default:
+ TIMESTAMP_RADIX = 1;
+ }
+ logger.info("Use timestamp precision {}", timestampPrecision);
+ }
try {
return querySeriesInternal(s, timeRange, function);
} catch (Exception e) {
@@ -140,8 +143,9 @@ public class BasicDaoImpl implements BasicDao {
sql = String.format(
"SELECT " + function
+ "(%s) FROM root.%s WHERE time > %d and time < %d group by (%s, [%d, %d])",
- s.substring(s.lastIndexOf('.') + 1), s.substring(0, s.lastIndexOf('.')), from, to,
- interval, from, to);
+ s.substring(s.lastIndexOf('.') + 1), s.substring(0, s.lastIndexOf('.')),
+ from * TIMESTAMP_RADIX, to * TIMESTAMP_RADIX,
+ interval, from * TIMESTAMP_RADIX, to * TIMESTAMP_RADIX);
columnName = function + "(root." + s + ")";
}
logger.info(sql);
diff --git a/grafana/src/main/resources/application.properties b/grafana/src/main/resources/application.properties
index 9401a32..dfdef16 100644
--- a/grafana/src/main/resources/application.properties
+++ b/grafana/src/main/resources/application.properties
@@ -31,6 +31,7 @@ isDownSampling=true
# defaut sampling intervals
interval=1m
# aggregation function to use to downsampling the data
-# COUNT, FIRST_VALUE, LAST_VALUE, MAX_TIME, MAX_VALUE, AVG, MIN_TIME, MIN_VALUE, NOW, SUM
+# COUNT, FIRST, LAST, MAX_TIME, MAX_VALUE, AVG, MIN_TIME, MIN_VALUE, NOW, SUM
# If it does fail (e.g. due to applying AVG to boolean) it will Fallback to LAST
+# notice that from v0.10 on, this parameter is deprecated
function=AVG
\ No newline at end of file