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 11:13:18 UTC

[iotdb] branch master updated: Fix load TsFile failed when time partition enabled caused by TsFileReWriteTool NPE (#3870)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2920d4c  Fix load TsFile failed when time partition enabled caused by TsFileReWriteTool NPE (#3870)
2920d4c is described below

commit 2920d4c6d64aa73142552b1f26ec77010318b30b
Author: Haonan <hh...@outlook.com>
AuthorDate: Mon Aug 30 19:12:52 2021 +0800

    Fix load TsFile failed when time partition enabled caused by TsFileReWriteTool NPE (#3870)
---
 .../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 60c42ea..3feed55 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 0c293af..0a79c09 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
@@ -166,6 +166,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 measurementId - measurementId of this time series