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/06/03 06:51:10 UTC

[iotdb] branch Updatev5 created (now 23f33dd)

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

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


      at 23f33dd  Fix upgrade tool cannot close file reader

This branch includes the following new commits:

     new 23f33dd  Fix upgrade tool cannot close file reader

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: Fix upgrade tool cannot close file reader

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

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

commit 23f33dd5af8417a7825f9276ac94107a4a831e24
Author: HTHou <hh...@outlook.com>
AuthorDate: Thu Jun 3 14:50:06 2021 +0800

    Fix upgrade tool cannot close file reader
---
 .../org/apache/iotdb/db/tools/TsFileRewriteTool.java   | 18 ++++++++++++++++++
 .../db/tools/upgrade/TsFileOnlineUpgradeTool.java      |  4 +---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/tools/TsFileRewriteTool.java b/server/src/main/java/org/apache/iotdb/db/tools/TsFileRewriteTool.java
index 842fd00..955ed77 100644
--- a/server/src/main/java/org/apache/iotdb/db/tools/TsFileRewriteTool.java
+++ b/server/src/main/java/org/apache/iotdb/db/tools/TsFileRewriteTool.java
@@ -41,6 +41,7 @@ import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
 import org.apache.iotdb.tsfile.read.common.BatchData;
 import org.apache.iotdb.tsfile.read.reader.page.PageReader;
 import org.apache.iotdb.tsfile.utils.Binary;
+import org.apache.iotdb.tsfile.v2.read.TsFileSequenceReaderForV2;
 import org.apache.iotdb.tsfile.write.chunk.ChunkWriterImpl;
 import org.apache.iotdb.tsfile.write.chunk.IChunkWriter;
 import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
@@ -106,6 +107,23 @@ public class TsFileRewriteTool implements AutoCloseable {
     }
   }
 
+  public TsFileRewriteTool(TsFileResource resourceToBeRewritten, boolean needReaderForV2)
+      throws IOException {
+    oldTsFile = resourceToBeRewritten.getTsFile();
+    String file = oldTsFile.getAbsolutePath();
+    if (needReaderForV2) {
+      reader = new TsFileSequenceReaderForV2(file);
+    } else {
+      reader = new TsFileSequenceReader(file);
+    }
+    partitionWriterMap = new HashMap<>();
+    if (FSFactoryProducer.getFSFactory().getFile(file + ModificationFile.FILE_SUFFIX).exists()) {
+      oldModification = (List<Modification>) resourceToBeRewritten.getModFile().getModifications();
+      modsIterator = oldModification.iterator();
+      fileModificationMap = new HashMap<>();
+    }
+  }
+
   /**
    * Rewrite an old file to the latest version
    *
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 a876044..90646b5 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
@@ -61,9 +61,7 @@ public class TsFileOnlineUpgradeTool extends TsFileRewriteTool {
    * @throws IOException If some I/O error occurs
    */
   public TsFileOnlineUpgradeTool(TsFileResource resourceToBeUpgraded) throws IOException {
-    super(resourceToBeUpgraded);
-    String file = oldTsFile.getAbsolutePath();
-    reader = new TsFileSequenceReaderForV2(file);
+    super(resourceToBeUpgraded, true);
   }
 
   /**