You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@hertzbeat.apache.org by go...@apache.org on 2024/05/01 02:57:39 UTC
(hertzbeat) branch master updated: [improve] support Time Type to Tengine Data Storage (#1890)
This is an automated email from the ASF dual-hosted git repository.
gongchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/master by this push:
new 8d684e964 [improve] support Time Type to Tengine Data Storage (#1890)
8d684e964 is described below
commit 8d684e964db5657224847246f6b36bbaa491b9e0
Author: Clownsw <ms...@gmail.com>
AuthorDate: Wed May 1 10:57:34 2024 +0800
[improve] support Time Type to Tengine Data Storage (#1890)
Signed-off-by: Clownsw <ms...@gmail.com>
Co-authored-by: tomsun28 <to...@outlook.com>
---
.../warehouse/store/HistoryTdEngineDataStorage.java | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/HistoryTdEngineDataStorage.java b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/HistoryTdEngineDataStorage.java
index d760f3a17..18643b5d9 100644
--- a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/HistoryTdEngineDataStorage.java
+++ b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/HistoryTdEngineDataStorage.java
@@ -134,7 +134,9 @@ public class HistoryTdEngineDataStorage extends AbstractHistoryDataStorage {
for (int index = 0; index < fields.size(); index++) {
CollectRep.Field field = fields.get(index);
String value = valueRow.getColumns(index);
- if (field.getType() == CommonConstants.TYPE_NUMBER) {
+ final int fieldType;
+
+ if ((fieldType = field.getType()) == CommonConstants.TYPE_NUMBER || fieldType == CommonConstants.TYPE_TIME) {
// number data
if (CommonConstants.NULL_VALUE.equals(value)) {
sqlRowBuffer.append("NULL");
@@ -183,7 +185,9 @@ public class HistoryTdEngineDataStorage extends AbstractHistoryDataStorage {
for (int index = 0; index < fields.size(); index++) {
CollectRep.Field field = fields.get(index);
String fieldName = field.getName();
- if (field.getType() == CommonConstants.TYPE_NUMBER) {
+ final int fieldType;
+
+ if ((fieldType = field.getType()) == CommonConstants.TYPE_NUMBER || fieldType == CommonConstants.TYPE_TIME) {
fieldSqlBuilder.append("`").append(fieldName).append("` ").append("DOUBLE");
} else {
fieldSqlBuilder.append("`").append(fieldName).append("` ").append("NCHAR(")
@@ -216,7 +220,7 @@ public class HistoryTdEngineDataStorage extends AbstractHistoryDataStorage {
}
}
- private String formatStringValue(String value){
+ private String formatStringValue(String value) {
String formatValue = SQL_SPECIAL_STRING_PATTERN.matcher(value).replaceAll("\\\\$0");
// bugfix Argument list too long
if (formatValue != null && formatValue.length() > tableStrColumnDefineMaxLength) {
@@ -235,7 +239,7 @@ public class HistoryTdEngineDataStorage extends AbstractHistoryDataStorage {
@Override
public Map<String, List<Value>> getHistoryMetricData(Long monitorId, String app, String metrics, String metric, String label, String history) {
String table = app + "_" + metrics + "_" + monitorId;
- String selectSql = label == null ? String.format(QUERY_HISTORY_SQL, metric, table, history) :
+ String selectSql = label == null ? String.format(QUERY_HISTORY_SQL, metric, table, history) :
String.format(QUERY_HISTORY_WITH_INSTANCE_SQL, metric, table, label, history);
log.debug(selectSql);
Map<String, List<Value>> instanceValuesMap = new HashMap<>(8);
@@ -322,7 +326,7 @@ public class HistoryTdEngineDataStorage extends AbstractHistoryDataStorage {
instanceValue = "";
}
String selectSql = String.format(QUERY_HISTORY_INTERVAL_WITH_INSTANCE_SQL,
- metric, metric, metric, metric, table, instanceValue, history);
+ metric, metric, metric, metric, table, instanceValue, history);
log.debug(selectSql);
List<Value> values = instanceValuesMap.computeIfAbsent(instanceValue, k -> new LinkedList<>());
Connection connection = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: notifications-help@hertzbeat.apache.org