You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2021/03/31 03:12:41 UTC

[iotdb] branch upgradeFileName created (now f0e977b)

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

haonan pushed a change to branch upgradeFileName
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at f0e977b  upgradeFileName

This branch includes the following new commits:

     new f0e977b  upgradeFileName

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[iotdb] 01/01: upgradeFileName

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f0e977b5685ecc3f10eb633bc234a29358811329
Author: HTHou <hh...@outlook.com>
AuthorDate: Wed Mar 31 11:12:00 2021 +0800

    upgradeFileName
---
 .../iotdb/db/tools/upgrade/TsFileOnlineUpgradeTool.java   | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/tools/upgrade/TsFileOnlineUpgradeTool.java b/server/src/main/java/org/apache/iotdb/db/tools/upgrade/TsFileOnlineUpgradeTool.java
index b7e0842..c07af7e 100644
--- a/server/src/main/java/org/apache/iotdb/db/tools/upgrade/TsFileOnlineUpgradeTool.java
+++ b/server/src/main/java/org/apache/iotdb/db/tools/upgrade/TsFileOnlineUpgradeTool.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.db.engine.modification.ModificationFile;
 import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
 import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
 import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
+import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.encoding.decoder.Decoder;
 import org.apache.iotdb.tsfile.exception.write.PageException;
 import org.apache.iotdb.tsfile.exception.write.UnSupportedDataTypeException;
@@ -85,7 +86,7 @@ public class TsFileOnlineUpgradeTool implements AutoCloseable {
    * file metadata size. Then the reader will skip the first TSFileConfig.OLD_MAGIC_STRING.length()
    * bytes of the file for preparing reading real data.
    *
-   * @param file the data file
+   * @param resourceToBeUpgraded old version tsFile's resource
    * @throws IOException If some I/O error occurs
    */
   public TsFileOnlineUpgradeTool(TsFileResource resourceToBeUpgraded) throws IOException {
@@ -103,7 +104,7 @@ public class TsFileOnlineUpgradeTool implements AutoCloseable {
   /**
    * upgrade a single TsFile
    *
-   * @param tsFileName old version tsFile's absolute path
+   * @param resourceToBeUpgraded old version tsFile's resource
    * @param upgradedResources new version tsFiles' resources
    */
   public static void upgradeOneTsfile(
@@ -351,10 +352,10 @@ public class TsFileOnlineUpgradeTool implements AutoCloseable {
           }
           File newFile =
               FSFactoryProducer.getFSFactory()
-                  .getFile(partitionDir + File.separator + oldTsFile.getName());
+                  .getFile(partitionDir + File.separator + upgradeTsFileName(oldTsFile.getName()));
           try {
             if (newFile.exists()) {
-              logger.debug("delete uncomplated file {}", newFile);
+              logger.debug("Delete uncompleted file {}", newFile);
               Files.delete(newFile.toPath());
             }
             if (!newFile.createNewFile()) {
@@ -373,6 +374,12 @@ public class TsFileOnlineUpgradeTool implements AutoCloseable {
         });
   }
 
+  // TsFileName is changing like from 1610635230693-1-0.tsfile to 1610635230693-1-0-0.tsfile
+  private String upgradeTsFileName(String oldTsFileName) {
+    String[] name = oldTsFileName.split(TsFileConstant.TSFILE_SUFFIX);
+    return name[0] + "-0" + TsFileConstant.TSFILE_SUFFIX;
+  }
+
   private void writePageInToFile(
       File oldTsFile,
       MeasurementSchema schema,