This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new 41dea10bfa5 Load: Enhanced the auto-creation logic (#15265) (#15474)
(#15473)
41dea10bfa5 is described below
commit 41dea10bfa50ac587c9b9d7be53b32b296a54ab5
Author: Caideyipi <[email protected]>
AuthorDate: Thu May 8 12:47:12 2025 +0800
Load: Enhanced the auto-creation logic (#15265) (#15474) (#15473)
---
.../queryengine/plan/analyze/LoadTsFileAnalyzer.java | 16 +++++++++++++---
.../org/apache/iotdb/db/utils/ModificationUtils.java | 20 ++++++++++----------
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/LoadTsFileAnalyzer.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/LoadTsFileAnalyzer.java
index 95caf7d81a9..2b16de9dd80 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/LoadTsFileAnalyzer.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/LoadTsFileAnalyzer.java
@@ -455,11 +455,13 @@ public class LoadTsFileAnalyzer implements AutoCloseable {
while (timeseriesMetadataIterator.hasNext()) {
final Map<IDeviceID, List<TimeseriesMetadata>> device2TimeseriesMetadata
=
timeseriesMetadataIterator.next();
- if (isAutoCreateSchemaOrVerifySchemaEnabled) {
- schemaAutoCreatorAndVerifier.autoCreateAndVerify(reader,
device2TimeseriesMetadata);
- }
if (!tsFileResource.resourceFileExists()) {
TsFileResourceUtils.updateTsFileResource(device2TimeseriesMetadata,
tsFileResource);
+
schemaAutoCreatorAndVerifier.setCurrentTimeIndex(tsFileResource.getTimeIndex());
+ }
+
+ if (isAutoCreateSchemaOrVerifySchemaEnabled) {
+ schemaAutoCreatorAndVerifier.autoCreateAndVerify(reader,
device2TimeseriesMetadata);
}
// TODO: how to get the correct write point count when
// !isAutoCreateSchemaOrVerifySchemaEnabled
@@ -571,6 +573,10 @@ public class LoadTsFileAnalyzer implements AutoCloseable {
schemaCache.setCurrentModificationsAndTimeIndex(resource);
}
+ public void setCurrentTimeIndex(final ITimeIndex timeIndex) {
+ schemaCache.setCurrentTimeIndex(timeIndex);
+ }
+
public void autoCreateAndVerify(
TsFileSequenceReader reader,
Map<IDeviceID, List<TimeseriesMetadata>> device2TimeseriesMetadataList)
@@ -1060,6 +1066,10 @@ public class LoadTsFileAnalyzer implements AutoCloseable
{
}
}
+ public void setCurrentTimeIndex(final ITimeIndex timeIndex) {
+ currentTimeIndex = timeIndex;
+ }
+
public boolean isDeviceDeletedByMods(IDeviceID device) throws
IllegalPathException {
return ModificationUtils.isDeviceDeletedByMods(
currentModifications, currentTimeIndex, device);
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ModificationUtils.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ModificationUtils.java
index b2a52c71caf..67a3c3c9e8e 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ModificationUtils.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ModificationUtils.java
@@ -39,7 +39,7 @@ import org.apache.tsfile.utils.Pair;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Optional;
+import java.util.Objects;
public class ModificationUtils {
@@ -300,14 +300,14 @@ public class ModificationUtils {
public static boolean isDeviceDeletedByMods(
Collection<Modification> currentModifications, ITimeIndex
currentTimeIndex, IDeviceID device)
throws IllegalPathException {
- if (currentTimeIndex == null) {
- return false;
- }
- Optional<Long> startTime = currentTimeIndex.getStartTime(device);
- Optional<Long> endTime = currentTimeIndex.getEndTime(device);
- if (startTime.isPresent() && endTime.isPresent()) {
- return isDeviceDeletedByMods(currentModifications, device,
startTime.get(), endTime.get());
- }
- return false;
+ return isDeviceDeletedByMods(
+ currentModifications,
+ device,
+ Objects.isNull(currentTimeIndex)
+ ? Long.MIN_VALUE
+ : currentTimeIndex.getStartTime(device).orElse(Long.MIN_VALUE),
+ Objects.isNull(currentTimeIndex)
+ ? Long.MAX_VALUE
+ : currentTimeIndex.getEndTime(device).orElse(Long.MAX_VALUE));
}
}