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

[iotdb] 05/08: invoke readyForFirstIteration() in hasNext() instead of in constructor

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

rong pushed a commit to branch trasnsform-operator-bugfix
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 7e47110c8d6a151e2c411faf507c81e3a48c5fca
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Mon May 16 12:03:52 2022 +0800

    invoke readyForFirstIteration() in hasNext() instead of in constructor
---
 .../db/mpp/execution/operator/process/FilterOperator.java  |  5 +++++
 .../mpp/execution/operator/process/TransformOperator.java  | 14 +++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/FilterOperator.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/FilterOperator.java
index f6a7122fb9..54023374cf 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/FilterOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/FilterOperator.java
@@ -161,6 +161,11 @@ public class FilterOperator extends TransformOperator {
   @Override
   public boolean hasNext() {
     try {
+      if (isFirstIteration) {
+        readyForFirstIteration();
+        isFirstIteration = false;
+      }
+
       return filterPointReader.next();
     } catch (Exception e) {
       throw new RuntimeException(e);
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/TransformOperator.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/TransformOperator.java
index 69acb3a9a3..de3cedcc3c 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/TransformOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/TransformOperator.java
@@ -67,6 +67,8 @@ public class TransformOperator implements ProcessOperator {
   protected final Expression[] outputExpressions;
   protected final boolean keepNull;
 
+  protected boolean isFirstIteration;
+
   protected RawQueryInputLayer inputLayer;
   protected UDTFContext udtfContext;
   protected LayerPointReader[] transformers;
@@ -89,10 +91,11 @@ public class TransformOperator implements ProcessOperator {
     this.outputExpressions = outputExpressions;
     this.keepNull = keepNull;
 
+    isFirstIteration = true;
+
     initInputLayer(inputDataTypes);
     initUdtfContext(zoneId);
     initTransformers(inputLocations, typeProvider);
-    readyForFirstIteration();
   }
 
   private void initInputLayer(List<TSDataType> inputDataTypes) throws QueryProcessException {
@@ -157,6 +160,15 @@ public class TransformOperator implements ProcessOperator {
 
   @Override
   public boolean hasNext() {
+    if (isFirstIteration) {
+      try {
+        readyForFirstIteration();
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+      isFirstIteration = false;
+    }
+
     return !timeHeap.isEmpty();
   }