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

jackietien pushed a commit to branch tsbs/iot
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/tsbs/iot by this push:
     new 5fc57cef220 change according to TD
5fc57cef220 is described below

commit 5fc57cef220636c54a23e10241003f3e6be69aa7
Author: JackieTien97 <[email protected]>
AuthorDate: Mon May 13 12:15:31 2024 +0800

    change according to TD
---
 .../iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java |  4 +++-
 .../java/org/apache/iotdb/db/utils/QueryDataSetUtils.java   | 13 +++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
index 88593390da5..d9cb981cb45 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
@@ -3654,7 +3654,9 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
                   serde,
                   deviceColumnIndex1,
                   1 - deviceColumnIndex1,
-                  1 - deviceColumnIndex2);
+                  1 - deviceColumnIndex2,
+                  req.startTime,
+                  req.endTime);
           finished = pair.right;
           resp.setQueryResult(pair.left);
           resp.setMoreData(!finished);
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
index e09a1a1015e..5e4c9d8c3e2 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
@@ -1228,6 +1228,8 @@ public class QueryDataSetUtils {
     ColumnBuilder nameColumnBuilder = builder.getColumnBuilder(0);
     ColumnBuilder durationColumnBuilder = builder.getColumnBuilder(1);
 
+    int dayCount = (int) ((endTime - startTime - 1) / 
TimeUnit.DAYS.toMillis(1)) + 1;
+
     int numOfTenMinutesInOneDay = 144;
     List<Double> velocityList = new ArrayList<>(numOfTenMinutesInOneDay);
     List<Long> timeList = new ArrayList<>(numOfTenMinutesInOneDay);
@@ -1295,7 +1297,7 @@ public class QueryDataSetUtils {
 
             day++;
             // 10 days is done, move to next device
-            if (day == 10) {
+            if (day == dayCount) {
               day = 0;
             }
           }
@@ -1528,7 +1530,9 @@ public class QueryDataSetUtils {
       TsBlockSerde serde,
       int deviceColumnIndex,
       int totalColumnIndex,
-      int statusColumnIndex)
+      int statusColumnIndex,
+      long startTime,
+      long endTime)
       throws IoTDBException, IOException {
 
     Map<String, DailyActivityValue> map = new HashMap<>();
@@ -1539,7 +1543,8 @@ public class QueryDataSetUtils {
     TsBlock statusTsBlock = null;
     boolean statusFinished = false;
     int statusIndex = 0;
-    List<Boolean> avtiveList = new ArrayList<>(1440);
+    int groupCount = (int) ((endTime - startTime - 1) / 
TimeUnit.MINUTES.toMillis(10)) + 1;
+    List<Boolean> avtiveList = new ArrayList<>(groupCount);
 
     while (!totalFinished && !statusFinished) {
       if (totalTsBlock == null || totalTsBlock.isEmpty()) {
@@ -1573,7 +1578,7 @@ public class QueryDataSetUtils {
           long currentStatus = statusColumn.getLong(statusIndex);
 
           avtiveList.add(currentStatus * 1.0d / currentTotal > 0.5);
-          if (avtiveList.size() == 1440) {
+          if (avtiveList.size() == groupCount) {
             String deviceId =
                 
deviceColumn.getBinary(totalIndex).getStringValue(StandardCharsets.UTF_8);
             String model = deviceId.split("\\.")[MODEL_LEVEL];

Reply via email to