You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2025/01/25 07:01:45 UTC
(iotdb) 10/31: 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)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rc/2.0.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 4dc2e9a5ca72c8f9ac376dbb04c67a32674e966d
Author: Zhenyu Luo <lu...@gmail.com>
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)
(cherry picked from commit b349f565fd81ade02603ddd2936b651083e683ca)
---
.../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);