jt2594838 commented on code in PR #16687:
URL: https://github.com/apache/iotdb/pull/16687#discussion_r2485247224
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java:
##########
@@ -2905,6 +2905,44 @@ private void
deleteDataInSealedFiles(Collection<TsFileResource> sealedTsFiles, M
continue;
}
+ ArrayDeviceTimeIndex deviceTimeIndex = (ArrayDeviceTimeIndex)
sealedTsFile.getTimeIndex();
+ Set<IDeviceID> devicesInFile = deviceTimeIndex.getDevices();
+ boolean onlyOneTable = devicesInFile.size() == 1;
+ IDeviceID theOnlyDevice = onlyOneTable ? devicesInFile.iterator().next()
: null;
Review Comment:
The file does not necessarily have an ArrayDeviceTimeIndex.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java:
##########
@@ -2905,6 +2905,44 @@ private void
deleteDataInSealedFiles(Collection<TsFileResource> sealedTsFiles, M
continue;
}
+ ArrayDeviceTimeIndex deviceTimeIndex = (ArrayDeviceTimeIndex)
sealedTsFile.getTimeIndex();
+ Set<IDeviceID> devicesInFile = deviceTimeIndex.getDevices();
+ boolean onlyOneTable = devicesInFile.size() == 1;
+ IDeviceID theOnlyDevice = onlyOneTable ? devicesInFile.iterator().next()
: null;
Review Comment:
onlyOneTable != onlyOneDevice
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java:
##########
@@ -2905,6 +2905,44 @@ private void
deleteDataInSealedFiles(Collection<TsFileResource> sealedTsFiles, M
continue;
}
+ ArrayDeviceTimeIndex deviceTimeIndex = (ArrayDeviceTimeIndex)
sealedTsFile.getTimeIndex();
+ Set<IDeviceID> devicesInFile = deviceTimeIndex.getDevices();
+ boolean onlyOneTable = devicesInFile.size() == 1;
+ IDeviceID theOnlyDevice = onlyOneTable ? devicesInFile.iterator().next()
: null;
+
+ boolean fileFullyDeleted = false;
+
+ for (IDeviceID device : devicesInFile) {
+ Optional<Long> optStart = deviceTimeIndex.getStartTime(device);
+ Optional<Long> optEnd = deviceTimeIndex.getEndTime(device);
+ if (!optStart.isPresent() || !optEnd.isPresent()) {
+ continue;
+ }
+
+ long fileStart = optStart.get();
+ long fileEnd = optEnd.get();
+
+ if (onlyOneTable
+ && device.equals(theOnlyDevice)
+ && deletion.getStartTime() <= fileStart
+ && deletion.getEndTime() >= fileEnd) {
+
+ logger.info(
+ "[Deletion] TsFile {} only contains one table and will be
removed physically.",
+ sealedTsFile.getTsFilePath());
+
+ deleteTsFileCompletely(sealedTsFile);
+ removeTsFileResourceFromList(sealedTsFile);
Review Comment:
See how deleteDataDirectlyInFile works.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]