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

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


The following commit(s) were added to refs/heads/rel/0.11 by this push:
     new ab90c93  [IOTDB-1398] Do not select unseq files when there are 
uncompacted old unseq files
     new 73dc164  Merge pull request #3283 from 
zhanglingzhe0820/to_0.11_select_unseq_file_by_order
ab90c93 is described below

commit ab90c932d7413bf6d7513ee7e47deddc8632a031
Author: jt <[email protected]>
AuthorDate: Thu May 27 11:33:44 2021 +0800

    [IOTDB-1398] Do not select unseq files when there are uncompacted old unseq 
files
---
 .../merge/selector/MaxFileMergeFileSelector.java    | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/engine/merge/selector/MaxFileMergeFileSelector.java
 
b/server/src/main/java/org/apache/iotdb/db/engine/merge/selector/MaxFileMergeFileSelector.java
index 7cc23e5..1e1acdf 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/engine/merge/selector/MaxFileMergeFileSelector.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/engine/merge/selector/MaxFileMergeFileSelector.java
@@ -164,10 +164,14 @@ public class MaxFileMergeFileSelector implements 
IMergeFileSelector {
       }
 
       tempMaxSeqFileCost = maxSeqFileCost;
-      long newCost = useTightBound ? calculateTightMemoryCost(unseqFile, 
tmpSelectedSeqFiles,
-          startTime, timeLimit) :
-          calculateLooseMemoryCost(unseqFile, tmpSelectedSeqFiles, startTime, 
timeLimit);
-      updateSelectedFiles(newCost, unseqFile);
+      long newCost =
+          useTightBound
+              ? calculateTightMemoryCost(unseqFile, tmpSelectedSeqFiles, 
startTime, timeLimit)
+              : calculateLooseMemoryCost(unseqFile, tmpSelectedSeqFiles, 
startTime, timeLimit);
+      if (!updateSelectedFiles(newCost, unseqFile)) {
+        // older unseq files must be merged before newer ones
+        break;
+      }
 
       tmpSelectedSeqFiles.clear();
       unseqIndex++;
@@ -180,7 +184,7 @@ public class MaxFileMergeFileSelector implements 
IMergeFileSelector {
     }
   }
 
-  private void updateSelectedFiles(long newCost, TsFileResource unseqFile) {
+  private boolean updateSelectedFiles(long newCost, TsFileResource unseqFile) {
     if (totalCost + newCost < memoryBudget) {
       selectedUnseqFiles.add(unseqFile);
       maxSeqFileCost = tempMaxSeqFileCost;
@@ -192,8 +196,13 @@ public class MaxFileMergeFileSelector implements 
IMergeFileSelector {
       totalCost += newCost;
       logger.debug("Adding a new unseqFile {} and seqFiles {} as candidates, 
new cost {}, total"
               + " cost {}",
-          unseqFile, tmpSelectedSeqFiles, newCost, totalCost);
+          unseqFile,
+          tmpSelectedSeqFiles,
+          newCost,
+          totalCost);
+      return true;
     }
+    return false;
   }
 
   private boolean checkClosed(TsFileResource unseqFile) {

Reply via email to