THUMarkLau commented on a change in pull request #4549:
URL: https://github.com/apache/iotdb/pull/4549#discussion_r766301030
##########
File path:
server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/utils/InnerSpaceCompactionUtils.java
##########
@@ -584,4 +587,40 @@ public static ICrossSpaceMergeFileSelector
getCrossSpaceFileSelector(
return new File[0];
}
}
+
+ /**
+ * Update the targetResource. Move xxx.target to xxx.tsfile and
xxx.target.resource to
+ * xxx.tsfile.resource.
+ *
+ * @param targetResource the old tsfile to be moved, which is xxx.target
+ * @throws IOException
+ */
+ public static void moveTargetFile(TsFileResource targetResource) throws
IOException {
+ if
(!targetResource.getTsFilePath().endsWith(TsFileNameGenerator.COMPACTION_TMP_FILE_SUFFIX))
{
+ logger.warn(
+ "TmpTargetFileReource "
+ + targetResource.getTsFilePath()
+ + " should be end with "
+ + TsFileNameGenerator.COMPACTION_TMP_FILE_SUFFIX);
+ return;
+ }
+ File oldFile = targetResource.getTsFile();
+
+ // move TsFile and delete .target file
+ String newFilePath =
+ targetResource
+ .getTsFilePath()
+ .replace(TsFileNameGenerator.COMPACTION_TMP_FILE_SUFFIX,
TsFileConstant.TSFILE_SUFFIX);
+ File newFile = new File(newFilePath);
+ FSFactoryProducer.getFSFactory().moveFile(oldFile, newFile);
+
+ // move .resource file
+ targetResource.setFile(newFile);
+ targetResource.setClosed(true);
+ targetResource.serialize();
+
+ // delete old tsfile and .resource file
+ File oldResourceFile = new File(oldFile.getPath() +
TsFileResource.RESOURCE_SUFFIX);
+ oldResourceFile.delete();
Review comment:
check the return value of `delete`
--
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]