You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ma...@apache.org on 2022/10/13 08:02:20 UTC

[iotdb] branch IOTDB-4636-0.13 created (now 1e4bb82329)

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

marklau99 pushed a change to branch IOTDB-4636-0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 1e4bb82329 check before compacting aligned series

This branch includes the following new commits:

     new 1e4bb82329 check before compacting aligned series

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: check before compacting aligned series

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

marklau99 pushed a commit to branch IOTDB-4636-0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 1e4bb8232992e03d6831eab80555a44f31223de3
Author: Liu Xuxin <li...@outlook.com>
AuthorDate: Thu Oct 13 16:02:01 2022 +0800

    check before compacting aligned series
---
 .../inner/utils/AlignedSeriesCompactionExecutor.java |  2 ++
 .../inner/utils/InnerSpaceCompactionUtils.java       | 20 ++++++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/utils/AlignedSeriesCompactionExecutor.java b/server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/utils/AlignedSeriesCompactionExecutor.java
index dbd5b98bec..fd1ec218b2 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/utils/AlignedSeriesCompactionExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/utils/AlignedSeriesCompactionExecutor.java
@@ -111,6 +111,7 @@ public class AlignedSeriesCompactionExecutor {
   }
 
   public void execute() throws IOException {
+    writer.startChunkGroup(device);
     while (readerAndChunkMetadataList.size() > 0) {
       Pair<TsFileSequenceReader, List<AlignedChunkMetadata>> readerListPair =
           readerAndChunkMetadataList.removeFirst();
@@ -135,6 +136,7 @@ public class AlignedSeriesCompactionExecutor {
           chunkWriter.estimateMaxSeriesMemSize());
       chunkWriter.writeToFileWriter(writer);
     }
+    writer.endChunkGroup();
     writer.checkMetadataSizeAndMayFlush();
   }
 
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/utils/InnerSpaceCompactionUtils.java b/server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/utils/InnerSpaceCompactionUtils.java
index e21a5c3a57..6e43ee6988 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/utils/InnerSpaceCompactionUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/utils/InnerSpaceCompactionUtils.java
@@ -80,13 +80,13 @@ public class InnerSpaceCompactionUtils {
         String device = deviceInfo.left;
         boolean aligned = deviceInfo.right;
 
-        writer.startChunkGroup(device);
         if (aligned) {
           compactAlignedSeries(device, targetResource, writer, deviceIterator);
         } else {
+          writer.startChunkGroup(device);
           compactNotAlignedSeries(device, targetResource, writer, deviceIterator);
+          writer.endChunkGroup();
         }
-        writer.endChunkGroup();
       }
 
       for (TsFileResource tsFileResource : tsFileResources) {
@@ -140,12 +140,28 @@ public class InnerSpaceCompactionUtils {
     checkThreadInterrupted(targetResource);
     LinkedList<Pair<TsFileSequenceReader, List<AlignedChunkMetadata>>> readerAndChunkMetadataList =
         deviceIterator.getReaderAndChunkMetadataForCurrentAlignedSeries();
+    if (!checkAlignedSeriesValid(readerAndChunkMetadataList)) {
+      return;
+    }
     AlignedSeriesCompactionExecutor compactionExecutor =
         new AlignedSeriesCompactionExecutor(
             device, targetResource, readerAndChunkMetadataList, writer);
     compactionExecutor.execute();
   }
 
+  /** Ensure that there is at least one chunk that is not empty. */
+  private static boolean checkAlignedSeriesValid(
+      LinkedList<Pair<TsFileSequenceReader, List<AlignedChunkMetadata>>>
+          readerAndChunkMetadataList) {
+    for (Pair<TsFileSequenceReader, List<AlignedChunkMetadata>> readerMetadataPair :
+        readerAndChunkMetadataList) {
+      if (!readerMetadataPair.right.isEmpty()) {
+        return true;
+      }
+    }
+    return false;
+  }
+
   public static boolean deleteTsFilesInDisk(
       Collection<TsFileResource> mergeTsFiles, String storageGroupName) {
     logger.info("{} [Compaction] Compaction starts to delete real file ", storageGroupName);