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

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

commit d391752d1186d7aa4ff1d2397b947776d1a2d533
Author: lancelly <[email protected]>
AuthorDate: Wed Oct 11 13:22:20 2023 +0800

    add time watch on prepareInput of AbstractConsumeAllOperator
---
 .../operator/process/AbstractConsumeAllOperator.java    | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractConsumeAllOperator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractConsumeAllOperator.java
index c078bfb1308..f28460b9473 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractConsumeAllOperator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AbstractConsumeAllOperator.java
@@ -47,7 +47,7 @@ public abstract class AbstractConsumeAllOperator extends 
AbstractOperator
   protected int currentChildIndex = 0;
 
   /** Indicate whether we found an empty child input in one loop */
-  protected boolean hasEmptyChild = false;
+  protected boolean hasEmptyChildInput = false;
 
   protected AbstractConsumeAllOperator(OperatorContext operatorContext, 
List<Operator> children) {
     this.operatorContext = operatorContext;
@@ -91,7 +91,6 @@ public abstract class AbstractConsumeAllOperator extends 
AbstractOperator
    * @throws Exception errors happened while getting tsblock from children
    */
   protected boolean prepareInput() throws Exception {
-
     // start stopwatch
     long maxRuntime = 
operatorContext.getMaxRunTime().roundTo(TimeUnit.NANOSECONDS);
     long start = System.nanoTime();
@@ -113,7 +112,7 @@ public abstract class AbstractConsumeAllOperator extends 
AbstractOperator
           // the data that is not empty, but this will cause the execution 
time of the while loop
           // to be uncontrollable and may exceed all allocated time slice
           if (isEmpty(currentChildIndex)) {
-            hasEmptyChild = true;
+            hasEmptyChildInput = true;
           } else {
             processCurrentInputTsBlock(currentChildIndex);
           }
@@ -121,7 +120,7 @@ public abstract class AbstractConsumeAllOperator extends 
AbstractOperator
           handleFinishedChild(currentChildIndex);
         }
       } else {
-        hasEmptyChild = true;
+        hasEmptyChildInput = true;
       }
       currentChildIndex++;
     }
@@ -129,10 +128,13 @@ public abstract class AbstractConsumeAllOperator extends 
AbstractOperator
     if (currentChildIndex == inputOperatorsCount) {
       // start a new loop
       currentChildIndex = 0;
-      if (!hasEmptyChild) {
+      if (!hasEmptyChildInput) {
+        // all children are ready now
         return true;
       } else {
-        hasEmptyChild = false;
+        // In a new loop, previously empty child input could be non-empty now, 
and we can skip the
+        // children that have generated input
+        hasEmptyChildInput = false;
       }
     }
     return false;
@@ -176,8 +178,9 @@ public abstract class AbstractConsumeAllOperator extends 
AbstractOperator
         child.close();
       }
     }
-    children.clear();
+
     // friendly for gc
+    children.clear();
     inputTsBlocks = null;
   }
 

Reply via email to