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/08/30 07:45:43 UTC

[iotdb] branch rel/0.12 updated: [To rel/0.12] Fix load TsFile failed caused by TsFileReWriteTool NPE when time partition enabled (#3864)

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

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


The following commit(s) were added to refs/heads/rel/0.12 by this push:
     new 7874566  [To rel/0.12] Fix load TsFile failed caused by TsFileReWriteTool NPE when time partition enabled (#3864)
7874566 is described below

commit 78745664f83f5b2a4df502723fa6300e6a8ddc3f
Author: Haonan <hh...@outlook.com>
AuthorDate: Mon Aug 30 15:45:20 2021 +0800

    [To rel/0.12] Fix load TsFile failed caused by TsFileReWriteTool NPE when time partition enabled (#3864)
---
 .../main/java/org/apache/iotdb/db/tools/TsFileRewriteTool.java |  2 +-
 .../org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java   | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

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 84b075f..53ad1e6 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
@@ -306,7 +306,7 @@ public class TsFileRewriteTool implements AutoCloseable {
     for (Entry<Long, ChunkWriterImpl> entry : partitionChunkWriterMap.entrySet()) {
       long partitionId = entry.getKey();
       TsFileIOWriter tsFileIOWriter = partitionWriterMap.get(partitionId);
-      if (firstChunkInChunkGroup) {
+      if (firstChunkInChunkGroup || !tsFileIOWriter.isWritingChunkGroup()) {
         tsFileIOWriter.startChunkGroup(deviceId);
       }
       // write chunks to their own upgraded tsFiles
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
index 3df2eb9..d0818f3 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
@@ -161,6 +161,16 @@ public class TsFileIOWriter {
   }
 
   /**
+   * For TsFileReWriteTool / UpgradeTool. Use this method to determine if needs to start a
+   * ChunkGroup.
+   *
+   * @return isWritingChunkGroup
+   */
+  public boolean isWritingChunkGroup() {
+    return currentChunkGroupDeviceId != null;
+  }
+
+  /**
    * start a {@linkplain ChunkMetadata ChunkMetaData}.
    *
    * @param measurementSchema - schema of this time series