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 02:36:13 UTC
[iotdb] 01/01: Fix load TsFile failed when time partition enabled
caused by TsFileReWriteTool NPE
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch rewriteToolNPE
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit c1c8dbea6d29ada5831f9bb2dcf9ed9872c844f7
Author: HTHou <hh...@outlook.com>
AuthorDate: Mon Aug 30 10:35:32 2021 +0800
Fix load TsFile failed when time partition enabled caused by TsFileReWriteTool NPE
---
.../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..dc1b398 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