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

rong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new b349f565fd8 Pipe/Load: Fixed the issue where the TsFileResource of the 
PlainDeviceTimeIndex type was judged to be empty (triggered by IoTDB loading 
TsFiles in v3 and the tsfiles are syned to other clusters) (#14692)
b349f565fd8 is described below

commit b349f565fd81ade02603ddd2936b651083e683ca
Author: Zhenyu Luo <[email protected]>
AuthorDate: Tue Jan 14 01:22:46 2025 +0800

    Pipe/Load: Fixed the issue where the TsFileResource of the 
PlainDeviceTimeIndex type was judged to be empty (triggered by IoTDB loading 
TsFiles in v3 and the tsfiles are syned to other clusters) (#14692)
---
 .../tsfile/timeindex/ArrayDeviceTimeIndex.java       | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/ArrayDeviceTimeIndex.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/ArrayDeviceTimeIndex.java
index cf1cf1dd1db..4c5c12cc154 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/ArrayDeviceTimeIndex.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/ArrayDeviceTimeIndex.java
@@ -86,6 +86,10 @@ public class ArrayDeviceTimeIndex implements ITimeIndex {
     this.startTimes = startTimes;
     this.endTimes = endTimes;
     this.deviceToIndex = deviceToIndex;
+
+    // The TSFileResource file is judged to be empty based on MaxEndTime and 
MinStartTime, so the
+    // construction of TimeIndex needs to update MaxEndTime and MinStartTime.
+    updateMinStartTimeAndMaxEndTime();
   }
 
   @Override
@@ -336,6 +340,22 @@ public class ArrayDeviceTimeIndex implements ITimeIndex {
     maxEndTime = Math.max(maxEndTime, time);
   }
 
+  private void updateMinStartTimeAndMaxEndTime() {
+    for (Map.Entry<IDeviceID, Integer> entry : deviceToIndex.entrySet()) {
+      if (entry.getValue() == null) {
+        continue;
+      }
+
+      if (endTimes != null) {
+        maxEndTime = Math.max(maxEndTime, endTimes[entry.getValue()]);
+      }
+
+      if (startTimes != null) {
+        minStartTime = Math.min(minStartTime, startTimes[entry.getValue()]);
+      }
+    }
+  }
+
   @Override
   public void putStartTime(IDeviceID deviceId, long time) {
     int index = getDeviceIndex(deviceId);

Reply via email to