Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Drill, mail # dev - [2/3] git commit: DRILL-467: support multiple "and" join conditions in merge join operator.


Copy link to this message
-
[2/3] git commit: DRILL-467: support multiple "and" join conditions in merge join operator.
jacques@... 2014-03-29, 22:08
DRILL-467: support multiple "and" join conditions in merge join operator.

DRILL-467: Support multiple "and" join conditions in merge join operator.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/356c2dba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/356c2dba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/356c2dba

Branch: refs/heads/master
Commit: 356c2dba979c12c1768f8aa4f1b9f58a2327b598
Parents: 3651182
Author: Jinfeng Ni <[EMAIL PROTECTED]>
Authored: Thu Mar 27 14:34:48 2014 -0700
Committer: Jacques Nadeau <[EMAIL PROTECTED]>
Committed: Sat Mar 29 14:38:34 2014 -0700

 .../exec/physical/impl/join/MergeJoinBatch.java | 278 ++++++++++---------
 .../impl/join/TestMergeJoinMulCondition.java    |  71 +++++
 .../test/resources/join/mj_multi_condition.json | 129 +++++++++
 3 files changed, 347 insertions(+), 131 deletions(-)
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/356c2dba/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/MergeJoinBatch.java
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/MergeJoinBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/MergeJoinBatch.java
index e30a649..0a287b6 100644
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/MergeJoinBatch.java
@@ -20,13 +20,11 @@ package org.apache.drill.exec.physical.impl.join;
 import static org.apache.drill.exec.compile.sig.GeneratorMapping.GM;
 
 import java.io.IOException;
+import java.util.List;
 
 import org.apache.drill.common.expression.ErrorCollector;
 import org.apache.drill.common.expression.ErrorCollectorImpl;
-import org.apache.drill.common.expression.ExpressionPosition;
-import org.apache.drill.common.expression.FunctionCall;
 import org.apache.drill.common.expression.LogicalExpression;
-import org.apache.drill.common.logical.data.Join;
 import org.apache.drill.common.logical.data.JoinCondition;
 import org.apache.drill.exec.compile.sig.MappingSet;
 import org.apache.drill.exec.exception.ClassTransformationException;
@@ -34,12 +32,11 @@ import org.apache.drill.exec.exception.SchemaChangeException;
 import org.apache.drill.exec.expr.ClassGenerator;
 import org.apache.drill.exec.expr.CodeGenerator;
 import org.apache.drill.exec.expr.ExpressionTreeMaterializer;
-import org.apache.drill.exec.expr.HoldingContainerExpression;
 import org.apache.drill.exec.expr.TypeHelper;
+import org.apache.drill.exec.expr.ClassGenerator.HoldingContainer;
 import org.apache.drill.exec.expr.fn.FunctionGenerationHelper;
 import org.apache.drill.exec.ops.FragmentContext;
 import org.apache.drill.exec.physical.config.MergeJoinPOP;
-import org.apache.drill.exec.physical.impl.filter.ReturnValueExpression;
 import org.apache.drill.exec.physical.impl.join.JoinWorker.JoinOutcome;
 import org.apache.drill.exec.record.AbstractRecordBatch;
 import org.apache.drill.exec.record.BatchSchema;
@@ -51,8 +48,8 @@ import org.apache.drill.exec.vector.ValueVector;
 import org.apache.drill.exec.vector.allocator.VectorAllocator;
 import org.eigenbase.rel.JoinRelType;
 
-import com.google.common.collect.ImmutableList;
 import com.sun.codemodel.JClass;
+import com.sun.codemodel.JConditional;
 import com.sun.codemodel.JExpr;
 import com.sun.codemodel.JMod;
 import com.sun.codemodel.JType;
@@ -64,21 +61,7 @@ import com.sun.codemodel.JVar;
 public class MergeJoinBatch extends AbstractRecordBatch<MergeJoinPOP> {
 
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(MergeJoinBatch.class);
-  
-//  private static GeneratorMapping setup = GM("doSetup", "doSetup");
-//  private static GeneratorMapping copyLeft = GM("doSetup", "doCopyLeft");
-//  private static GeneratorMapping copyRight = GM("doSetup", "doCopyRight");
-//  private static GeneratorMapping compare = GM("doSetup", "doCompare");
-//  private static GeneratorMapping compareLeft= GM("doSetup", "doCompareNextLeftKey");
-//  
-//  private static final MappingSet SETUP_MAPPING = new MappingSet((String) null, null, setup, setup);
-//  private static final MappingSet COPY_LEFT_MAPPING = new MappingSet("leftIndex", "outIndex", copyLeft, copyLeft);
-//  private static final MappingSet COPY_RIGHT_MAPPING = new MappingSet("rightIndex", "outIndex", copyRight, copyRight);
-//  private static final MappingSet COMPARE_MAPPING = new MappingSet("leftIndex", "rightIndex", compare, compare);
-//  private static final MappingSet COMPARE_RIGHT_MAPPING = new MappingSet("rightIndex", null, compare, compare);
-//  private static final MappingSet COMPARE_LEFT_MAPPING = new MappingSet("leftIndex", "null", compareLeft, compareLeft);
-//  private static final MappingSet COMPARE_NEXT_LEFT_MAPPING = new MappingSet("nextLeftIndex", "null", compareLeft, compareLeft);
-//  
+    
   public final MappingSet setupMapping =
       new MappingSet("null", "null",
                      GM("doSetup", "doSetup", null, null),
@@ -112,7 +95,7 @@ public class MergeJoinBatch extends AbstractRecordBatch<MergeJoinPOP> {
   private final RecordBatch left;
   private final RecordBatch right;
   private final JoinStatus status;
-  private final JoinCondition condition;
+  private final List<JoinCondition> conditions;
   private final JoinRelType joinType;
   private JoinWorker worker;
   public MergeJoinBatchBuilder batchBuilder;
@@ -120,14 +103,13 @@ public class MergeJoinBatch extends AbstractRecordBatch<MergeJoinPOP> {
   protected MergeJoinBatch(MergeJoinPOP popConfig, FragmentContext context, RecordBatch left, RecordBatch right) {
     super(popConfig, context);
     // currently only one join condition is supported
-    assert popConfig.getConditions().size() == 1 : String.format("Merge Join currently only supports joins with a single condition.  This join operator was configured with %d condition(s).", popConfig.getConditions().size());
+    assert popConfig.getConditio