You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/12/22 04:40:28 UTC

[iotdb] 01/02: fix the bug when checking target seq files

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

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

commit 5a8e43df3d0d4de881dd6747a2638cc858866894
Author: Jinrui.Zhang <xi...@gmail.com>
AuthorDate: Thu Dec 22 00:14:01 2022 +0800

    fix the bug when checking target seq files
---
 .../cross/rewrite/CrossSpaceCompactionCandidate.java   | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/compaction/cross/rewrite/CrossSpaceCompactionCandidate.java b/server/src/main/java/org/apache/iotdb/db/engine/compaction/cross/rewrite/CrossSpaceCompactionCandidate.java
index 4ff2759af4..f3ddb7c230 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/compaction/cross/rewrite/CrossSpaceCompactionCandidate.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/compaction/cross/rewrite/CrossSpaceCompactionCandidate.java
@@ -70,12 +70,9 @@ public class CrossSpaceCompactionCandidate {
   private boolean prepareNextSplit() {
     TsFileResourceCandidate unseqFile = unseqFiles.get(nextUnseqFileIndex);
     List<TsFileResourceCandidate> ret = new ArrayList<>();
-    boolean lastTargetSeqFileSelected = false;
-    for (TsFileResourceCandidate seqFile : seqFiles) {
-      if (lastTargetSeqFileSelected) {
-        break;
-      }
-      for (DeviceInfo unseqDeviceInfo : unseqFile.getDevices()) {
+
+    for (DeviceInfo unseqDeviceInfo : unseqFile.getDevices()) {
+      for (TsFileResourceCandidate seqFile : seqFiles) {
         if (!seqFile.containsDevice(unseqDeviceInfo.deviceId)) {
           continue;
         }
@@ -92,24 +89,21 @@ public class CrossSpaceCompactionCandidate {
           // avoid duplication selection
           if (!seqFile.selected) {
             ret.add(seqFile);
+            seqFile.markAsSelected();
           }
-          // prepare
-          lastTargetSeqFileSelected = true;
+          // if this condition is satisfied, all subsequent seq files is unnecessary to check
           break;
         } else if (unseqDeviceInfo.startTime <= seqDeviceInfo.endTime) {
           if (!seqFile.selected) {
             ret.add(seqFile);
+            seqFile.markAsSelected();
           }
-          break;
         }
       }
     }
     // mark candidates in next split as selected even though it may not be added to the final
     // TaskResource
     unseqFile.markAsSelected();
-    for (TsFileResourceCandidate fileCandidate : ret) {
-      fileCandidate.markAsSelected();
-    }
     nextSplit = new CrossCompactionTaskResourceSplit(unseqFile, ret);
     return true;
   }