drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ve...@apache.org
Subject [2/3] drill git commit: DRILL-2010: MergeJoin: Store/restore the right batch state when existing join loop due to output batch full.
Date Fri, 20 Mar 2015 18:31:51 GMT
DRILL-2010: MergeJoin: Store/restore the right batch state when existing join loop due to output
batch full.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/cfd88dbf
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/cfd88dbf
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/cfd88dbf

Branch: refs/heads/master
Commit: cfd88dbf61101e86aea7de8ac0409e029ee30ffc
Parents: d7dc0b9
Author: vkorukanti <venki.korukanti@gmail.com>
Authored: Fri Mar 6 06:58:07 2015 -0800
Committer: vkorukanti <venki.korukanti@gmail.com>
Committed: Thu Mar 19 22:16:46 2015 -0700

----------------------------------------------------------------------
 .../exec/physical/impl/join/JoinStatus.java     | 26 ++++++++++++++++++++
 .../exec/physical/impl/join/JoinTemplate.java   | 24 +++++++++++++-----
 2 files changed, 44 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/cfd88dbf/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinStatus.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinStatus.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinStatus.java
index 299fd3a..5fb2585 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinStatus.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinStatus.java
@@ -60,6 +60,10 @@ public final class JoinStatus {
   public MergeJoinBatch outputBatch;
   public SelectionVector4 sv4;
 
+  private boolean hasIntermediateData;
+  private int initialRightPosition = -1;
+  private boolean crossedBatchBoundaries;
+
   private final JoinRelType joinType;
 
   public boolean ok = true;
@@ -97,6 +101,28 @@ public final class JoinStatus {
         + "]";
   }
 
+  public boolean hasIntermediateData() {
+    return hasIntermediateData;
+  }
+
+  public void resetIntermediateData() {
+    hasIntermediateData = false;
+  }
+
+  public void setIntermediateData(int initialRightPosition, boolean crossedBatchBoundaries)
{
+    this.initialRightPosition = initialRightPosition;
+    this.crossedBatchBoundaries = crossedBatchBoundaries;
+    this.hasIntermediateData = true;
+  }
+
+  public int getInitialRightPosition() {
+    return initialRightPosition;
+  }
+
+  public boolean getCrossedBatchBoundaries() {
+    return crossedBatchBoundaries;
+  }
+
   private final IterOutcome nextLeft() {
     return outputBatch.next(LEFT_INPUT, left);
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/cfd88dbf/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinTemplate.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinTemplate.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinTemplate.java
index 7da9788..6da10d2 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinTemplate.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinTemplate.java
@@ -95,7 +95,7 @@ public abstract class JoinTemplate implements JoinWorker {
           // we've hit the end of the right record batch; copy any remaining values from
the left batch
           while (status.isLeftPositionAllowed()) {
             if (status.isOutgoingBatchFull()) {
-              return false;
+              return true;
             }
             doCopyLeft(status.getLeftPosition(), status.getOutPosition());
 
@@ -137,11 +137,21 @@ public abstract class JoinTemplate implements JoinWorker {
           status.notifyLeftStoppedRepeating();
         }
 
-        boolean crossedBatchBoundaries = false;
-        int initialRightPosition = status.getRightPosition();
+        boolean crossedBatchBoundaries;
+        int initialRightPosition;
+        if (status.hasIntermediateData()) {
+          crossedBatchBoundaries = status.getCrossedBatchBoundaries();
+          initialRightPosition = status.getInitialRightPosition();
+          status.resetIntermediateData();
+        } else {
+          crossedBatchBoundaries = false;
+          initialRightPosition = status.getRightPosition();
+        }
+
         do {
           if (status.isOutgoingBatchFull()) {
-            return false;
+            status.setIntermediateData(initialRightPosition, crossedBatchBoundaries);
+            return true;
           }
           // copy all equal right keys to the output record batch
           doCopyLeft(status.getLeftPosition(), status.getOutPosition());
@@ -170,7 +180,8 @@ public abstract class JoinTemplate implements JoinWorker {
         }
         status.advanceLeft();
 
-        if (status.isLeftRepeating() && doCompareNextLeftKey(status.getLeftPosition())
!= 0) {
+        if (status.isLeftRepeating() && status.isNextLeftPositionInCurrentBatch()
&&
+          doCompareNextLeftKey(status.getLeftPosition()) != 0) {
           // left no longer has duplicates.  switch back to incoming batch mode
           status.setDefaultAdvanceMode();
           status.notifyLeftStoppedRepeating();
@@ -197,7 +208,8 @@ public abstract class JoinTemplate implements JoinWorker {
         throw new IllegalStateException();
       }
     }
-    return false;
+
+    return true;
   }
 
   // Generated Methods


Mime
View raw message