|
@@ -68,8 +68,9 @@ public class TaskRedis2Taos implements Runnable {
|
|
|
boolean bl;
|
|
|
List<String> response;
|
|
|
|
|
|
+ int j = 1;
|
|
|
if (dataType == TsDataType.BOOLEAN) {
|
|
|
- for (int i = 0; i < objects.size(); ) {
|
|
|
+ for (int i = 0; i < objects.size();i++) {
|
|
|
response = (List<String>) objects.get(i);
|
|
|
|
|
|
value = response.get(1);
|
|
@@ -98,16 +99,15 @@ public class TaskRedis2Taos implements Runnable {
|
|
|
ChangedSave.map.put(pointid, datetime);
|
|
|
ts = Long.valueOf(datetime) * 1000;
|
|
|
bl = Double.valueOf(value) == 1;
|
|
|
-
|
|
|
+ j++;
|
|
|
sb.append(pointid).append(" VALUES (").append(ts).append(",").append(bl).append(") ");
|
|
|
}
|
|
|
} else {
|
|
|
ChangedSave.map.put(pointid, datetime);
|
|
|
}
|
|
|
|
|
|
- i++;
|
|
|
//分为1000个1组,taos单机可以控制在1s内
|
|
|
- if (i % 1000 == 0 || i == objects.size()) {
|
|
|
+ if (j % 1000 == 0) {
|
|
|
sb.append(";");
|
|
|
|
|
|
taskExecutor.execute(new TaskInsert2Taos(conn, sb.toString(), "USING " +
|
|
@@ -117,8 +117,12 @@ public class TaskRedis2Taos implements Runnable {
|
|
|
sb.append("INSERT INTO ");
|
|
|
}
|
|
|
}
|
|
|
+ sb.append(";");
|
|
|
+ taskExecutor.execute(new TaskInsert2Taos(conn, sb.toString(), "USING " +
|
|
|
+ taosConfig.getDIStableName() + " TAGS('','','','','',1,'') VALUES"));
|
|
|
+
|
|
|
} else {
|
|
|
- for (int i = 0; i < objects.size(); ) {
|
|
|
+ for (int i = 0; i < objects.size(); i++) {
|
|
|
response = (List<String>) objects.get(i);
|
|
|
|
|
|
value = response.get(1);
|
|
@@ -134,14 +138,14 @@ public class TaskRedis2Taos implements Runnable {
|
|
|
ts = Long.valueOf(datetime) * 1000;
|
|
|
val = Double.valueOf(value);
|
|
|
|
|
|
+ j++;
|
|
|
sb.append(pointid).append(" VALUES (").append(ts).append(",").append(val).append(") ");
|
|
|
}
|
|
|
} else {
|
|
|
ChangedSave.map.put(pointid, datetime);
|
|
|
}
|
|
|
|
|
|
- i++;
|
|
|
- if (i % 1000 == 0 || i == objects.size()) {
|
|
|
+ if (j % 1000 == 0) {
|
|
|
sb.append(";");
|
|
|
|
|
|
taskExecutor.execute(new TaskInsert2Taos(conn, sb.toString(), "USING " +
|
|
@@ -151,6 +155,9 @@ public class TaskRedis2Taos implements Runnable {
|
|
|
sb.append("INSERT INTO ");
|
|
|
}
|
|
|
}
|
|
|
+ sb.append(";");
|
|
|
+ taskExecutor.execute(new TaskInsert2Taos(conn, sb.toString(), "USING " +
|
|
|
+ taosConfig.getAIStableName() + " TAGS('','','','','',1,'') VALUES"));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|