You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by xu...@apache.org on 2015/03/28 15:03:49 UTC

svn commit: r1669775 [12/35] - in /hive/branches/spark: ./ ant/src/org/apache/hadoop/hive/ant/ beeline/src/java/org/apache/hive/beeline/ common/src/java/org/apache/hadoop/hive/common/ common/src/java/org/apache/hadoop/hive/common/type/ common/src/java/...

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/Operator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/Operator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/Operator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/Operator.java Sat Mar 28 14:03:43 2015
@@ -27,6 +27,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.commons.logging.Log;
@@ -68,6 +69,7 @@ public abstract class Operator<T extends
   protected List<Operator<? extends OperatorDesc>> parentOperators;
   protected String operatorId;
   private transient ExecMapperContext execContext;
+  private transient boolean rootInitializeCalled = false;
 
   private static AtomicInteger seqId;
 
@@ -101,13 +103,13 @@ public abstract class Operator<T extends
   // dummy operator (for not increasing seqId)
   private Operator(String name) {
     id = name;
+    initOperatorId();
+    childOperators = new ArrayList<Operator<? extends OperatorDesc>>();
+    parentOperators = new ArrayList<Operator<? extends OperatorDesc>>();
   }
 
   public Operator() {
-    id = String.valueOf(seqId.getAndIncrement());
-    childOperators = new ArrayList<Operator<? extends OperatorDesc>>();
-    parentOperators = new ArrayList<Operator<? extends OperatorDesc>>();
-    initOperatorId();
+    this(String.valueOf(seqId.getAndIncrement()));
   }
 
   public static void resetId() {
@@ -252,11 +254,6 @@ public abstract class Operator<T extends
   public void setReporter(Reporter rep) {
     reporter = rep;
 
-    // the collector is same across all operators
-    if (childOperators == null) {
-      return;
-    }
-
     for (Operator<? extends OperatorDesc> op : childOperators) {
       op.setReporter(rep);
     }
@@ -266,11 +263,6 @@ public abstract class Operator<T extends
   public void setOutputCollector(OutputCollector out) {
     this.out = out;
 
-    // the collector is same across all operators
-    if (childOperators == null) {
-      return;
-    }
-
     for (Operator<? extends OperatorDesc> op : childOperators) {
       op.setOutputCollector(out);
     }
@@ -282,10 +274,6 @@ public abstract class Operator<T extends
   public void setAlias(String alias) {
     this.alias = alias;
 
-    if (childOperators == null) {
-      return;
-    }
-
     for (Operator<? extends OperatorDesc> op : childOperators) {
       op.setAlias(alias);
     }
@@ -306,9 +294,6 @@ public abstract class Operator<T extends
    *         otherwise
    */
   protected boolean areAllParentsInitialized() {
-    if (parentOperators == null) {
-      return true;
-    }
     for (Operator<? extends OperatorDesc> parent : parentOperators) {
       if (parent == null) {
         //return true;
@@ -332,7 +317,7 @@ public abstract class Operator<T extends
    * @throws HiveException
    */
   @SuppressWarnings("unchecked")
-  public void initialize(Configuration hconf, ObjectInspector[] inputOIs)
+  public final void initialize(Configuration hconf, ObjectInspector[] inputOIs)
       throws HiveException {
     if (state == State.INIT) {
       return;
@@ -344,7 +329,7 @@ public abstract class Operator<T extends
     }
 
     if (isLogInfoEnabled) {
-      LOG.info("Initializing Self " + this);
+      LOG.info("Initializing operator " + this);
     }
 
     if (inputOIs != null) {
@@ -352,50 +337,69 @@ public abstract class Operator<T extends
     }
 
     // initialize structure to maintain child op info. operator tree changes
-    // while
-    // initializing so this need to be done here instead of initialize() method
-    if (childOperators != null && !childOperators.isEmpty()) {
-      childOperatorsArray = new Operator[childOperators.size()];
-      for (int i = 0; i < childOperatorsArray.length; i++) {
-        childOperatorsArray[i] = childOperators.get(i);
-      }
-      childOperatorsTag = new int[childOperatorsArray.length];
-      for (int i = 0; i < childOperatorsArray.length; i++) {
-        List<Operator<? extends OperatorDesc>> parentOperators = childOperatorsArray[i]
-            .getParentOperators();
-        if (parentOperators == null) {
-          throw new HiveException("Hive internal error: parent is null in "
-              + childOperatorsArray[i].getClass() + "!");
-        }
-        childOperatorsTag[i] = parentOperators.indexOf(this);
-        if (childOperatorsTag[i] == -1) {
-          throw new HiveException(
-              "Hive internal error: cannot find parent in the child operator!");
-        }
+    // while initializing so this need to be done here instead of constructor
+    childOperatorsArray = new Operator[childOperators.size()];
+    for (int i = 0; i < childOperatorsArray.length; i++) {
+      childOperatorsArray[i] = childOperators.get(i);
+    }
+    childOperatorsTag = new int[childOperatorsArray.length];
+    for (int i = 0; i < childOperatorsArray.length; i++) {
+      List<Operator<? extends OperatorDesc>> parentOperators =
+          childOperatorsArray[i].getParentOperators();
+      childOperatorsTag[i] = parentOperators.indexOf(this);
+      if (childOperatorsTag[i] == -1) {
+        throw new HiveException("Hive internal error: cannot find parent in the child operator!");
       }
     }
 
     if (inputObjInspectors.length == 0) {
       throw new HiveException("Internal Error during operator initialization.");
     }
+
     // derived classes can set this to different object if needed
     outputObjInspector = inputObjInspectors[0];
 
-    //pass the exec context to child operators
-    passExecContext(this.execContext);
+    Collection<Future<?>> asyncInitOperations = initializeOp(hconf);
 
-    initializeOp(hconf);
-
-    // sanity check
-    if (childOperatorsArray == null
-        && !(childOperators == null || childOperators.isEmpty())) {
-      throw new HiveException(
-          "Internal Hive error during operator initialization.");
+    // sanity checks
+    if (!rootInitializeCalled
+	|| asyncInitOperations == null
+	|| childOperatorsArray.length != childOperators.size()) {
+      throw new AssertionError("Internal error during operator initialization");
     }
 
     if (isLogInfoEnabled) {
       LOG.info("Initialization Done " + id + " " + getName());
     }
+
+    initializeChildren(hconf);
+
+    // let's wait on the async ops before continuing
+    completeInitialization(asyncInitOperations);
+  }
+
+  private void completeInitialization(Collection<Future<?>> fs) throws HiveException {
+    Object[] os = new Object[fs.size()];
+    int i = 0;
+    for (Future<?> f : fs) {
+      try {
+        os[i++] = f.get();
+      } catch (Exception e) {
+        throw new HiveException(e);
+      }
+    }
+    completeInitializationOp(os);
+  }
+
+  /**
+   * This metod can be used to retrieve the results from async operations
+   * started at init time - before the operator pipeline is started.
+   *
+   * @param os
+   * @throws HiveException
+   */
+  protected void completeInitializationOp(Object[] os) throws HiveException {
+    // no-op default
   }
 
   public void initializeLocalWork(Configuration hconf) throws HiveException {
@@ -410,8 +414,9 @@ public abstract class Operator<T extends
   /**
    * Operator specific initialization.
    */
-  protected void initializeOp(Configuration hconf) throws HiveException {
-    initializeChildren(hconf);
+  protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+    rootInitializeCalled = true;
+    return new ArrayList<Future<?>>();
   }
 
   /**
@@ -430,8 +435,7 @@ public abstract class Operator<T extends
       LOG.info("Initializing children of " + id + " " + getName());
     }
     for (int i = 0; i < childOperatorsArray.length; i++) {
-      childOperatorsArray[i].initialize(hconf, outputObjInspector,
-          childOperatorsTag[i]);
+      childOperatorsArray[i].initialize(hconf, outputObjInspector, childOperatorsTag[i]);
       if (reporter != null) {
         childOperatorsArray[i].setReporter(reporter);
       }
@@ -443,10 +447,8 @@ public abstract class Operator<T extends
    */
   public void passExecContext(ExecMapperContext execContext) {
     this.setExecContext(execContext);
-    if(childOperators != null) {
-      for (int i = 0; i < childOperators.size(); i++) {
+    for (int i = 0; i < childOperators.size(); i++) {
         childOperators.get(i).passExecContext(execContext);
-      }
     }
   }
 
@@ -501,7 +503,7 @@ public abstract class Operator<T extends
    *          Rows with the same tag should have exactly the same rowInspector
    *          all the time.
    */
-  public abstract void processOp(Object row, int tag) throws HiveException;
+  public abstract void process(Object row, int tag) throws HiveException;
 
   protected final void defaultStartGroup() throws HiveException {
     if (isLogDebugEnabled) {
@@ -598,7 +600,7 @@ public abstract class Operator<T extends
     // check if all parents are finished
     if (!allInitializedParentsAreClosed()) {
       if (isLogDebugEnabled) {
-	LOG.debug("Not all parent operators are closed. Not closing.");
+        LOG.debug("Not all parent operators are closed. Not closing.");
       }
       return;
     }
@@ -822,7 +824,7 @@ public abstract class Operator<T extends
   protected void forward(Object row, ObjectInspector rowInspector)
       throws HiveException {
 
-    if ((childOperatorsArray == null) || (getDone())) {
+    if (getDone()) {
       return;
     }
 
@@ -832,12 +834,12 @@ public abstract class Operator<T extends
       if (o.getDone()) {
         childrenDone++;
       } else {
-        o.processOp(row, childOperatorsTag[i]);
+        o.process(row, childOperatorsTag[i]);
       }
     }
 
     // if all children are done, this operator is also done
-    if (childrenDone == childOperatorsArray.length) {
+    if (childrenDone != 0 && childrenDone == childOperatorsArray.length) {
       setDone(true);
     }
   }
@@ -878,7 +880,7 @@ public abstract class Operator<T extends
   public void logStats() {
     if (isLogInfoEnabled) {
       for (String e : statsMap.keySet()) {
-	LOG.info(e.toString() + ":" + statsMap.get(e).toString());
+        LOG.info(e.toString() + ":" + statsMap.get(e).toString());
       }
     }
   }
@@ -969,7 +971,7 @@ public abstract class Operator<T extends
    * Initialize an array of ExprNodeEvaluator and return the result
    * ObjectInspectors.
    */
-  protected static ObjectInspector[] initEvaluators(ExprNodeEvaluator[] evals,
+  protected static ObjectInspector[] initEvaluators(ExprNodeEvaluator<?>[] evals,
       ObjectInspector rowInspector) throws HiveException {
     ObjectInspector[] result = new ObjectInspector[evals.length];
     for (int i = 0; i < evals.length; i++) {
@@ -982,7 +984,7 @@ public abstract class Operator<T extends
    * Initialize an array of ExprNodeEvaluator from start, for specified length
    * and return the result ObjectInspectors.
    */
-  protected static ObjectInspector[] initEvaluators(ExprNodeEvaluator[] evals,
+  protected static ObjectInspector[] initEvaluators(ExprNodeEvaluator<?>[] evals,
       int start, int length,
       ObjectInspector rowInspector) throws HiveException {
     ObjectInspector[] result = new ObjectInspector[length];
@@ -997,7 +999,7 @@ public abstract class Operator<T extends
    * StructObjectInspector with integer field names.
    */
   protected static StructObjectInspector initEvaluatorsAndReturnStruct(
-      ExprNodeEvaluator[] evals, List<String> outputColName,
+      ExprNodeEvaluator<?>[] evals, List<String> outputColName,
       ObjectInspector rowInspector) throws HiveException {
     ObjectInspector[] fieldObjectInspectors = initEvaluators(evals,
         rowInspector);
@@ -1059,12 +1061,6 @@ public abstract class Operator<T extends
 
   public void setExecContext(ExecMapperContext execContext) {
     this.execContext = execContext;
-    if(this.childOperators != null) {
-      for (int i = 0; i<this.childOperators.size();i++) {
-        Operator<? extends OperatorDesc> op = this.childOperators.get(i);
-        op.setExecContext(execContext);
-      }
-    }
   }
 
   // The input file has changed - every operator can invoke specific action
@@ -1128,6 +1124,7 @@ public abstract class Operator<T extends
    * @return Cloned operator
    * @throws CloneNotSupportedException
    */
+  @SuppressWarnings("unchecked")
   public Operator<? extends OperatorDesc> cloneOp() throws CloneNotSupportedException {
     T descClone = (T) conf.clone();
     Operator<? extends OperatorDesc> ret =
@@ -1148,11 +1145,6 @@ public abstract class Operator<T extends
       throws CloneNotSupportedException {
     Operator<? extends OperatorDesc> newOp = this.cloneOp();
     newOp.setParentOperators(this.parentOperators);
-    // Fix parent in all children
-    if (this.getChildOperators() == null) {
-      newOp.setChildOperators(null);
-      return newOp;
-    }
     List<Operator<? extends OperatorDesc>> newChildren =
         new ArrayList<Operator<? extends OperatorDesc>>();
 
@@ -1301,12 +1293,13 @@ public abstract class Operator<T extends
     if (conf != null) {
       return conf.getStatistics();
     }
+
     return null;
   }
 
   public OpTraits getOpTraits() {
     if (conf != null) {
-      return conf.getOpTraits();
+      return conf.getTraits();
     }
 
     return null;
@@ -1314,36 +1307,48 @@ public abstract class Operator<T extends
 
   public void setOpTraits(OpTraits metaInfo) {
     if (isLogDebugEnabled) {
-      LOG.debug("Setting traits ("+metaInfo+") on "+this);
+      LOG.debug("Setting traits (" + metaInfo + ") on " + this);
     }
     if (conf != null) {
-      conf.setOpTraits(metaInfo);
+      conf.setTraits(metaInfo);
     } else {
-      LOG.warn("Cannot set traits when there's no descriptor: "+this);
+      LOG.warn("Cannot set traits when there's no descriptor: " + this);
     }
   }
 
   public void setStatistics(Statistics stats) {
     if (isLogDebugEnabled) {
-      LOG.debug("Setting stats ("+stats+") on "+this);
+      LOG.debug("Setting stats (" + stats + ") on " + this);
     }
     if (conf != null) {
       conf.setStatistics(stats);
     } else {
-      LOG.warn("Cannot set stats when there's no descriptor: "+this);
+      LOG.warn("Cannot set stats when there's no descriptor: " + this);
     }
   }
 
+  @SuppressWarnings("rawtypes")
   public static Operator createDummy() {
     return new DummyOperator();
   }
 
+  @SuppressWarnings({ "serial", "unchecked", "rawtypes" })
   private static class DummyOperator extends Operator {
     public DummyOperator() { super("dummy"); }
+
     @Override
-    public void processOp(Object row, int tag) { }
+    public void process(Object row, int tag) {
+    }
+
     @Override
-    public OperatorType getType() { return null; }
+    public OperatorType getType() {
+      return null;
+    }
+
+    @Override
+    protected Collection<Future<?>> initializeOp(Configuration conf) {
+      return childOperators;
+    }
   }
 
   public Map<Integer, DummyStoreOperator> getTagToOperatorTree() {

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OperatorFactory.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OperatorFactory.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OperatorFactory.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OperatorFactory.java Sat Mar 28 14:03:43 2015
@@ -18,6 +18,12 @@
 
 package org.apache.hadoop.hive.ql.exec;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.ql.exec.vector.VectorAppMasterEventOperator;
 import org.apache.hadoop.hive.ql.exec.vector.VectorFileSinkOperator;
 import org.apache.hadoop.hive.ql.exec.vector.VectorFilterOperator;
@@ -62,16 +68,13 @@ import org.apache.hadoop.hive.ql.plan.Ta
 import org.apache.hadoop.hive.ql.plan.UDTFDesc;
 import org.apache.hadoop.hive.ql.plan.UnionDesc;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
 /**
  * OperatorFactory.
  *
  */
 @SuppressWarnings({ "rawtypes", "unchecked" })
 public final class OperatorFactory {
+  protected static transient final Log LOG = LogFactory.getLog(OperatorFactory.class);
   private static final List<OpTuple> opvec;
   private static final List<OpTuple> vectorOpvec;
 
@@ -227,9 +230,6 @@ public final class OperatorFactory {
     // Add this parent to the children
     for (Operator<? extends OperatorDesc> op : oplist) {
       List<Operator<? extends OperatorDesc>> parents = op.getParentOperators();
-      if (parents == null) {
-        parents = new ArrayList<Operator<? extends OperatorDesc>>();
-      }
       parents.add(ret);
       op.setParentOperators(parents);
     }
@@ -259,9 +259,6 @@ public final class OperatorFactory {
     // Add the new operator as child of each of the passed in operators
     for (Operator op : oplist) {
       List<Operator> children = op.getChildOperators();
-      if (children == null) {
-        children = new ArrayList<Operator>();
-      }
       children.add(ret);
       op.setChildOperators(children);
     }
@@ -286,17 +283,13 @@ public final class OperatorFactory {
     Operator<T> ret = get((Class<T>) conf.getClass());
     ret.setConf(conf);
     if (oplist.size() == 0) {
-      return (ret);
+      return ret;
     }
 
     // Add the new operator as child of each of the passed in operators
     for (Operator op : oplist) {
       List<Operator> children = op.getChildOperators();
-      if (children == null) {
-        children = new ArrayList<Operator>();
-      }
       children.add(ret);
-      op.setChildOperators(children);
     }
 
     // add parents for the newly created operator
@@ -308,7 +301,7 @@ public final class OperatorFactory {
 
     ret.setParentOperators(parent);
 
-    return (ret);
+    return ret;
   }
 
   /**
@@ -318,7 +311,7 @@ public final class OperatorFactory {
       RowSchema rwsch, Operator... oplist) {
     Operator<T> ret = getAndMakeChild(conf, oplist);
     ret.setSchema(rwsch);
-    return (ret);
+    return ret;
   }
 
   /**

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OperatorUtils.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OperatorUtils.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OperatorUtils.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OperatorUtils.java Sat Mar 28 14:03:43 2015
@@ -122,7 +122,7 @@ public class OperatorUtils {
       if(op.getName().equals(ReduceSinkOperator.getOperatorName())) {
         ReduceSinkOperator rs = ((ReduceSinkOperator)op);
         if (outMap.containsKey(rs.getConf().getOutputName())) {
-          LOG.info("Setting output collector: " + rs + " --> " 
+          LOG.info("Setting output collector: " + rs + " --> "
             + rs.getConf().getOutputName());
           rs.setOutputCollector(outMap.get(rs.getConf().getOutputName()));
         }
@@ -234,9 +234,7 @@ public class OperatorUtils {
             resultMap.put(clazz, op);
           }
         }
-        if (op.getChildOperators() != null) {
-          allChildren.addAll(op.getChildOperators());
-        }
+        allChildren.addAll(op.getChildOperators());
       }
       ops = allChildren;
     }

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OrcFileMergeOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OrcFileMergeOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OrcFileMergeOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/OrcFileMergeOperator.java Sat Mar 28 14:03:43 2015
@@ -56,7 +56,7 @@ public class OrcFileMergeOperator extend
   private FSDataInputStream fdis;
 
   @Override
-  public void processOp(Object row, int tag) throws HiveException {
+  public void process(Object row, int tag) throws HiveException {
     Object[] keyValue = (Object[]) row;
     processKeyValuePairs(keyValue[0], keyValue[1]);
   }

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java Sat Mar 28 14:03:43 2015
@@ -19,12 +19,13 @@
 package org.apache.hadoop.hive.ql.exec;
 
 import java.io.Serializable;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Stack;
+import java.util.concurrent.Future;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.ql.exec.PTFPartition.PTFPartitionIterator;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
@@ -66,7 +67,8 @@ public class PTFOperator extends Operato
    * 4. Create input partition to store rows coming from previous operator
    */
   @Override
-  protected void initializeOp(Configuration jobConf) throws HiveException {
+  protected Collection<Future<?>> initializeOp(Configuration jobConf) throws HiveException {
+    Collection<Future<?>> result = super.initializeOp(jobConf);
     hiveConf = jobConf;
     isMapOperator = conf.isMapSide();
 
@@ -84,8 +86,7 @@ public class PTFOperator extends Operato
     ptfInvocation = setupChain();
     ptfInvocation.initializeStreaming(jobConf, isMapOperator);
     firstMapRow = true;
-
-    super.initializeOp(jobConf);
+    return result;
   }
 
   @Override
@@ -96,7 +97,7 @@ public class PTFOperator extends Operato
   }
 
   @Override
-  public void processOp(Object row, int tag) throws HiveException {
+  public void process(Object row, int tag) throws HiveException {
     if (!isMapOperator ) {
       /*
        * checkif current row belongs to the current accumulated Partition:

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/RCFileMergeOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/RCFileMergeOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/RCFileMergeOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/RCFileMergeOperator.java Sat Mar 28 14:03:43 2015
@@ -43,7 +43,7 @@ public class RCFileMergeOperator
   int columnNumber = 0;
 
   @Override
-  public void processOp(Object row, int tag) throws HiveException {
+  public void process(Object row, int tag) throws HiveException {
     Object[] keyValue = (Object[]) row;
     processKeyValuePairs(keyValue[0], keyValue[1]);
   }

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ReduceSinkOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ReduceSinkOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ReduceSinkOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ReduceSinkOperator.java Sat Mar 28 14:03:43 2015
@@ -18,12 +18,16 @@
 
 package org.apache.hadoop.hive.ql.exec;
 
+import static org.apache.hadoop.hive.ql.plan.ReduceSinkDesc.ReducerTraits.UNIFORM;
+
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 import java.util.Random;
+import java.util.concurrent.Future;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -48,14 +52,12 @@ import org.apache.hadoop.hive.serde2.obj
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.IntObjectInspector;
 import org.apache.hadoop.io.BinaryComparable;
 import org.apache.hadoop.io.BytesWritable;
-import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.mapred.OutputCollector;
 import org.apache.hadoop.util.hash.MurmurHash;
 
-import static org.apache.hadoop.hive.ql.plan.ReduceSinkDesc.ReducerTraits.UNIFORM;
-
 /**
  * Reduce Sink Operator sends output to the reduce stage.
  **/
@@ -150,13 +152,17 @@ public class ReduceSinkOperator extends
 
   protected transient long numRows = 0;
   protected transient long cntr = 1;
+  protected transient long logEveryNRows = 0;
   private final transient LongWritable recordCounter = new LongWritable();
 
   @Override
-  protected void initializeOp(Configuration hconf) throws HiveException {
+  protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+    Collection<Future<?>> result = super.initializeOp(hconf);
     try {
 
       numRows = 0;
+      cntr = 1;
+      logEveryNRows = HiveConf.getLongVar(hconf, HiveConf.ConfVars.HIVE_LOG_N_RECORDS);
 
       String context = hconf.get(Operator.CONTEXT_NAME_KEY, "");
       if (context != null && !context.isEmpty()) {
@@ -237,12 +243,12 @@ public class ReduceSinkOperator extends
       useUniformHash = conf.getReducerTraits().contains(UNIFORM);
 
       firstRow = true;
-      initializeChildren(hconf);
     } catch (Exception e) {
       String msg = "Error initializing ReduceSinkOperator: " + e.getMessage();
       LOG.error(msg, e);
       throw new RuntimeException(e);
     }
+    return result;
   }
 
 
@@ -291,7 +297,7 @@ public class ReduceSinkOperator extends
 
   @Override
   @SuppressWarnings("unchecked")
-  public void processOp(Object row, int tag) throws HiveException {
+  public void process(Object row, int tag) throws HiveException {
     try {
       ObjectInspector rowInspector = inputObjInspectors[tag];
       if (firstRow) {
@@ -514,6 +520,7 @@ public class ReduceSinkOperator extends
     return keyWritable;
   }
 
+  @Override
   public void collect(byte[] key, byte[] value, int hash) throws IOException {
     HiveKey keyWritable = new HiveKey(key, hash);
     BytesWritable valueWritable = new BytesWritable(value);
@@ -527,7 +534,11 @@ public class ReduceSinkOperator extends
       numRows++;
       if (isLogInfoEnabled) {
         if (numRows == cntr) {
-          cntr *= 10;
+          cntr = logEveryNRows == 0 ? cntr * 10 : numRows + logEveryNRows;
+          if (cntr < 0 || numRows < 0) {
+            cntr = 0;
+            numRows = 1;
+          }
           LOG.info(toString() + ": records written - " + numRows);
         }
       }
@@ -608,6 +619,7 @@ public class ReduceSinkOperator extends
     return inputAliases;
   }
 
+  @Override
   public void setOutputCollector(OutputCollector _out) {
     this.out = _out;
   }

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SMBMapJoinOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SMBMapJoinOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SMBMapJoinOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SMBMapJoinOperator.java Sat Mar 28 14:03:43 2015
@@ -21,10 +21,12 @@ import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Future;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -91,7 +93,7 @@ public class SMBMapJoinOperator extends
   }
 
   @Override
-  protected void initializeOp(Configuration hconf) throws HiveException {
+  protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
 
     // If there is a sort-merge join followed by a regular join, the SMBJoinOperator may not
     // get initialized at all. Consider the following query:
@@ -99,7 +101,7 @@ public class SMBMapJoinOperator extends
     // For the mapper processing C, The SMJ is not initialized, no need to close it either.
     initDone = true;
 
-    super.initializeOp(hconf);
+    Collection<Future<?>> result = super.initializeOp(hconf);
 
     closeCalled = false;
 
@@ -154,6 +156,7 @@ public class SMBMapJoinOperator extends
       }
       foundNextKeyGroup[pos] = false;
     }
+    return result;
   }
 
   @Override
@@ -195,7 +198,7 @@ public class SMBMapJoinOperator extends
       HiveInputFormat.pushFilters(jobClone, ts);
 
 
-      ts.setExecContext(getExecContext());
+      ts.passExecContext(getExecContext());
 
       FetchOperator fetchOp = new FetchOperator(fetchWork, jobClone);
       ts.initialize(jobClone, new ObjectInspector[]{fetchOp.getOutputObjectInspector()});
@@ -231,7 +234,7 @@ public class SMBMapJoinOperator extends
   }
 
   @Override
-  public void processOp(Object row, int tag) throws HiveException {
+  public void process(Object row, int tag) throws HiveException {
 
     if (tag == posBigTable) {
       if (inputFileChanged) {
@@ -555,7 +558,7 @@ public class SMBMapJoinOperator extends
         fetchDone[tag] = true;
         return;
       }
-      forwardOp.processOp(row.o, tag);
+      forwardOp.process(row.o, tag);
       // check if any operator had a fatal error or early exit during
       // execution
       if (forwardOp.getDone()) {
@@ -803,7 +806,7 @@ public class SMBMapJoinOperator extends
 
         // Pass the row though the operator tree. It is guaranteed that not more than 1 row can
         // be produced from a input row.
-        forwardOp.processOp(nextRow.o, 0);
+        forwardOp.process(nextRow.o, 0);
         nextRow = sinkOp.getResult();
 
         // It is possible that the row got absorbed in the operator tree.

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java Sat Mar 28 14:03:43 2015
@@ -27,12 +27,14 @@ import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.hadoop.conf.Configuration;
@@ -152,7 +154,6 @@ public class ScriptOperator extends Oper
         if (bl != null && bl.length() > 0) {
           String[] bls = bl.split(",");
           for (String b : bls) {
-            b.replaceAll(".", "_");
             blackListedConfEntries.add(b);
           }
         }
@@ -260,7 +261,8 @@ public class ScriptOperator extends Oper
   }
 
   @Override
-  protected void initializeOp(Configuration hconf) throws HiveException {
+  protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+    Collection<Future<?>> result = super.initializeOp(hconf);
     firstRow = true;
 
     statsMap.put(Counter.DESERIALIZE_ERRORS.toString(), deserialize_error_count);
@@ -281,11 +283,10 @@ public class ScriptOperator extends Oper
 
       outputObjInspector = scriptOutputDeserializer.getObjectInspector();
 
-      // initialize all children before starting the script
-      initializeChildren(hconf);
     } catch (Exception e) {
       throw new HiveException(ErrorMsg.SCRIPT_INIT_ERROR.getErrorCodedMsg(), e);
     }
+    return result;
   }
 
   boolean isBrokenPipeException(IOException e) {
@@ -322,7 +323,7 @@ public class ScriptOperator extends Oper
   }
 
   @Override
-  public void processOp(Object row, int tag) throws HiveException {
+  public void process(Object row, int tag) throws HiveException {
     // initialize the user's process only when you receive the first row
     if (firstRow) {
       firstRow = false;
@@ -574,6 +575,7 @@ public class ScriptOperator extends Oper
       this.rowInspector = rowInspector;
     }
 
+    @Override
     public void processLine(Writable line) throws HiveException {
       try {
         row = scriptOutputDeserializer.deserialize(line);
@@ -584,6 +586,7 @@ public class ScriptOperator extends Oper
       forward(row, rowInspector);
     }
 
+    @Override
     public void close() {
     }
   }
@@ -652,6 +655,7 @@ public class ScriptOperator extends Oper
       }
     }
 
+    @Override
     public void processLine(Writable line) throws HiveException {
 
       String stringLine = line.toString();
@@ -694,6 +698,7 @@ public class ScriptOperator extends Oper
       bytesCopied += len;
     }
 
+    @Override
     public void close() {
     }
 

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SelectOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SelectOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SelectOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SelectOperator.java Sat Mar 28 14:03:43 2015
@@ -19,7 +19,9 @@
 package org.apache.hadoop.hive.ql.exec;
 
 import java.io.Serializable;
+import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.Future;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -42,12 +44,12 @@ public class SelectOperator extends Oper
   private transient boolean isSelectStarNoCompute = false;
 
   @Override
-  protected void initializeOp(Configuration hconf) throws HiveException {
+  protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+    Collection<Future<?>> result = super.initializeOp(hconf);
     // Just forward the row as is
     if (conf.isSelStarNoCompute()) {
-      initializeChildren(hconf);
       isSelectStarNoCompute = true;
-      return;
+      return result;
     }
     List<ExprNodeDesc> colList = conf.getColList();
     eval = new ExprNodeEvaluator[colList.size()];
@@ -64,11 +66,11 @@ public class SelectOperator extends Oper
     }
     outputObjInspector = initEvaluatorsAndReturnStruct(eval, conf.getOutputColumnNames(),
         inputObjInspectors[0]);
-    initializeChildren(hconf);
+    return result;
   }
 
   @Override
-  public void processOp(Object row, int tag) throws HiveException {
+  public void process(Object row, int tag) throws HiveException {
     if (isSelectStarNoCompute) {
       forward(row, inputObjInspectors[tag]);
       return;

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SparkHashTableSinkOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SparkHashTableSinkOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SparkHashTableSinkOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/SparkHashTableSinkOperator.java Sat Mar 28 14:03:43 2015
@@ -21,7 +21,9 @@ import java.io.BufferedOutputStream;
 import java.io.ObjectOutputStream;
 import java.io.OutputStream;
 import java.io.Serializable;
+import java.util.Collection;
 import java.util.Set;
+import java.util.concurrent.Future;
 
 import org.apache.commons.io.FileExistsException;
 import org.apache.commons.logging.Log;
@@ -49,7 +51,7 @@ public class SparkHashTableSinkOperator
   private final PerfLogger perfLogger = PerfLogger.getPerfLogger();
   protected static final Log LOG = LogFactory.getLog(SparkHashTableSinkOperator.class.getName());
 
-  private HashTableSinkOperator htsOperator;
+  private final HashTableSinkOperator htsOperator;
 
   // The position of this table
   private byte tag;
@@ -59,18 +61,20 @@ public class SparkHashTableSinkOperator
   }
 
   @Override
-  protected void initializeOp(Configuration hconf) throws HiveException {
+  protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+    Collection<Future<?>> result = super.initializeOp(hconf);
     ObjectInspector[] inputOIs = new ObjectInspector[conf.getTagLength()];
     inputOIs[tag] = inputObjInspectors[0];
     conf.setTagOrder(new Byte[]{ tag });
     htsOperator.setConf(conf);
     htsOperator.initialize(hconf, inputOIs);
+    return result;
   }
 
   @Override
-  public void processOp(Object row, int tag) throws HiveException {
+  public void process(Object row, int tag) throws HiveException {
     // Ignore the tag passed in, which should be 0, not what we want
-    htsOperator.processOp(row, this.tag);
+    htsOperator.process(row, this.tag);
   }
 
   @Override

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/TableScanOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/TableScanOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/TableScanOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/TableScanOperator.java Sat Mar 28 14:03:43 2015
@@ -20,9 +20,11 @@ package org.apache.hadoop.hive.ql.exec;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Future;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
@@ -84,7 +86,7 @@ public class TableScanOperator extends O
    * operator will be enhanced to read the table.
    **/
   @Override
-  public void processOp(Object row, int tag) throws HiveException {
+  public void process(Object row, int tag) throws HiveException {
     if (rowLimit >= 0 && currCount++ >= rowLimit) {
       setDone(true);
       return;
@@ -153,9 +155,9 @@ public class TableScanOperator extends O
           values.add(o == null ? defaultPartitionName : o.toString());
         }
         partitionSpecs = FileUtils.makePartName(conf.getPartColumns(), values);
-	if (isLogInfoEnabled) {
-	  LOG.info("Stats Gathering found a new partition spec = " + partitionSpecs);
-	}
+        if (isLogInfoEnabled) {
+          LOG.info("Stats Gathering found a new partition spec = " + partitionSpecs);
+        }
       }
       // find which column contains the raw data size (both partitioned and non partitioned
       int uSizeColumn = -1;
@@ -191,16 +193,17 @@ public class TableScanOperator extends O
   }
 
   @Override
-  protected void initializeOp(Configuration hconf) throws HiveException {
-    initializeChildren(hconf);
+  protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+    Collection<Future<?>> result = super.initializeOp(hconf);
     inputFileChanged = false;
 
     if (conf == null) {
-      return;
+      return result;
     }
+
     rowLimit = conf.getRowLimit();
     if (!conf.isGatherStats()) {
-      return;
+      return result;
     }
 
     this.hconf = hconf;
@@ -216,9 +219,9 @@ public class TableScanOperator extends O
     stats = new HashMap<String, Stat>();
     if (conf.getPartColumns() == null || conf.getPartColumns().size() == 0) {
       // NON PARTITIONED table
-      return;
+      return result;
     }
-
+    return result;
   }
 
   @Override
@@ -282,7 +285,7 @@ public class TableScanOperator extends O
     if (!statsPublisher.connect(jc)) {
       // just return, stats gathering should not block the main query.
       if (isLogInfoEnabled) {
-	LOG.info("StatsPublishing error: cannot connect to database.");
+        LOG.info("StatsPublishing error: cannot connect to database.");
       }
       if (isStatsReliable) {
         throw new HiveException(ErrorMsg.STATSPUBLISHER_CONNECTION_ERROR.getErrorCodedMsg());

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/TezDummyStoreOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/TezDummyStoreOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/TezDummyStoreOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/TezDummyStoreOperator.java Sat Mar 28 14:03:43 2015
@@ -33,8 +33,8 @@ public class TezDummyStoreOperator exten
    * the records.
    */
   @Override
-  public void processOp(Object row, int tag) throws HiveException {
-    super.processOp(row, tag);
+  public void process(Object row, int tag) throws HiveException {
+    super.process(row, tag);
     forward(result.o, outputObjInspector);
   }
 }

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/UDTFOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/UDTFOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/UDTFOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/UDTFOperator.java Sat Mar 28 14:03:43 2015
@@ -20,7 +20,9 @@ package org.apache.hadoop.hive.ql.exec;
 
 import java.io.Serializable;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.logging.Log;
@@ -57,7 +59,8 @@ public class UDTFOperator extends Operat
   transient AutoProgressor autoProgressor;
 
   @Override
-  protected void initializeOp(Configuration hconf) throws HiveException {
+  protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+    Collection<Future<?>> result = super.initializeOp(hconf);
     genericUDTF = conf.getGenericUDTF();
     collector = new UDTFCollector(this);
 
@@ -90,13 +93,11 @@ public class UDTFOperator extends Operat
               hconf, HiveConf.ConfVars.HIVES_AUTO_PROGRESS_TIMEOUT, TimeUnit.MILLISECONDS));
       autoProgressor.go();
     }
-
-    // Initialize the rest of the operator DAG
-    super.initializeOp(hconf);
+    return result;
   }
 
   @Override
-  public void processOp(Object row, int tag) throws HiveException {
+  public void process(Object row, int tag) throws HiveException {
     // The UDTF expects arguments in an object[]
     StructObjectInspector soi = (StructObjectInspector) inputObjInspectors[tag];
     List<? extends StructField> fields = soi.getAllStructFieldRefs();

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/UnionOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/UnionOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/UnionOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/UnionOperator.java Sat Mar 28 14:03:43 2015
@@ -20,7 +20,9 @@ package org.apache.hadoop.hive.ql.exec;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.Future;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -54,7 +56,8 @@ public class UnionOperator extends Opera
    * needsTransform[].
    */
   @Override
-  protected void initializeOp(Configuration hconf) throws HiveException {
+  protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+    Collection<Future<?>> result = super.initializeOp(hconf);
 
     int parents = parentOperators.size();
     parentObjInspectors = new StructObjectInspector[parents];
@@ -116,11 +119,11 @@ public class UnionOperator extends Opera
             + "] from " + inputObjInspectors[p] + " to " + outputObjInspector);
       }
     }
-    initializeChildren(hconf);
+    return result;
   }
 
   @Override
-  public synchronized void processOp(Object row, int tag) throws HiveException {
+  public synchronized void process(Object row, int tag) throws HiveException {
 
     StructObjectInspector soi = parentObjInspectors[tag];
     List<? extends StructField> fields = parentFields[tag];

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecMapper.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecMapper.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecMapper.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecMapper.java Sat Mar 28 14:03:43 2015
@@ -24,9 +24,9 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.hadoop.conf.Configuration;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.ql.exec.MapOperator;
 import org.apache.hadoop.hive.ql.exec.MapredContext;
@@ -105,6 +105,7 @@ public class ExecMapper extends MapReduc
       }
       mo.setConf(mrwork);
       // initialize map operator
+      mo.initialize(job, null);
       mo.setChildren(job);
       l4j.info(mo.dump(0));
       // initialize map local work
@@ -113,9 +114,9 @@ public class ExecMapper extends MapReduc
 
       MapredContext.init(true, new JobConf(jc));
 
-      mo.setExecContext(execContext);
+      mo.passExecContext(execContext);
       mo.initializeLocalWork(jc);
-      mo.initialize(jc, null);
+      mo.initializeMapOperator(jc);
 
       if (localWork == null) {
         return;
@@ -126,7 +127,7 @@ public class ExecMapper extends MapReduc
       l4j.info("Initializing dummy operator");
       List<Operator<? extends OperatorDesc>> dummyOps = localWork.getDummyParentOp();
       for (Operator<? extends OperatorDesc> dummyOp : dummyOps){
-        dummyOp.setExecContext(execContext);
+        dummyOp.passExecContext(execContext);
         dummyOp.initialize(jc,null);
       }
     } catch (Throwable e) {

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecReducer.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecReducer.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecReducer.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecReducer.java Sat Mar 28 14:03:43 2015
@@ -232,7 +232,7 @@ public class ExecReducer extends MapRedu
         row.add(valueObject[tag]);
 
         try {
-          reducer.processOp(row, tag);
+          reducer.process(row, tag);
         } catch (Exception e) {
           String rowString = null;
           try {

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HashTableLoader.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HashTableLoader.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HashTableLoader.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HashTableLoader.java Sat Mar 28 14:03:43 2015
@@ -32,11 +32,10 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.ql.exec.HashTableSinkOperator;
 import org.apache.hadoop.hive.ql.exec.MapJoinOperator;
+import org.apache.hadoop.hive.ql.exec.MapredContext;
 import org.apache.hadoop.hive.ql.exec.Operator;
 import org.apache.hadoop.hive.ql.exec.TemporaryHashSinkOperator;
 import org.apache.hadoop.hive.ql.exec.Utilities;
-import org.apache.hadoop.hive.ql.exec.persistence.MapJoinKey;
-import org.apache.hadoop.hive.ql.exec.persistence.MapJoinKeyObject;
 import org.apache.hadoop.hive.ql.exec.persistence.MapJoinTableContainer;
 import org.apache.hadoop.hive.ql.exec.persistence.MapJoinTableContainerSerDe;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -62,7 +61,8 @@ public class HashTableLoader implements
   private MapJoinDesc desc;
 
   @Override
-  public void init(ExecMapperContext context, Configuration hconf, MapJoinOperator joinOp) {
+  public void init(ExecMapperContext context, MapredContext mrContext, Configuration hconf,
+      MapJoinOperator joinOp) {
     this.context = context;
     this.hconf = hconf;
     this.joinOp = joinOp;

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/MapredLocalTask.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/MapredLocalTask.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/MapredLocalTask.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/MapredLocalTask.java Sat Mar 28 14:03:43 2015
@@ -404,7 +404,7 @@ public class MapredLocalTask extends Tas
         if (row == null) {
           break;
         }
-        forwardOp.processOp(row.o, 0);
+        forwardOp.process(row.o, 0);
       }
       forwardOp.flush();
     }
@@ -445,7 +445,7 @@ public class MapredLocalTask extends Tas
       Operator<? extends OperatorDesc> forwardOp = work.getAliasToWork().get(alias);
 
       // put the exe context into all the operators
-      forwardOp.setExecContext(execContext);
+      forwardOp.passExecContext(execContext);
       // All the operators need to be initialized before process
       FetchOperator fetchOp = entry.getValue();
       JobConf jobConf = fetchOpJobConfMap.get(fetchOp);

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ObjectCache.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ObjectCache.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ObjectCache.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ObjectCache.java Sat Mar 28 14:03:43 2015
@@ -19,6 +19,10 @@
 package org.apache.hadoop.hive.ql.exec.mr;
 
 import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -32,18 +36,59 @@ import org.apache.hadoop.hive.ql.metadat
 public class ObjectCache implements org.apache.hadoop.hive.ql.exec.ObjectCache {
 
   private static final Log LOG = LogFactory.getLog(ObjectCache.class.getName());
+  private static final boolean isInfoEnabled = LOG.isInfoEnabled();
 
   @Override
   public void release(String key) {
     // nothing to do
+    if (isInfoEnabled) {
+      LOG.info(key + " no longer needed");
+    }
   }
 
   @Override
-  public Object retrieve(String key, Callable<?> fn) throws HiveException {
+  public <T> T retrieve(String key, Callable<T> fn) throws HiveException {
     try {
+      if (isInfoEnabled) {
+        LOG.info("Creating " + key);
+      }
       return fn.call();
     } catch (Exception e) {
       throw new HiveException(e);
     }
   }
+
+  @Override
+  public <T> Future<T> retrieveAsync(String key, Callable<T> fn) throws HiveException {
+    final T value = retrieve(key, fn);
+
+    return new Future<T>() {
+
+      @Override
+      public boolean cancel(boolean mayInterruptIfRunning) {
+        return false;
+      }
+
+      @Override
+      public boolean isCancelled() {
+        return false;
+      }
+
+      @Override
+      public boolean isDone() {
+        return true;
+      }
+
+      @Override
+      public T get() throws InterruptedException, ExecutionException {
+        return value;
+      }
+
+      @Override
+      public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException,
+          TimeoutException {
+        return value;
+      }
+    };
+  }
 }

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/BytesBytesMultiHashMap.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/BytesBytesMultiHashMap.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/BytesBytesMultiHashMap.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/BytesBytesMultiHashMap.java Sat Mar 28 14:03:43 2015
@@ -124,6 +124,7 @@ public final class BytesBytesMultiHashMa
 
   private int resizeThreshold;
   private int keysAssigned;
+  private int numValues;
 
   /**
    * Largest number of probe steps ever taken to find location for a key. When getting, we can
@@ -154,7 +155,7 @@ public final class BytesBytesMultiHashMa
   private final static int DEFAULT_MAX_CAPACITY = 1024 * 1024 * 1024;
 
   public BytesBytesMultiHashMap(int initialCapacity,
-      float loadFactor, int wbSize, long memUsage, int defaultCapacity) {
+      float loadFactor, int wbSize, long memUsage) {
     if (loadFactor < 0 || loadFactor > 1) {
       throw new AssertionError("Load factor must be between (0, 1].");
     }
@@ -180,7 +181,7 @@ public final class BytesBytesMultiHashMa
 
   @VisibleForTesting
   BytesBytesMultiHashMap(int initialCapacity, float loadFactor, int wbSize) {
-    this(initialCapacity, loadFactor, wbSize, -1, 100000);
+    this(initialCapacity, loadFactor, wbSize, -1);
   }
 
   /** The source of keys and values to put into hashtable; avoids byte copying. */
@@ -204,7 +205,7 @@ public final class BytesBytesMultiHashMa
    * @param kv Keyvalue writer. Each method will be called at most once.
    */
   private static final byte[] FOUR_ZEROES = new byte[] { 0, 0, 0, 0 };
-  public void put(KvSource kv) throws SerDeException {
+  public void put(KvSource kv, int keyHashCode) throws SerDeException {
     if (resizeThreshold <= keysAssigned) {
       expandAndRehash();
     }
@@ -218,7 +219,7 @@ public final class BytesBytesMultiHashMa
 
     kv.writeKey(writeBuffers);
     int keyLength = (int)(writeBuffers.getWritePoint() - keyOffset);
-    int hashCode = writeBuffers.hashCode(keyOffset, keyLength);
+    int hashCode = (keyHashCode == -1) ? writeBuffers.hashCode(keyOffset, keyLength) : keyHashCode;
 
     int slot = findKeySlotToWrite(keyOffset, keyLength, hashCode);
     // LOG.info("Write hash code is " + Integer.toBinaryString(hashCode) + " - " + slot);
@@ -243,6 +244,7 @@ public final class BytesBytesMultiHashMa
       }
       refs[slot] = Ref.setListFlag(ref);
     }
+    ++numValues;
   }
 
   /**
@@ -301,10 +303,33 @@ public final class BytesBytesMultiHashMa
     writeBuffers.populateValue(valueRef);
   }
 
+  /**
+   * Number of keys in the hashmap
+   * @return number of keys
+   */
   public int size() {
     return keysAssigned;
   }
 
+  /**
+   * Number of values in the hashmap
+   * This is equal to or bigger than number of keys, since some values may share the same key
+   * @return number of values
+   */
+  public int getNumValues() {
+    return numValues;
+  }
+
+  /**
+   * Number of bytes used by the hashmap
+   * There are two main components that take most memory: writeBuffers and refs
+   * Others include instance fields: 100
+   * @return number of bytes
+   */
+  public long memorySize() {
+    return writeBuffers.size() + refs.length * 8 + 100;
+  }
+
   public void seal() {
     writeBuffers.seal();
   }

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HashMapWrapper.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HashMapWrapper.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HashMapWrapper.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HashMapWrapper.java Sat Mar 28 14:03:43 2015
@@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator;
+import org.apache.hadoop.hive.ql.exec.JoinUtil;
 import org.apache.hadoop.hive.ql.exec.vector.VectorHashKeyWrapper;
 import org.apache.hadoop.hive.ql.exec.vector.VectorHashKeyWrapperBatch;
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpressionWriter;
@@ -153,8 +154,9 @@ public class HashMapWrapper extends Abst
     }
 
     @Override
-    public void setFromVector(VectorHashKeyWrapper kw, VectorExpressionWriter[] keyOutputWriters,
-        VectorHashKeyWrapperBatch keyWrapperBatch) throws HiveException {
+    public JoinUtil.JoinResult setFromVector(VectorHashKeyWrapper kw,
+        VectorExpressionWriter[] keyOutputWriters, VectorHashKeyWrapperBatch keyWrapperBatch)
+        throws HiveException {
       if (currentKey == null) {
         currentKey = new Object[keyOutputWriters.length];
         vectorKeyOIs = new ArrayList<ObjectInspector>();
@@ -168,10 +170,16 @@ public class HashMapWrapper extends Abst
       key =  MapJoinKey.readFromVector(output, key, currentKey, vectorKeyOIs, !isFirstKey);
       isFirstKey = false;
       this.currentValue = mHash.get(key);
+      if (this.currentValue == null) {
+        return JoinUtil.JoinResult.NOMATCH;
+      }
+      else {
+        return JoinUtil.JoinResult.MATCH;
+      }
     }
 
     @Override
-    public void setFromRow(Object row, List<ExprNodeEvaluator> fields,
+    public JoinUtil.JoinResult setFromRow(Object row, List<ExprNodeEvaluator> fields,
         List<ObjectInspector> ois) throws HiveException {
       if (currentKey == null) {
         currentKey = new Object[fields.size()];
@@ -182,15 +190,27 @@ public class HashMapWrapper extends Abst
       key = MapJoinKey.readFromRow(output, key, currentKey, ois, !isFirstKey);
       isFirstKey = false;
       this.currentValue = mHash.get(key);
+      if (this.currentValue == null) {
+        return JoinUtil.JoinResult.NOMATCH;
+      }
+      else {
+        return JoinUtil.JoinResult.MATCH;
+      }
     }
 
     @Override
-    public void setFromOther(ReusableGetAdaptor other) {
+    public JoinUtil.JoinResult setFromOther(ReusableGetAdaptor other) {
       assert other instanceof GetAdaptor;
       GetAdaptor other2 = (GetAdaptor)other;
       this.key = other2.key;
       this.isFirstKey = other2.isFirstKey;
       this.currentValue = mHash.get(key);
+      if (this.currentValue == null) {
+        return JoinUtil.JoinResult.NOMATCH;
+      }
+      else {
+        return JoinUtil.JoinResult.MATCH;
+      }
     }
 
     @Override
@@ -223,4 +243,9 @@ public class HashMapWrapper extends Abst
   public void dumpMetrics() {
     // Nothing to do.
   }
+
+  @Override
+  public boolean hasSpill() {
+    return false;
+  }
 }

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinBytesTableContainer.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinBytesTableContainer.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinBytesTableContainer.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinBytesTableContainer.java Sat Mar 28 14:03:43 2015
@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator;
+import org.apache.hadoop.hive.ql.exec.JoinUtil;
 import org.apache.hadoop.hive.ql.exec.vector.VectorHashKeyWrapper;
 import org.apache.hadoop.hive.ql.exec.vector.VectorHashKeyWrapperBatch;
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpressionWriter;
@@ -91,7 +92,11 @@ public class MapJoinBytesTableContainer
           throws SerDeException {
     int newThreshold = HashMapWrapper.calculateTableSize(
         keyCountAdj, threshold, loadFactor, keyCount);
-    hashMap = new BytesBytesMultiHashMap(newThreshold, loadFactor, wbSize, memUsage, threshold);
+    hashMap = new BytesBytesMultiHashMap(newThreshold, loadFactor, wbSize, memUsage);
+  }
+
+  public MapJoinBytesTableContainer(BytesBytesMultiHashMap hashMap) {
+    this.hashMap = hashMap;
   }
 
   private LazyBinaryStructObjectInspector createInternalOi(
@@ -114,8 +119,18 @@ public class MapJoinBytesTableContainer
         .getLazyBinaryStructObjectInspector(colNames, colOis);
   }
 
-  private static interface KeyValueHelper extends BytesBytesMultiHashMap.KvSource {
+  public void setInternalValueOi(LazyBinaryStructObjectInspector internalValueOi) {
+    this.internalValueOi = internalValueOi;
+  }
+
+  public void setSortableSortOrders(boolean[] sortableSortOrders) {
+    this.sortableSortOrders = sortableSortOrders;
+  }
+
+  public static interface KeyValueHelper extends BytesBytesMultiHashMap.KvSource {
     void setKeyValue(Writable key, Writable val) throws SerDeException;
+    /** Get hash value from the key. */
+    int getHashFromKey() throws SerDeException;
   }
 
   private static class KeyValueWriter implements KeyValueHelper {
@@ -176,9 +191,14 @@ public class MapJoinBytesTableContainer
       aliasFilter &= ((ShortWritable)valObjs[valObjs.length - 1]).get();
       return aliasFilter;
     }
+
+    @Override
+    public int getHashFromKey() throws SerDeException {
+      throw new UnsupportedOperationException("Not supported for MapJoinBytesTableContainer");
+    }
   }
 
-  private static class LazyBinaryKvWriter implements KeyValueHelper {
+  static class LazyBinaryKvWriter implements KeyValueHelper {
     private final LazyBinaryStruct.SingleFieldGetter filterGetter;
     private Writable key, value;
     private final SerDe keySerDe;
@@ -210,6 +230,16 @@ public class MapJoinBytesTableContainer
       dest.write(b.getBytes(), 0, b.getLength() - (hasTag ? 1 : 0));
     }
 
+    @Override
+    public int getHashFromKey() throws SerDeException {
+      if (!(key instanceof BinaryComparable)) {
+        throw new SerDeException("Unexpected type " + key.getClass().getCanonicalName());
+      }
+      sanityCheckKeyForTag();
+      BinaryComparable b = (BinaryComparable)key;
+      return WriteBuffers.murmurHash(b.getBytes(), 0, b.getLength() - (hasTag ? 1 : 0));
+    }
+
     /**
      * If we received data with tags from ReduceSinkOperators, no keys will match. This should
      * not happen, but is important enough that we want to find out and work around it if some
@@ -285,7 +315,7 @@ public class MapJoinBytesTableContainer
       }
     }
     writeHelper.setKeyValue(currentKey, currentValue);
-    hashMap.put(writeHelper);
+    hashMap.put(writeHelper, -1);
     return null; // there's no key to return
   }
 
@@ -329,9 +359,9 @@ public class MapJoinBytesTableContainer
     }
 
     @Override
-    public void setFromVector(VectorHashKeyWrapper kw,
-        VectorExpressionWriter[] keyOutputWriters,
-        VectorHashKeyWrapperBatch keyWrapperBatch) throws HiveException {
+    public JoinUtil.JoinResult setFromVector(VectorHashKeyWrapper kw,
+        VectorExpressionWriter[] keyOutputWriters, VectorHashKeyWrapperBatch keyWrapperBatch)
+        throws HiveException {
       if (nulls == null) {
         nulls = new boolean[keyOutputWriters.length];
         currentKey = new Object[keyOutputWriters.length];
@@ -346,12 +376,12 @@ public class MapJoinBytesTableContainer
         currentKey[i] = keyWrapperBatch.getWritableKeyValue(kw, i, keyOutputWriters[i]);
         nulls[i] = currentKey[i] == null;
       }
-      currentValue.setFromOutput(
+      return currentValue.setFromOutput(
           MapJoinKey.serializeRow(output, currentKey, vectorKeyOIs, sortableSortOrders));
     }
 
     @Override
-    public void setFromRow(Object row, List<ExprNodeEvaluator> fields,
+    public JoinUtil.JoinResult setFromRow(Object row, List<ExprNodeEvaluator> fields,
         List<ObjectInspector> ois) throws HiveException {
       if (nulls == null) {
         nulls = new boolean[fields.size()];
@@ -361,17 +391,17 @@ public class MapJoinBytesTableContainer
         currentKey[keyIndex] = fields.get(keyIndex).evaluate(row);
         nulls[keyIndex] = currentKey[keyIndex] == null;
       }
-      currentValue.setFromOutput(
+      return currentValue.setFromOutput(
           MapJoinKey.serializeRow(output, currentKey, ois, sortableSortOrders));
     }
 
     @Override
-    public void setFromOther(ReusableGetAdaptor other) {
+    public JoinUtil.JoinResult setFromOther(ReusableGetAdaptor other) {
       assert other instanceof GetAdaptor;
       GetAdaptor other2 = (GetAdaptor)other;
       nulls = other2.nulls;
       currentKey = other2.currentKey;
-      currentValue.setFromOutput(other2.output);
+      return currentValue.setFromOutput(other2.output);
     }
 
     @Override
@@ -422,13 +452,19 @@ public class MapJoinBytesTableContainer
       clearRows();
     }
 
-    public void setFromOutput(Output output) {
+    public JoinUtil.JoinResult setFromOutput(Output output) {
       if (refs == null) {
-        refs = new ArrayList<WriteBuffers.ByteSegmentRef>(0);
+        refs = new ArrayList<WriteBuffers.ByteSegmentRef>();
       }
       byte aliasFilter = hashMap.getValueRefs(output.getData(), output.getLength(), refs);
       this.aliasFilter = refs.isEmpty() ? (byte) 0xff : aliasFilter;
       this.dummyRow = null;
+      if (refs.isEmpty()) {
+        return JoinUtil.JoinResult.NOMATCH;
+      }
+      else {
+        return JoinUtil.JoinResult.MATCH;
+      }
     }
 
     public boolean isEmpty() {
@@ -472,12 +508,15 @@ public class MapJoinBytesTableContainer
     @Override
     public List<Object> first() throws HiveException {
       currentRow = 0;
-      return next();
+      return nextInternal();
     }
 
-
     @Override
     public List<Object> next() throws HiveException {
+      return nextInternal();
+    }
+
+    private List<Object> nextInternal() throws HiveException {
       if (dummyRow != null) {
         List<Object> result = dummyRow;
         dummyRow = null;
@@ -530,4 +569,9 @@ public class MapJoinBytesTableContainer
   public void dumpMetrics() {
     hashMap.debugDumpMetrics();
   }
+
+  @Override
+  public boolean hasSpill() {
+    return false;
+  }
 }

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinKey.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinKey.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinKey.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinKey.java Sat Mar 28 14:03:43 2015
@@ -82,6 +82,8 @@ public abstract class MapJoinKey {
     SUPPORTED_PRIMITIVES.add(PrimitiveCategory.STRING);
     SUPPORTED_PRIMITIVES.add(PrimitiveCategory.DATE);
     SUPPORTED_PRIMITIVES.add(PrimitiveCategory.TIMESTAMP);
+    SUPPORTED_PRIMITIVES.add(PrimitiveCategory.INTERVAL_YEAR_MONTH);
+    SUPPORTED_PRIMITIVES.add(PrimitiveCategory.INTERVAL_DAY_TIME);
     SUPPORTED_PRIMITIVES.add(PrimitiveCategory.BINARY);
     SUPPORTED_PRIMITIVES.add(PrimitiveCategory.VARCHAR);
     SUPPORTED_PRIMITIVES.add(PrimitiveCategory.CHAR);

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinTableContainer.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinTableContainer.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinTableContainer.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinTableContainer.java Sat Mar 28 14:03:43 2015
@@ -18,9 +18,11 @@
 
 package org.apache.hadoop.hive.ql.exec.persistence;
 
+import java.io.IOException;
 import java.util.List;
 
 import org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator;
+import org.apache.hadoop.hive.ql.exec.JoinUtil;
 import org.apache.hadoop.hive.ql.exec.vector.VectorHashKeyWrapper;
 import org.apache.hadoop.hive.ql.exec.vector.VectorHashKeyWrapperBatch;
 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpressionWriter;
@@ -40,21 +42,21 @@ public interface MapJoinTableContainer {
      * Changes current rows to which adaptor is referring to the rows corresponding to
      * the key represented by a VHKW object, and writers and batch used to interpret it.
      */
-    void setFromVector(VectorHashKeyWrapper kw, VectorExpressionWriter[] keyOutputWriters,
+    JoinUtil.JoinResult setFromVector(VectorHashKeyWrapper kw, VectorExpressionWriter[] keyOutputWriters,
         VectorHashKeyWrapperBatch keyWrapperBatch) throws HiveException;
 
     /**
      * Changes current rows to which adaptor is referring to the rows corresponding to
      * the key represented by a row object, and fields and ois used to interpret it.
      */
-    void setFromRow(Object row, List<ExprNodeEvaluator> fields, List<ObjectInspector> ois)
+    JoinUtil.JoinResult setFromRow(Object row, List<ExprNodeEvaluator> fields, List<ObjectInspector> ois)
         throws HiveException;
 
     /**
      * Changes current rows to which adaptor is referring to the rows corresponding to
      * the key that another adaptor has already deserialized via setFromVector/setFromRow.
      */
-    void setFromOther(ReusableGetAdaptor other);
+    JoinUtil.JoinResult setFromOther(ReusableGetAdaptor other) throws HiveException;
 
     /**
      * Checks whether the current key has any nulls.
@@ -77,7 +79,7 @@ public interface MapJoinTableContainer {
    */
   MapJoinKey putRow(MapJoinObjectSerDeContext keyContext, Writable currentKey,
       MapJoinObjectSerDeContext valueContext, Writable currentValue)
-          throws SerDeException, HiveException;
+      throws SerDeException, HiveException, IOException;
 
   /**
    * Indicates to the container that the puts have ended; table is now r/o.
@@ -98,4 +100,10 @@ public interface MapJoinTableContainer {
   MapJoinKey getAnyKey();
 
   void dumpMetrics();
+
+  /**
+   * Checks if the container has spilled any data onto disk.
+   * This is only applicable for HybridHashTableContainer.
+   */
+  boolean hasSpill();
 }

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/HashTableLoader.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/HashTableLoader.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/HashTableLoader.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/HashTableLoader.java Sat Mar 28 14:03:43 2015
@@ -29,6 +29,7 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.ql.exec.HashTableSinkOperator;
 import org.apache.hadoop.hive.ql.exec.MapJoinOperator;
+import org.apache.hadoop.hive.ql.exec.MapredContext;
 import org.apache.hadoop.hive.ql.exec.Operator;
 import org.apache.hadoop.hive.ql.exec.TemporaryHashSinkOperator;
 import org.apache.hadoop.hive.ql.exec.Utilities;
@@ -58,7 +59,8 @@ public class HashTableLoader implements
   private MapJoinDesc desc;
 
   @Override
-  public void init(ExecMapperContext context, Configuration hconf, MapJoinOperator joinOp) {
+  public void init(ExecMapperContext context, MapredContext mrContext, Configuration hconf,
+      MapJoinOperator joinOp) {
     this.context = context;
     this.hconf = hconf;
     this.joinOp = joinOp;
@@ -66,9 +68,9 @@ public class HashTableLoader implements
   }
 
   @Override
-  public void load(
-      MapJoinTableContainer[] mapJoinTables,
-      MapJoinTableContainerSerDe[] mapJoinTableSerdes, long memUsage) throws HiveException {
+  public void load(MapJoinTableContainer[] mapJoinTables,
+      MapJoinTableContainerSerDe[] mapJoinTableSerdes, long memUsage)
+      throws HiveException {
 
     // Note: it's possible that a MJ operator is in a ReduceWork, in which case the
     // currentInputPath will be null. But, since currentInputPath is only interesting

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkMapRecordHandler.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkMapRecordHandler.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkMapRecordHandler.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkMapRecordHandler.java Sat Mar 28 14:03:43 2015
@@ -18,6 +18,10 @@
 
 package org.apache.hadoop.hive.ql.exec.spark;
 
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.ql.exec.MapOperator;
@@ -29,7 +33,6 @@ import org.apache.hadoop.hive.ql.exec.mr
 import org.apache.hadoop.hive.ql.exec.mr.ExecMapperContext;
 import org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator;
 import org.apache.hadoop.hive.ql.log.PerfLogger;
-import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.plan.MapWork;
 import org.apache.hadoop.hive.ql.plan.MapredLocalWork;
 import org.apache.hadoop.hive.ql.plan.OperatorDesc;
@@ -38,10 +41,6 @@ import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.OutputCollector;
 import org.apache.hadoop.mapred.Reporter;
 
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
 
 /**
  * Clone from ExecMapper. SparkMapRecordHandler is the bridge between the spark framework and
@@ -61,6 +60,7 @@ public class SparkMapRecordHandler exten
   private boolean isLogInfoEnabled = false;
   private ExecMapperContext execContext;
 
+  @Override
   public <K, V> void init(JobConf job, OutputCollector<K, V> output, Reporter reporter) throws Exception {
     perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.SPARK_INIT_OPERATORS);
     super.init(job, output, reporter);
@@ -81,6 +81,7 @@ public class SparkMapRecordHandler exten
       mo.setConf(mrwork);
 
       // initialize map operator
+      mo.initialize(jc, null);
       mo.setChildren(job);
       LOG.info(mo.dump(0));
       // initialize map local work
@@ -90,9 +91,9 @@ public class SparkMapRecordHandler exten
       MapredContext.init(true, new JobConf(jc));
       MapredContext.get().setReporter(reporter);
 
-      mo.setExecContext(execContext);
+      mo.passExecContext(execContext);
       mo.initializeLocalWork(jc);
-      mo.initialize(jc, null);
+      mo.initializeMapOperator(jc);
 
       OperatorUtils.setChildrenCollector(mo.getChildOperators(), output);
       mo.setReporter(rp);

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkMergeFileRecordHandler.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkMergeFileRecordHandler.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkMergeFileRecordHandler.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkMergeFileRecordHandler.java Sat Mar 28 14:03:43 2015
@@ -93,7 +93,7 @@ public class SparkMergeFileRecordHandler
     row[0] = key;
     row[1] = value;
     try {
-      mergeOp.processOp(row, 0);
+      mergeOp.process(row, 0);
     } catch (HiveException e) {
       abort = true;
       throw new IOException(e);

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkReduceRecordHandler.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkReduceRecordHandler.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkReduceRecordHandler.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkReduceRecordHandler.java Sat Mar 28 14:03:43 2015
@@ -103,6 +103,7 @@ public class SparkReduceRecordHandler ex
   private List<VectorExpressionWriter>[] valueStringWriters;
   private MapredLocalWork localWork = null;
 
+  @Override
   @SuppressWarnings("unchecked")
   public void init(JobConf job, OutputCollector output, Reporter reporter) throws Exception {
     perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.SPARK_INIT_OPERATORS);
@@ -132,7 +133,7 @@ public class SparkReduceRecordHandler ex
         keyStructInspector = (StructObjectInspector) keyObjectInspector;
         batches = new VectorizedRowBatch[maxTags];
         valueStructInspectors = new StructObjectInspector[maxTags];
-        valueStringWriters = (List<VectorExpressionWriter>[]) new List[maxTags];
+        valueStringWriters = new List[maxTags];
         keysColumnOffset = keyStructInspector.getAllStructFieldRefs().size();
         buffer = new DataOutputBuffer();
       }
@@ -196,7 +197,7 @@ public class SparkReduceRecordHandler ex
     localWork = gWork.getMapRedLocalWork();
     execContext.setJc(jc);
     execContext.setLocalWork(localWork);
-    reducer.setExecContext(execContext);
+    reducer.passExecContext(execContext);
 
     reducer.setReporter(rp);
     OperatorUtils.setChildrenCollector(
@@ -319,7 +320,7 @@ public class SparkReduceRecordHandler ex
         logMemoryInfo();
       }
       try {
-        reducer.processOp(row, tag);
+        reducer.process(row, tag);
       } catch (Exception e) {
         String rowString = null;
         try {
@@ -361,7 +362,7 @@ public class SparkReduceRecordHandler ex
         rowIdx++;
         if (rowIdx >= BATCH_SIZE) {
           VectorizedBatchUtil.setBatchSize(batch, rowIdx);
-          reducer.processOp(batch, tag);
+          reducer.process(batch, tag);
           rowIdx = 0;
           if (isLogInfoEnabled) {
             logMemoryInfo();
@@ -370,7 +371,7 @@ public class SparkReduceRecordHandler ex
       }
       if (rowIdx > 0) {
         VectorizedBatchUtil.setBatchSize(batch, rowIdx);
-        reducer.processOp(batch, tag);
+        reducer.process(batch, tag);
       }
       if (isLogInfoEnabled) {
         logMemoryInfo();
@@ -402,6 +403,7 @@ public class SparkReduceRecordHandler ex
     }
   }
 
+  @Override
   public void close() {
 
     // No row was processed

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkUtilities.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkUtilities.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkUtilities.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/SparkUtilities.java Sat Mar 28 14:03:43 2015
@@ -19,12 +19,10 @@ package org.apache.hadoop.hive.ql.exec.s
 
 import java.io.File;
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 
-import org.apache.hadoop.conf.Configuration;
+import org.apache.commons.io.FilenameUtils;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -97,8 +95,8 @@ public class SparkUtilities {
       return null;
     }
 
-    String[] splits = uri.getPath().split(File.separator);
-    return  splits[splits.length-1];
+    String name = FilenameUtils.getName(uri.getPath());
+    return name;
   }
 
   public static SparkSession getSparkSession(HiveConf conf,

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/status/SparkJobMonitor.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/status/SparkJobMonitor.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/status/SparkJobMonitor.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/status/SparkJobMonitor.java Sat Mar 28 14:03:43 2015
@@ -21,7 +21,6 @@ package org.apache.hadoop.hive.ql.exec.s
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.ql.exec.spark.status.impl.LocalSparkJobStatus;
 import org.apache.hadoop.hive.ql.log.PerfLogger;
 import org.apache.hadoop.hive.ql.session.SessionState;
 
@@ -77,7 +76,7 @@ abstract class SparkJobMonitor {
       final int failed = progress.getFailedTaskCount();
       String stageName = "Stage-" + s;
       if (total <= 0) {
-        reportBuffer.append(String.format("%s: -/-\t", stageName, complete, total));
+        reportBuffer.append(String.format("%s: -/-\t", stageName));
       } else {
         if (complete == total && !completed.contains(s)) {
           completed.add(s);

Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/CustomPartitionVertex.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/CustomPartitionVertex.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/CustomPartitionVertex.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/CustomPartitionVertex.java Sat Mar 28 14:03:43 2015
@@ -274,9 +274,8 @@ public class CustomPartitionVertex exten
         for (Integer key : bucketToInitialSplitMap.keySet()) {
           InputSplit[] inputSplitArray =
               (bucketToInitialSplitMap.get(key).toArray(new InputSplit[0]));
-          HiveSplitGenerator hiveSplitGenerator = new HiveSplitGenerator();
           Multimap<Integer, InputSplit> groupedSplit =
-              hiveSplitGenerator.generateGroupedSplits(jobConf, conf, inputSplitArray, waves,
+              grouper.generateGroupedSplits(jobConf, conf, inputSplitArray, waves,
                   availableSlots, inputName, mainWorkName.isEmpty());
           if (mainWorkName.isEmpty() == false) {
             Multimap<Integer, InputSplit> singleBucketToGroupedSplit =
@@ -295,11 +294,10 @@ public class CustomPartitionVertex exten
         // grouped split. This would affect SMB joins where we want to find the smallest key in
         // all the bucket files.
         for (Integer key : bucketToInitialSplitMap.keySet()) {
-          HiveSplitGenerator hiveSplitGenerator = new HiveSplitGenerator();
           InputSplit[] inputSplitArray =
               (bucketToInitialSplitMap.get(key).toArray(new InputSplit[0]));
           Multimap<Integer, InputSplit> groupedSplit =
-              hiveSplitGenerator.generateGroupedSplits(jobConf, conf, inputSplitArray, waves,
+              grouper.generateGroupedSplits(jobConf, conf, inputSplitArray, waves,
                     availableSlots, inputName, false);
             bucketToGroupedSplitMap.putAll(key, groupedSplit.values());
         }