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 [11/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/ColumnStatsUpdateTask.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java Sat Mar 28 14:03:43 2015
@@ -238,8 +238,8 @@ public class ColumnStatsUpdateTask exten
} else {
throw new SemanticException("Unsupported type");
}
-
- ColumnStatisticsDesc statsDesc = getColumnStatsDesc(dbName, tableName,
+ String [] names = Utilities.getDbTableName(dbName, tableName);
+ ColumnStatisticsDesc statsDesc = getColumnStatsDesc(names[0], names[1],
partName, partName == null);
ColumnStatistics colStat = new ColumnStatistics();
colStat.setStatsDesc(statsDesc);
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonJoinOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonJoinOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonJoinOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonJoinOperator.java Sat Mar 28 14:03:43 2015
@@ -21,9 +21,11 @@ package org.apache.hadoop.hive.ql.exec;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.Future;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -185,7 +187,8 @@ public abstract class CommonJoinOperator
@Override
@SuppressWarnings("unchecked")
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
this.handleSkewJoin = conf.getHandleSkewJoin();
this.hconf = hconf;
@@ -319,6 +322,7 @@ public abstract class CommonJoinOperator
if (isLogInfoEnabled) {
LOG.info("JOIN " + outputObjInspector.getTypeName() + " totalsz = " + totalSz);
}
+ return result;
}
transient boolean newGroupStarted = false;
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonMergeJoinOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonMergeJoinOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonMergeJoinOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonMergeJoinOperator.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.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.concurrent.Future;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -85,10 +87,10 @@ public class CommonMergeJoinOperator ext
@SuppressWarnings("unchecked")
@Override
- public void initializeOp(Configuration hconf) throws HiveException {
- super.initializeOp(hconf);
+ public Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
firstFetchHappened = false;
- initializeChildren(hconf);
+
int maxAlias = 0;
for (byte pos = 0; pos < order.length; pos++) {
if (pos > maxAlias) {
@@ -132,6 +134,7 @@ public class CommonMergeJoinOperator ext
}
sources = ((TezContext) MapredContext.get()).getRecordSources();
+ return result;
}
@Override
@@ -155,7 +158,7 @@ public class CommonMergeJoinOperator ext
* push but the rest is pulled until we run out of records.
*/
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
posBigTable = (byte) conf.getBigTablePosition();
byte alias = (byte) tag;
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java Sat Mar 28 14:03:43 2015
@@ -56,6 +56,7 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FsShell;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.common.FileUtils;
import org.apache.hadoop.hive.common.StatsSetupConst;
import org.apache.hadoop.hive.common.type.HiveDecimal;
import org.apache.hadoop.hive.conf.HiveConf;
@@ -219,7 +220,6 @@ public class DDLTask extends Task<DDLWor
private static final long serialVersionUID = 1L;
private static final Log LOG = LogFactory.getLog("hive.ql.exec.DDLTask");
- transient HiveConf conf;
private static final int separator = Utilities.tabCode;
private static final int terminator = Utilities.newLineCode;
@@ -243,7 +243,6 @@ public class DDLTask extends Task<DDLWor
@Override
public void initialize(HiveConf conf, QueryPlan queryPlan, DriverContext ctx) {
super.initialize(conf, queryPlan, ctx);
- this.conf = conf;
// Pick the formatter to use to display the results. Either the
// normal human readable output or a json object.
@@ -601,7 +600,7 @@ public class DDLTask extends Task<DDLWor
aliasToWork.put(mergeFilesDesc.getInputDir().toString(), mergeOp);
mergeWork.setAliasToWork(aliasToWork);
DriverContext driverCxt = new DriverContext();
- Task task = null;
+ Task task;
if (conf.getVar(ConfVars.HIVE_EXECUTION_ENGINE).equals("tez")) {
TezWork tezWork = new TezWork(conf.getVar(HiveConf.ConfVars.HIVEQUERYID));
mergeWork.setName("File Merge");
@@ -939,10 +938,17 @@ public class DDLTask extends Task<DDLWor
Table tbl = db.getTable(renamePartitionDesc.getTableName());
- Partition oldPart = db.getPartition(tbl, renamePartitionDesc.getOldPartSpec(), false);
- Partition part = db.getPartition(tbl, renamePartitionDesc.getOldPartSpec(), false);
+ LinkedHashMap<String, String> oldPartSpec = renamePartitionDesc.getOldPartSpec();
+ Partition oldPart = db.getPartition(tbl, oldPartSpec, false);
+ if (oldPart == null) {
+ String partName = FileUtils.makePartName(new ArrayList<String>(oldPartSpec.keySet()),
+ new ArrayList<String>(oldPartSpec.values()));
+ throw new HiveException("Rename partition: source partition [" + partName
+ + "] does not exist.");
+ }
+ Partition part = db.getPartition(tbl, oldPartSpec, false);
part.setValues(renamePartitionDesc.getNewPartSpec());
- db.renamePartition(tbl, renamePartitionDesc.getOldPartSpec(), part);
+ db.renamePartition(tbl, oldPartSpec, part);
Partition newPart = db
.getPartition(tbl, renamePartitionDesc.getNewPartSpec(), false);
work.getInputs().add(new ReadEntity(oldPart));
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DefaultUDAFEvaluatorResolver.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DefaultUDAFEvaluatorResolver.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DefaultUDAFEvaluatorResolver.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DefaultUDAFEvaluatorResolver.java Sat Mar 28 14:03:43 2015
@@ -20,7 +20,6 @@ package org.apache.hadoop.hive.ql.exec;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
@@ -92,12 +91,12 @@ public class DefaultUDAFEvaluatorResolve
if (found == -1) {
found = i;
} else {
- throw new AmbiguousMethodException(udafClass, null, null);
+ throw new AmbiguousMethodException(udafClass, argClasses, mList);
}
}
}
assert (found != -1);
-
+
return cList.get(found);
}
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DemuxOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DemuxOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DemuxOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DemuxOperator.java Sat Mar 28 14:03:43 2015
@@ -20,9 +20,12 @@ package org.apache.hadoop.hive.ql.exec;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.concurrent.Future;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -107,7 +110,8 @@ public class DemuxOperator extends Opera
private int[][] newChildOperatorsTag;
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
// A DemuxOperator should have at least one child
if (childOperatorsArray.length == 0) {
throw new HiveException(
@@ -177,9 +181,9 @@ public class DemuxOperator extends Opera
newChildOperatorsTag[i] = toArray(childOperatorTags);
}
if (isLogInfoEnabled) {
- LOG.info("newChildOperatorsTag " + newChildOperatorsTag);
+ LOG.info("newChildOperatorsTag " + Arrays.toString(newChildOperatorsTag));
}
- initializeChildren(hconf);
+ return result;
}
private int[] toArray(List<Integer> list) {
@@ -252,7 +256,7 @@ public class DemuxOperator extends Opera
}
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
int currentChildIndex = newTagToChildIndex[tag];
// Check if we start to forward rows to a new child.
@@ -276,7 +280,7 @@ public class DemuxOperator extends Opera
if (child.getDone()) {
childrenDone++;
} else {
- child.processOp(row, oldTag);
+ child.process(row, oldTag);
}
// if all children are done, this operator is also done
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DummyStoreOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DummyStoreOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DummyStoreOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/DummyStoreOperator.java Sat Mar 28 14:03:43 2015
@@ -19,6 +19,8 @@
package org.apache.hadoop.hive.ql.exec;
import java.io.Serializable;
+import java.util.Collection;
+import java.util.concurrent.Future;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -72,13 +74,14 @@ public class DummyStoreOperator extends
}
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> ret = super.initializeOp(hconf);
/*
- * The conversion to standard object inspector was necessitated by HIVE-5973. The issue
- * happens when a select operator preceeds this operator as in the case of a subquery. The
- * select operator does not allocate a new object to hold the deserialized row. This affects
+ * The conversion to standard object inspector was necessitated by HIVE-5973. The issue
+ * happens when a select operator preceeds this operator as in the case of a subquery. The
+ * select operator does not allocate a new object to hold the deserialized row. This affects
* the operation of the SMB join which puts the object in a priority queue. Since all elements
- * of the priority queue point to the same object, the join was resulting in incorrect
+ * of the priority queue point to the same object, the join was resulting in incorrect
* results.
*
* So the fix is to make a copy of the object as done in the processOp phase below. This
@@ -87,11 +90,11 @@ public class DummyStoreOperator extends
*/
outputObjInspector = ObjectInspectorUtils.getStandardObjectInspector(inputObjInspectors[0]);
result = new InspectableObject(null, outputObjInspector);
- initializeChildren(hconf);
+ return ret;
}
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
// Store the row. See comments above for why we need a new copy of the row.
result.o = ObjectInspectorUtils.copyToStandardObject(row, inputObjInspectors[0],
ObjectInspectorCopyOption.WRITABLE);
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FetchOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FetchOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FetchOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FetchOperator.java Sat Mar 28 14:03:43 2015
@@ -29,7 +29,6 @@ import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang3.StringEscapeUtils;
-import com.google.common.collect.Iterators;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configurable;
@@ -74,6 +73,8 @@ import org.apache.hadoop.util.Reflection
import org.apache.hadoop.util.StringUtils;
import org.apache.hive.common.util.AnnotationUtils;
+import com.google.common.collect.Iterators;
+
/**
* FetchTask implementation.
**/
@@ -93,7 +94,7 @@ public class FetchOperator implements Se
private final boolean isPartitioned;
private final boolean isNonNativeTable;
private StructObjectInspector vcsOI;
- private List<VirtualColumn> vcCols;
+ private final List<VirtualColumn> vcCols;
private ExecMapperContext context;
private transient Deserializer tableSerDe;
@@ -178,7 +179,7 @@ public class FetchOperator implements Se
if (hasVC || work.getSplitSample() != null) {
context = new ExecMapperContext(job);
if (operator != null) {
- operator.setExecContext(context);
+ operator.passExecContext(context);
}
}
setFetchOperatorContext(job, paths);
@@ -203,7 +204,7 @@ public class FetchOperator implements Se
JobConf conf) throws IOException {
if (Configurable.class.isAssignableFrom(inputFormatClass) ||
JobConfigurable.class.isAssignableFrom(inputFormatClass)) {
- return (InputFormat<WritableComparable, Writable>) ReflectionUtils
+ return ReflectionUtils
.newInstance(inputFormatClass, conf);
}
InputFormat format = inputFormats.get(inputFormatClass.getName());
@@ -406,7 +407,7 @@ public class FetchOperator implements Se
public boolean pushRow() throws IOException, HiveException {
if (work.getRowsComputedUsingStats() != null) {
for (List<Object> row : work.getRowsComputedUsingStats()) {
- operator.processOp(row, 0);
+ operator.process(row, 0);
}
flushRow();
return true;
@@ -421,7 +422,7 @@ public class FetchOperator implements Se
}
protected void pushRow(InspectableObject row) throws HiveException {
- operator.processOp(row.o, 0);
+ operator.process(row.o, 0);
}
protected void flushRow() throws HiveException {
@@ -656,7 +657,7 @@ public class FetchOperator implements Se
// what's different is that this is evaluated by unit of row using RecordReader.getPos()
// and that is evaluated by unit of split using InputSplit.getLength().
private long shrinkedLength = -1;
- private InputFormat inputFormat;
+ private final InputFormat inputFormat;
public FetchInputFormatSplit(InputSplit split, InputFormat inputFormat) {
super(split, inputFormat.getClass().getName());
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java Sat Mar 28 14:03:43 2015
@@ -18,16 +18,20 @@
package org.apache.hadoop.hive.ql.exec;
+import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.HIVE_TEMPORARY_TABLE_STORAGE;
+
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.Future;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -76,8 +80,6 @@ import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.util.ReflectionUtils;
-import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.HIVE_TEMPORARY_TABLE_STORAGE;
-
/**
* File Sink operator implementation.
**/
@@ -116,6 +118,7 @@ public class FileSinkOperator extends Te
private IntObjectInspector bucketInspector; // OI for inspecting bucket id
protected transient long numRows = 0;
protected transient long cntr = 1;
+ protected transient long logEveryNRows = 0;
/**
* Counters.
@@ -319,7 +322,8 @@ public class FileSinkOperator extends Te
}
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
try {
this.hconf = hconf;
filesCreated = false;
@@ -417,6 +421,8 @@ public class FileSinkOperator extends Te
}
numRows = 0;
+ cntr = 1;
+ logEveryNRows = HiveConf.getLongVar(hconf, HiveConf.ConfVars.HIVE_LOG_N_RECORDS);
String suffix = Integer.toString(conf.getDestTableId());
String fullName = conf.getTableInfo().getTableName();
@@ -425,14 +431,13 @@ public class FileSinkOperator extends Te
}
statsMap.put(Counter.RECORDS_OUT + "_" + suffix, row_count);
-
- initializeChildren(hconf);
} catch (HiveException e) {
throw e;
} catch (Exception e) {
e.printStackTrace();
throw new HiveException(e);
}
+ return result;
}
/**
@@ -630,7 +635,7 @@ public class FileSinkOperator extends Te
protected Writable recordValue;
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
/* Create list bucketing sub-directory only if stored-as-directories is on. */
String lbDirName = null;
lbDirName = (lbCtx == null) ? null : generateListBucketingDirName(row);
@@ -703,7 +708,11 @@ public class FileSinkOperator extends Te
}
if ((++numRows == cntr) && isLogInfoEnabled) {
- cntr *= 10;
+ cntr = logEveryNRows == 0 ? cntr * 10 : numRows + logEveryNRows;
+ if (cntr < 0 || numRows < 0) {
+ cntr = 0;
+ numRows = 1;
+ }
LOG.info(toString() + ": records written - " + numRows);
}
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FilterOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FilterOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FilterOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FilterOperator.java Sat Mar 28 14:03:43 2015
@@ -19,6 +19,8 @@
package org.apache.hadoop.hive.ql.exec;
import java.io.Serializable;
+import java.util.Collection;
+import java.util.concurrent.Future;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.conf.HiveConf;
@@ -28,7 +30,6 @@ import org.apache.hadoop.hive.ql.plan.Fi
import org.apache.hadoop.hive.ql.plan.api.OperatorType;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
-import org.apache.hadoop.io.LongWritable;
/**
* Filter operator implementation.
@@ -49,7 +50,8 @@ public class FilterOperator extends Oper
}
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
try {
heartbeatInterval = HiveConf.getIntVar(hconf,
HiveConf.ConfVars.HIVESENDHEARTBEAT);
@@ -63,11 +65,11 @@ public class FilterOperator extends Oper
} catch (Throwable e) {
throw new HiveException(e);
}
- initializeChildren(hconf);
+ return result;
}
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
ObjectInspector rowInspector = inputObjInspectors[tag];
if (conditionInspector == null) {
conditionInspector = (PrimitiveObjectInspector) conditionEvaluator
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ForwardOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ForwardOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ForwardOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ForwardOperator.java Sat Mar 28 14:03:43 2015
@@ -19,7 +19,10 @@
package org.apache.hadoop.hive.ql.exec;
import java.io.Serializable;
+import java.util.Collection;
+import java.util.concurrent.Future;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.plan.ForwardDesc;
import org.apache.hadoop.hive.ql.plan.api.OperatorType;
@@ -32,7 +35,7 @@ public class ForwardOperator extends Ope
private static final long serialVersionUID = 1L;
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
forward(row, inputObjInspectors[tag]);
}
@@ -57,4 +60,9 @@ public class ForwardOperator extends Ope
static public String getOperatorName() {
return "FOR";
}
+
+ @Override
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ return super.initializeOp(hconf);
+ }
}
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java Sat Mar 28 14:03:43 2015
@@ -68,8 +68,11 @@ import org.apache.hadoop.hive.ql.udf.UDF
import org.apache.hadoop.hive.ql.udf.UDFMinute;
import org.apache.hadoop.hive.ql.udf.UDFMonth;
import org.apache.hadoop.hive.ql.udf.UDFOPBitAnd;
+import org.apache.hadoop.hive.ql.udf.UDFOPBitShiftLeft;
import org.apache.hadoop.hive.ql.udf.UDFOPBitNot;
import org.apache.hadoop.hive.ql.udf.UDFOPBitOr;
+import org.apache.hadoop.hive.ql.udf.UDFOPBitShiftRight;
+import org.apache.hadoop.hive.ql.udf.UDFOPBitShiftRightUnsigned;
import org.apache.hadoop.hive.ql.udf.UDFOPBitXor;
import org.apache.hadoop.hive.ql.udf.UDFOPLongDivide;
import org.apache.hadoop.hive.ql.udf.UDFPI;
@@ -188,6 +191,7 @@ public final class FunctionRegistry {
system.registerGenericUDF("round", GenericUDFRound.class);
system.registerGenericUDF("floor", GenericUDFFloor.class);
system.registerUDF("sqrt", UDFSqrt.class, false);
+ system.registerGenericUDF("cbrt", GenericUDFCbrt.class);
system.registerGenericUDF("ceil", GenericUDFCeil.class);
system.registerGenericUDF("ceiling", GenericUDFCeil.class);
system.registerUDF("rand", UDFRand.class, false);
@@ -212,6 +216,7 @@ public final class FunctionRegistry {
system.registerUDF("atan", UDFAtan.class, false);
system.registerUDF("tan", UDFTan.class, false);
system.registerUDF("e", UDFE.class, false);
+ system.registerGenericUDF("factorial", GenericUDFFactorial.class);
system.registerUDF("conv", UDFConv.class, false);
system.registerUDF("bin", UDFBin.class, false);
@@ -292,6 +297,9 @@ public final class FunctionRegistry {
system.registerUDF("|", UDFOPBitOr.class, true);
system.registerUDF("^", UDFOPBitXor.class, true);
system.registerUDF("~", UDFOPBitNot.class, true);
+ system.registerUDF("shiftleft", UDFOPBitShiftLeft.class, true);
+ system.registerUDF("shiftright", UDFOPBitShiftRight.class, true);
+ system.registerUDF("shiftrightunsigned", UDFOPBitShiftRightUnsigned.class, true);
system.registerGenericUDF("current_database", UDFCurrentDB.class);
system.registerGenericUDF("current_date", GenericUDFCurrentDate.class);
@@ -335,6 +343,8 @@ public final class FunctionRegistry {
system.registerGenericUDF(serdeConstants.DATE_TYPE_NAME, GenericUDFToDate.class);
system.registerGenericUDF(serdeConstants.TIMESTAMP_TYPE_NAME, GenericUDFTimestamp.class);
+ system.registerGenericUDF(serdeConstants.INTERVAL_YEAR_MONTH_TYPE_NAME, GenericUDFToIntervalYearMonth.class);
+ system.registerGenericUDF(serdeConstants.INTERVAL_DAY_TIME_TYPE_NAME, GenericUDFToIntervalDayTime.class);
system.registerGenericUDF(serdeConstants.BINARY_TYPE_NAME, GenericUDFToBinary.class);
system.registerGenericUDF(serdeConstants.DECIMAL_TYPE_NAME, GenericUDFToDecimal.class);
system.registerGenericUDF(serdeConstants.VARCHAR_TYPE_NAME, GenericUDFToVarchar.class);
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionTask.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionTask.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionTask.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionTask.java Sat Mar 28 14:03:43 2015
@@ -55,8 +55,6 @@ public class FunctionTask extends Task<F
private static final long serialVersionUID = 1L;
private static transient final Log LOG = LogFactory.getLog(FunctionTask.class);
- transient HiveConf conf;
-
public FunctionTask() {
super();
}
@@ -64,7 +62,6 @@ public class FunctionTask extends Task<F
@Override
public void initialize(HiveConf conf, QueryPlan queryPlan, DriverContext ctx) {
super.initialize(conf, queryPlan, ctx);
- this.conf = conf;
}
@Override
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java Sat Mar 28 14:03:43 2015
@@ -24,12 +24,14 @@ import java.lang.reflect.Field;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.Future;
import javolution.util.FastBitSet;
@@ -178,7 +180,8 @@ public class GroupByOperator extends Ope
}
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
numRowsInput = 0;
numRowsHashTbl = 0;
@@ -390,7 +393,7 @@ public class GroupByOperator extends Ope
memoryMXBean = ManagementFactory.getMemoryMXBean();
maxMemory = memoryMXBean.getHeapMemoryUsage().getMax();
memoryThreshold = this.getConf().getMemoryThreshold();
- initializeChildren(hconf);
+ return result;
}
/**
@@ -700,7 +703,7 @@ public class GroupByOperator extends Ope
}
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
firstRow = false;
ObjectInspector rowInspector = inputObjInspectors[tag];
// Total number of input rows is needed for hash aggregation only
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableDummyOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableDummyOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableDummyOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableDummyOperator.java Sat Mar 28 14:03:43 2015
@@ -18,6 +18,8 @@
package org.apache.hadoop.hive.ql.exec;
import java.io.Serializable;
+import java.util.Collection;
+import java.util.concurrent.Future;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -31,21 +33,22 @@ public class HashTableDummyOperator exte
private static final long serialVersionUID = 1L;
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
TableDesc tbl = this.getConf().getTbl();
try {
Deserializer serde = tbl.getDeserializerClass().newInstance();
SerDeUtils.initializeSerDe(serde, hconf, tbl.getProperties(), null);
this.outputObjInspector = serde.getObjectInspector();
- initializeChildren(hconf);
} catch (Exception e) {
LOG.error("Generating output obj inspector from dummy object error", e);
e.printStackTrace();
}
+ return result;
}
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
throw new HiveException();
}
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableLoader.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableLoader.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableLoader.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableLoader.java Sat Mar 28 14:03:43 2015
@@ -19,11 +19,9 @@ package org.apache.hadoop.hive.ql.exec;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.exec.mr.ExecMapperContext;
-import org.apache.hadoop.hive.ql.exec.persistence.MapJoinKey;
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;
-import org.apache.hadoop.hive.ql.plan.MapJoinDesc;
/**
* HashTableLoader is an interface used by MapJoinOperator used to load the hashtables
@@ -31,8 +29,9 @@ import org.apache.hadoop.hive.ql.plan.Ma
*/
public interface HashTableLoader {
- void init(ExecMapperContext context, Configuration hconf, MapJoinOperator joinOp);
+ void init(ExecMapperContext context, MapredContext mrContext, Configuration hconf,
+ MapJoinOperator joinOp);
- void load(MapJoinTableContainer[] mapJoinTables,
- MapJoinTableContainerSerDe[] mapJoinTableSerdes, long memUsage) throws HiveException;
+ void load(MapJoinTableContainer[] mapJoinTables, MapJoinTableContainerSerDe[] mapJoinTableSerdes,
+ long memUsage) throws HiveException;
}
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableSinkOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableSinkOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableSinkOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/HashTableSinkOperator.java Sat Mar 28 14:03:43 2015
@@ -22,7 +22,9 @@ import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
+import java.util.concurrent.Future;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -33,10 +35,10 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.exec.mapjoin.MapJoinMemoryExhaustionHandler;
import org.apache.hadoop.hive.ql.exec.persistence.HashMapWrapper;
+import org.apache.hadoop.hive.ql.exec.persistence.MapJoinEagerRowContainer;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinKeyObject;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinObjectSerDeContext;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinPersistableTableContainer;
-import org.apache.hadoop.hive.ql.exec.persistence.MapJoinEagerRowContainer;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinRowContainer;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinTableContainer;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinTableContainerSerDe;
@@ -114,7 +116,8 @@ public class HashTableSinkOperator exten
@Override
@SuppressWarnings("unchecked")
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
boolean isSilent = HiveConf.getBoolVar(hconf, HiveConf.ConfVars.HIVESESSIONSILENT);
console = new LogHelper(LOG, isSilent);
memoryExhaustionHandler = new MapJoinMemoryExhaustionHandler(console, conf.getHashtableMemoryUsage());
@@ -189,6 +192,7 @@ public class HashTableSinkOperator exten
} catch (SerDeException e) {
throw new HiveException(e);
}
+ return result;
}
public MapJoinTableContainer[] getMapJoinTables() {
@@ -219,7 +223,7 @@ public class HashTableSinkOperator exten
* This operator only process small tables Read the key/value pairs Load them into hashtable
*/
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
byte alias = (byte)tag;
// compute keys and values as StandardObjects. Use non-optimized key (MR).
Object[] currentKey = new Object[joinKeys[alias].size()];
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinOperator.java Sat Mar 28 14:03:43 2015
@@ -20,7 +20,9 @@ package org.apache.hadoop.hive.ql.exec;
import java.io.IOException;
import java.io.Serializable;
+import java.util.Collection;
import java.util.List;
+import java.util.concurrent.Future;
import org.apache.commons.logging.Log;
import org.apache.hadoop.conf.Configuration;
@@ -38,8 +40,7 @@ import org.apache.hadoop.io.LongWritable
/**
* Join operator implementation.
*/
-public class JoinOperator extends CommonJoinOperator<JoinDesc> implements
- Serializable {
+public class JoinOperator extends CommonJoinOperator<JoinDesc> implements Serializable {
private static final long serialVersionUID = 1L;
private transient SkewJoinHandler skewJoinKeyContext = null;
@@ -55,19 +56,19 @@ public class JoinOperator extends Common
private final transient LongWritable skewjoin_followup_jobs = new LongWritable(0);
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
- super.initializeOp(hconf);
- initializeChildren(hconf);
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
if (handleSkewJoin) {
skewJoinKeyContext = new SkewJoinHandler(this);
skewJoinKeyContext.initiliaze(hconf);
skewJoinKeyContext.setSkewJoinJobCounter(skewjoin_followup_jobs);
}
statsMap.put(SkewkeyTableCounter.SKEWJOINFOLLOWUPJOBS.toString(), skewjoin_followup_jobs);
+ return result;
}
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
try {
reportProgress();
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinUtil.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinUtil.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinUtil.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinUtil.java Sat Mar 28 14:03:43 2015
@@ -48,6 +48,15 @@ import org.apache.hadoop.util.Reflection
public class JoinUtil {
+ /**
+ * Represents the join result between two tables
+ */
+ public static enum JoinResult {
+ MATCH, // A match is found
+ NOMATCH, // No match is found, and the current row will be dropped
+ SPILL // The current row has been spilled to disk, as the join is postponed
+ }
+
public static List<ObjectInspector>[] getObjectInspectorsFromEvaluators(
List<ExprNodeEvaluator>[] exprEntries,
ObjectInspector[] inputObjInspector,
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LateralViewForwardOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LateralViewForwardOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LateralViewForwardOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LateralViewForwardOperator.java Sat Mar 28 14:03:43 2015
@@ -18,6 +18,10 @@
package org.apache.hadoop.hive.ql.exec;
+import java.util.Collection;
+import java.util.concurrent.Future;
+
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.plan.LateralViewForwardDesc;
import org.apache.hadoop.hive.ql.plan.api.OperatorType;
@@ -33,7 +37,7 @@ public class LateralViewForwardOperator
private static final long serialVersionUID = 1L;
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
forward(row, inputObjInspectors[tag]);
}
@@ -50,4 +54,9 @@ public class LateralViewForwardOperator
public OperatorType getType() {
return OperatorType.LATERALVIEWFORWARD;
}
+
+ @Override
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ return super.initializeOp(hconf);
+ }
}
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LateralViewJoinOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LateralViewJoinOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LateralViewJoinOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LateralViewJoinOperator.java Sat Mar 28 14:03:43 2015
@@ -19,7 +19,9 @@
package org.apache.hadoop.hive.ql.exec;
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;
@@ -82,7 +84,8 @@ public class LateralViewJoinOperator ext
public static final byte UDTF_TAG = 1;
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
ArrayList<ObjectInspector> ois = new ArrayList<ObjectInspector>();
ArrayList<String> fieldNames = conf.getOutputInternalColNames();
@@ -104,9 +107,8 @@ public class LateralViewJoinOperator ext
outputObjInspector = ObjectInspectorFactory
.getStandardStructObjectInspector(fieldNames, ois);
+ return result;
- // Initialize the rest of the operator DAG
- super.initializeOp(hconf);
}
// acc is short for accumulator. It's used to build the row before forwarding
@@ -121,7 +123,7 @@ public class LateralViewJoinOperator ext
* by all the corresponding rows from the UDTF operator. And so on.
*/
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
StructObjectInspector soi = (StructObjectInspector) inputObjInspectors[tag];
if (tag == SELECT_TAG) {
selectObjs.clear();
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LimitOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LimitOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LimitOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/LimitOperator.java Sat Mar 28 14:03:43 2015
@@ -19,6 +19,8 @@
package org.apache.hadoop.hive.ql.exec;
import java.io.Serializable;
+import java.util.Collection;
+import java.util.concurrent.Future;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -37,16 +39,17 @@ public class LimitOperator extends Opera
protected transient boolean isMap;
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
- super.initializeOp(hconf);
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
limit = conf.getLimit();
leastRow = conf.getLeastRows();
currCount = 0;
isMap = hconf.getBoolean("mapred.task.is.map", true);
+ return result;
}
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
if (currCount < limit) {
forward(row, inputObjInspectors[tag]);
currCount++;
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ListSinkOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ListSinkOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ListSinkOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ListSinkOperator.java Sat Mar 28 14:03:43 2015
@@ -18,11 +18,12 @@
package org.apache.hadoop.hive.ql.exec;
+import java.util.Collection;
import java.util.List;
import java.util.Properties;
+import java.util.concurrent.Future;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.common.JavaUtils;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.plan.ListSinkDesc;
import org.apache.hadoop.hive.ql.plan.api.OperatorType;
@@ -43,13 +44,14 @@ public class ListSinkOperator extends Op
private transient int numRows;
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
try {
fetcher = initializeFetcher(hconf);
} catch (Exception e) {
throw new HiveException(e);
}
- super.initializeOp(hconf);
+ return result;
}
private FetchFormatter initializeFetcher(Configuration conf) throws Exception {
@@ -81,8 +83,9 @@ public class ListSinkOperator extends Op
return numRows;
}
+ @Override
@SuppressWarnings("unchecked")
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
try {
res.add(fetcher.convert(row, inputObjInspectors[0]));
numRows++;
@@ -91,6 +94,7 @@ public class ListSinkOperator extends Op
}
}
+ @Override
public OperatorType getType() {
return OperatorType.FORWARD;
}
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapJoinOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapJoinOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapJoinOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapJoinOperator.java Sat Mar 28 14:03:43 2015
@@ -18,26 +18,38 @@
package org.apache.hadoop.hive.ql.exec;
+import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.common.ObjectPair;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.HashTableLoaderFactory;
import org.apache.hadoop.hive.ql.exec.mapjoin.MapJoinMemoryExhaustionHandler;
+import org.apache.hadoop.hive.ql.exec.mr.ExecMapperContext;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinKey;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinObjectSerDeContext;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinRowContainer;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinTableContainer;
-import org.apache.hadoop.hive.ql.exec.persistence.MapJoinTableContainer.ReusableGetAdaptor;
import org.apache.hadoop.hive.ql.exec.persistence.MapJoinTableContainerSerDe;
+import org.apache.hadoop.hive.ql.exec.persistence.MapJoinTableContainer.ReusableGetAdaptor;
import org.apache.hadoop.hive.ql.exec.persistence.UnwrapRowContainer;
+import org.apache.hadoop.hive.ql.exec.persistence.BytesBytesMultiHashMap;
+import org.apache.hadoop.hive.ql.exec.persistence.MapJoinBytesTableContainer;
+import org.apache.hadoop.hive.ql.exec.persistence.HybridHashTableContainer;
+import org.apache.hadoop.hive.ql.exec.persistence.KeyValueContainer;
+import org.apache.hadoop.hive.ql.exec.persistence.ObjectContainer;
+import org.apache.hadoop.hive.ql.io.HiveKey;
import org.apache.hadoop.hive.ql.log.PerfLogger;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.plan.MapJoinDesc;
@@ -47,8 +59,13 @@ import org.apache.hadoop.hive.serde2.Ser
import org.apache.hadoop.hive.serde2.SerDeException;
import org.apache.hadoop.hive.serde2.SerDeUtils;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.io.BytesWritable;
+import org.apache.hadoop.io.Writable;
import org.apache.hadoop.util.ReflectionUtils;
+import static org.apache.hadoop.hive.ql.exec.persistence.HybridHashTableContainer.HashPartition;
+import static org.apache.hadoop.hive.ql.exec.persistence.MapJoinBytesTableContainer.KeyValueHelper;
+
/**
* Map side Join operator implementation.
*/
@@ -70,6 +87,12 @@ public class MapJoinOperator extends Abs
private transient ReusableGetAdaptor[] hashMapRowGetters;
private UnwrapRowContainer[] unwrapContainer;
+ private transient Configuration hconf;
+ private transient boolean useHybridGraceHashJoin; // whether Hybrid Grace Hash Join is enabled
+ private transient boolean hybridMapJoinLeftover; // whether there's spilled data to be processed
+ private transient MapJoinBytesTableContainer currentSmallTable; // reloaded hashmap from disk
+ private transient int tag; // big table alias
+ private transient int smallTable; // small table alias
public MapJoinOperator() {
}
@@ -94,9 +117,14 @@ public class MapJoinOperator extends Abs
}
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ this.hconf = hconf;
unwrapContainer = new UnwrapRowContainer[conf.getTagLength()];
- super.initializeOp(hconf);
+
+ Collection<Future<?>> result = super.initializeOp(hconf);
+ if (result == null) {
+ result = new HashSet<Future<?>>();
+ }
int tagLen = conf.getTagLength();
@@ -113,10 +141,15 @@ public class MapJoinOperator extends Abs
mapJoinTables = new MapJoinTableContainer[tagLen];
mapJoinTableSerdes = new MapJoinTableContainerSerDe[tagLen];
hashTblInitedOnce = false;
+ useHybridGraceHashJoin =
+ HiveConf.getBoolVar(hconf, HiveConf.ConfVars.HIVEUSEHYBRIDGRACEHASHJOIN);
generateMapMetaData();
- if (!conf.isBucketMapJoin()) {
+ final ExecMapperContext mapContext = getExecContext();
+ final MapredContext mrContext = MapredContext.get();
+
+ if (!conf.isBucketMapJoin() && !useHybridGraceHashJoin) {
/*
* The issue with caching in case of bucket map join is that different tasks
* process different buckets and if the container is reused to join a different bucket,
@@ -126,27 +159,42 @@ public class MapJoinOperator extends Abs
* also ability to schedule tasks to re-use containers that have cached the specific bucket.
*/
if (isLogInfoEnabled) {
- LOG.info("This is not bucket map join, so cache");
+ LOG.info("This is not bucket map join, so cache");
}
- Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]> pair =
- (Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]>)
- cache.retrieve(cacheKey, new Callable<Object>() {
- public Object call() throws HiveException {
- return loadHashTable();
- }
- });
+ Future<Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]>> future =
+ cache.retrieveAsync(
+ cacheKey,
+ new Callable<Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]>>() {
+ @Override
+ public Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]> call()
+ throws HiveException {
+ return loadHashTable(mapContext, mrContext);
+ }
+ });
+ result.add(future);
+ } else if (mapContext == null || mapContext.getLocalWork() == null
+ || mapContext.getLocalWork().getInputFileChangeSensitive() == false) {
+ loadHashTable(mapContext, mrContext);
+ hashTblInitedOnce = true;
+ }
+ return result;
+ }
+ @SuppressWarnings("unchecked")
+ @Override
+ protected final void completeInitializationOp(Object[] os) throws HiveException {
+ if (os.length != 0) {
+ Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]> pair =
+ (Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]>) os[0];
mapJoinTables = pair.getLeft();
mapJoinTableSerdes = pair.getRight();
hashTblInitedOnce = true;
- } else {
- loadHashTable();
}
if (this.getExecContext() != null) {
// reset exec context so that initialization of the map operator happens
- // poperly
+ // properly
this.getExecContext().setLastInputPath(null);
this.getExecContext().setCurrentInputPath(null);
}
@@ -182,45 +230,44 @@ public class MapJoinOperator extends Abs
try {
TableDesc keyTableDesc = conf.getKeyTblDesc();
SerDe keySerializer = (SerDe) ReflectionUtils.newInstance(keyTableDesc.getDeserializerClass(),
- null);
+ null);
SerDeUtils.initializeSerDe(keySerializer, null, keyTableDesc.getProperties(), null);
MapJoinObjectSerDeContext keyContext = new MapJoinObjectSerDeContext(keySerializer, false);
for (int pos = 0; pos < order.length; pos++) {
- if (pos == posBigTable) {
- continue;
- }
- TableDesc valueTableDesc;
- if (conf.getNoOuterJoin()) {
- valueTableDesc = conf.getValueTblDescs().get(pos);
- } else {
- valueTableDesc = conf.getValueFilteredTblDescs().get(pos);
- }
- SerDe valueSerDe = (SerDe) ReflectionUtils.newInstance(valueTableDesc.getDeserializerClass(),
- null);
- SerDeUtils.initializeSerDe(valueSerDe, null, valueTableDesc.getProperties(), null);
- MapJoinObjectSerDeContext valueContext = new MapJoinObjectSerDeContext(valueSerDe, hasFilter(pos));
- mapJoinTableSerdes[pos] = new MapJoinTableContainerSerDe(keyContext, valueContext);
+ if (pos == posBigTable) {
+ continue;
+ }
+ TableDesc valueTableDesc;
+ if (conf.getNoOuterJoin()) {
+ valueTableDesc = conf.getValueTblDescs().get(pos);
+ } else {
+ valueTableDesc = conf.getValueFilteredTblDescs().get(pos);
+ }
+ SerDe valueSerDe =
+ (SerDe) ReflectionUtils.newInstance(valueTableDesc.getDeserializerClass(), null);
+ SerDeUtils.initializeSerDe(valueSerDe, null, valueTableDesc.getProperties(), null);
+ MapJoinObjectSerDeContext valueContext =
+ new MapJoinObjectSerDeContext(valueSerDe, hasFilter(pos));
+ mapJoinTableSerdes[pos] = new MapJoinTableContainerSerDe(keyContext, valueContext);
}
} catch (SerDeException e) {
throw new HiveException(e);
}
}
- private Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]>
- loadHashTable() throws HiveException {
+ private Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]> loadHashTable(
+ ExecMapperContext mapContext, MapredContext mrContext) throws HiveException {
if (this.hashTblInitedOnce
- && ((this.getExecContext() == null)
- || (this.getExecContext().getLocalWork() == null)
- || (this.getExecContext().getLocalWork().getInputFileChangeSensitive()
- == false))) {
+ && ((mapContext == null) || (mapContext.getLocalWork() == null) || (mapContext
+ .getLocalWork().getInputFileChangeSensitive() == false))) {
// no need to reload
- return new ImmutablePair<MapJoinTableContainer[],
- MapJoinTableContainerSerDe[]> (mapJoinTables, mapJoinTableSerdes);
+ return new ImmutablePair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]>(
+ mapJoinTables, mapJoinTableSerdes);
}
perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.LOAD_HASHTABLE);
- loader.init(getExecContext(), hconf, this);
+ loader.init(mapContext, mrContext, hconf, this);
long memUsage = (long)(MapJoinMemoryExhaustionHandler.getMaxHeapSize()
* conf.getHashTableMemoryUsage());
loader.load(mapJoinTables, mapJoinTableSerdes, memUsage);
@@ -239,12 +286,12 @@ public class MapJoinOperator extends Abs
// Load the hash table
@Override
public void cleanUpInputFileChangedOp() throws HiveException {
- loadHashTable();
+ loadHashTable(getExecContext(), MapredContext.get());
}
- protected void setMapJoinKey(
+ protected JoinUtil.JoinResult setMapJoinKey(
ReusableGetAdaptor dest, Object row, byte alias) throws HiveException {
- dest.setFromRow(row, joinKeys[alias], joinKeysObjectInspectors[alias]);
+ return dest.setFromRow(row, joinKeys[alias], joinKeysObjectInspectors[alias]);
}
protected MapJoinKey getRefKey(byte alias) {
@@ -260,7 +307,19 @@ public class MapJoinOperator extends Abs
}
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
+ this.tag = tag;
+
+ // As we're calling processOp again to process the leftover triplets, we know the "row" is
+ // coming from the on-disk matchfile. We need to recreate hashMapRowGetter against new hashtable
+ if (hybridMapJoinLeftover) {
+ assert hashMapRowGetters != null;
+ if (hashMapRowGetters[smallTable] == null) {
+ MapJoinKey refKey = getRefKey((byte) tag);
+ hashMapRowGetters[smallTable] = currentSmallTable.createGetter(refKey);
+ }
+ }
+
try {
alias = (byte) tag;
if (hashMapRowGetters == null) {
@@ -279,14 +338,16 @@ public class MapJoinOperator extends Abs
boolean joinNeeded = false;
for (byte pos = 0; pos < order.length; pos++) {
if (pos != alias) {
+ smallTable = pos; // record small table alias
+ JoinUtil.JoinResult joinResult;
ReusableGetAdaptor adaptor;
if (firstSetKey == null) {
adaptor = firstSetKey = hashMapRowGetters[pos];
- setMapJoinKey(firstSetKey, row, alias);
+ joinResult = setMapJoinKey(firstSetKey, row, alias);
} else {
// Keys for all tables are the same, so only the first has to deserialize them.
adaptor = hashMapRowGetters[pos];
- adaptor.setFromOther(firstSetKey);
+ joinResult = adaptor.setFromOther(firstSetKey);
}
MapJoinRowContainer rowContainer = adaptor.getCurrentRows();
if (rowContainer != null && unwrapContainer[pos] != null) {
@@ -296,8 +357,13 @@ public class MapJoinOperator extends Abs
// there is no join-value or join-key has all null elements
if (rowContainer == null || firstSetKey.hasAnyNulls(fieldCount, nullsafes)) {
if (!noOuterJoin) {
- joinNeeded = true;
- storage[pos] = dummyObjVectors[pos];
+ // For Hybrid Grace Hash Join, during the 1st round processing,
+ // we only keep the LEFT side if the row is not spilled
+ if (!useHybridGraceHashJoin || hybridMapJoinLeftover ||
+ (!hybridMapJoinLeftover && joinResult != JoinUtil.JoinResult.SPILL)) {
+ joinNeeded = true;
+ storage[pos] = dummyObjVectors[pos];
+ }
} else {
storage[pos] = emptyList;
}
@@ -306,6 +372,10 @@ public class MapJoinOperator extends Abs
storage[pos] = rowContainer.copy();
aliasFilterTags[pos] = rowContainer.getAliasFilter();
}
+ // Spill the big table rows into appropriate partition
+ if (joinResult == JoinUtil.JoinResult.SPILL) {
+ spillBigTableRow(mapJoinTables[pos], row);
+ }
}
}
if (joinNeeded) {
@@ -329,11 +399,60 @@ public class MapJoinOperator extends Abs
}
}
+ /**
+ * Postpone processing the big table row temporarily by spilling it to a row container
+ * @param hybridHtContainer Hybrid hashtable container
+ * @param row big table row
+ */
+ protected void spillBigTableRow(MapJoinTableContainer hybridHtContainer, Object row) throws HiveException {
+ HybridHashTableContainer ht = (HybridHashTableContainer) hybridHtContainer;
+ int partitionId = ht.getToSpillPartitionId();
+ HashPartition hp = ht.getHashPartitions()[partitionId];
+ ObjectContainer bigTable = hp.getMatchfileObjContainer();
+ bigTable.add(row);
+ }
+
@Override
public void closeOp(boolean abort) throws HiveException {
for (MapJoinTableContainer tableContainer : mapJoinTables) {
if (tableContainer != null) {
tableContainer.dumpMetrics();
+
+ if (tableContainer instanceof HybridHashTableContainer) {
+ HybridHashTableContainer hybridHtContainer = (HybridHashTableContainer) tableContainer;
+ hybridHtContainer.dumpStats();
+
+ HashPartition[] hashPartitions = hybridHtContainer.getHashPartitions();
+ // Clear all in memory partitions first
+ for (int i = 0; i < hashPartitions.length; i++) {
+ if (!hashPartitions[i].isHashMapOnDisk()) {
+ hybridHtContainer.setTotalInMemRowCount(
+ hybridHtContainer.getTotalInMemRowCount() -
+ hashPartitions[i].getHashMapFromMemory().getNumValues());
+ hashPartitions[i].getHashMapFromMemory().clear();
+ }
+ }
+ assert hybridHtContainer.getTotalInMemRowCount() == 0;
+
+ for (int i = 0; i < hashPartitions.length; i++) {
+ if (hashPartitions[i].isHashMapOnDisk()) {
+ // Recursively process on-disk triplets (hash partition, sidefile, matchfile)
+ try {
+ hybridMapJoinLeftover = true;
+ hashMapRowGetters[smallTable] = null;
+ continueProcess(hashPartitions[i], hybridHtContainer);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (SerDeException e) {
+ e.printStackTrace();
+ }
+ }
+ hybridMapJoinLeftover = false;
+ currentSmallTable = null;
+ }
+ }
}
}
if ((this.getExecContext() != null) && (this.getExecContext().getLocalWork() != null)
@@ -350,6 +469,91 @@ public class MapJoinOperator extends Abs
}
/**
+ * Continue processing each pair of spilled hashtable and big table row container
+ * @param partition hash partition to process
+ * @param hybridHtContainer Hybrid hashtable container
+ * @throws HiveException
+ * @throws IOException
+ * @throws ClassNotFoundException
+ * @throws SerDeException
+ */
+ private void continueProcess(HashPartition partition, HybridHashTableContainer hybridHtContainer)
+ throws HiveException, IOException, ClassNotFoundException, SerDeException {
+ reloadHashTable(partition, hybridHtContainer);
+ reProcessBigTable(partition);
+ }
+
+ /**
+ * Reload hashtable from the hash partition.
+ * It can have two steps:
+ * 1) Deserialize a serialized hash table, and
+ * 2) Merge every key/value pair from small table container into the hash table
+ * @param partition hash partition to process
+ * @param hybridHtContainer Hybrid hashtable container
+ * @throws IOException
+ * @throws ClassNotFoundException
+ * @throws HiveException
+ * @throws SerDeException
+ */
+ private void reloadHashTable(HashPartition partition,
+ HybridHashTableContainer hybridHtContainer)
+ throws IOException, ClassNotFoundException, HiveException, SerDeException {
+ // Deserialize the on-disk hash table
+ // We're sure this part is smaller than memory limit
+ BytesBytesMultiHashMap restoredHashMap = partition.getHashMapFromDisk();
+ int rowCount = restoredHashMap.getNumValues();
+ LOG.info("Hybrid Grace Hash Join: Deserializing spilled hash partition...");
+ LOG.info("Hybrid Grace Hash Join: Number of rows restored from hashmap: " + rowCount);
+
+ // Merge the sidefile into the newly created hash table
+ // This is where the spilling may happen again
+ KeyValueContainer kvContainer = partition.getSidefileKVContainer();
+ rowCount += kvContainer.size();
+ LOG.info("Hybrid Grace Hash Join: Number of rows restored from KeyValueContainer: " +
+ kvContainer.size());
+
+ // If based on the new key count, keyCount is smaller than a threshold,
+ // then just load the entire restored hashmap into memory.
+ // The size of deserialized partition shouldn't exceed half of memory limit
+ if (rowCount * hybridHtContainer.getTableRowSize() >= hybridHtContainer.getMemoryThreshold() / 2) {
+ throw new RuntimeException("Hybrid Grace Hash Join: Hash table cannot be reloaded since it" +
+ " will be greater than memory limit. Recursive spilling is currently not supported");
+ }
+
+ KeyValueHelper writeHelper = hybridHtContainer.getWriteHelper();
+ while (kvContainer.hasNext()) {
+ ObjectPair<HiveKey, BytesWritable> pair = kvContainer.next();
+ Writable key = pair.getFirst();
+ Writable val = pair.getSecond();
+ writeHelper.setKeyValue(key, val);
+ restoredHashMap.put(writeHelper, -1);
+ }
+
+ hybridHtContainer.setTotalInMemRowCount(hybridHtContainer.getTotalInMemRowCount()
+ + restoredHashMap.getNumValues() + kvContainer.size());
+ kvContainer.clear();
+
+ // Since there's only one hashmap to deal with, it's OK to create a MapJoinBytesTableContainer
+ currentSmallTable = new MapJoinBytesTableContainer(restoredHashMap);
+ currentSmallTable.setInternalValueOi(hybridHtContainer.getInternalValueOi());
+ currentSmallTable.setSortableSortOrders(hybridHtContainer.getSortableSortOrders());
+ }
+
+ /**
+ * Iterate over the big table row container and feed process() with leftover rows
+ * @param partition the hash partition being brought back to memory at the moment
+ * @throws HiveException
+ */
+ protected void reProcessBigTable(HashPartition partition) throws HiveException {
+ ObjectContainer bigTable = partition.getMatchfileObjContainer();
+ while (bigTable.hasNext()) {
+ Object row = bigTable.next();
+ process(row, tag);
+ }
+ bigTable.clear();
+ }
+
+ /**
* Implements the getName function for the Node Interface.
*
* @return the name of the operator
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapOperator.java Sat Mar 28 14:03:43 2015
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.ql.exec;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -29,10 +30,11 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
+import java.util.concurrent.Future;
-import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
import org.apache.hadoop.hive.ql.exec.mr.ExecMapperContext;
import org.apache.hadoop.hive.ql.exec.tez.MapRecordProcessor;
@@ -62,6 +64,8 @@ import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.util.StringUtils;
+import com.google.common.annotations.VisibleForTesting;
+
/**
* Map operator. This triggers overall map side processing. This is a little
* different from regular operators in that it starts off by processing a
@@ -85,6 +89,7 @@ public class MapOperator extends Operato
private final transient LongWritable recordCounter = new LongWritable();
protected transient long numRows = 0;
protected transient long cntr = 1;
+ protected transient long logEveryNRows = 0;
// input path --> {operator --> context}
private final Map<String, Map<Operator<?>, MapOpCtx>> opCtxMap =
@@ -154,7 +159,7 @@ public class MapOperator extends Operato
if (op.getDone()) {
return false;
}
- op.processOp(row, 0);
+ op.process(row, 0);
return true;
}
}
@@ -172,8 +177,8 @@ public class MapOperator extends Operato
void initializeAsRoot(JobConf hconf, MapWork mapWork) throws Exception {
setConf(mapWork);
setChildren(hconf);
- setExecContext(new ExecMapperContext(hconf));
- initialize(hconf, null);
+ passExecContext(new ExecMapperContext(hconf));
+ initializeMapOperator(hconf);
}
private MapOpCtx initObjectInspector(Configuration hconf, MapOpCtx opCtx,
@@ -413,12 +418,18 @@ public class MapOperator extends Operato
}
@Override
- public void initializeOp(Configuration hconf) throws HiveException {
+ public Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ return super.initializeOp(hconf);
+ }
+
+ public void initializeMapOperator(Configuration hconf) throws HiveException {
// set that parent initialization is done and call initialize on children
state = State.INIT;
statsMap.put(Counter.DESERIALIZE_ERRORS.toString(), deserialize_error_count);
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()) {
@@ -514,7 +525,11 @@ public class MapOperator extends Operato
numRows += rows;
if (isLogInfoEnabled) {
while (numRows >= cntr) {
- cntr *= 10;
+ cntr = logEveryNRows == 0 ? cntr * 10 : numRows + logEveryNRows;
+ if (cntr < 0 || numRows < 0) {
+ cntr = 1;
+ numRows = 0;
+ }
LOG.info(toString() + ": records read - " + numRows);
}
}
@@ -604,7 +619,7 @@ public class MapOperator extends Operato
}
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
throw new HiveException("Hive 2 Internal error: should not be called!");
}
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapredContext.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapredContext.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapredContext.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MapredContext.java Sat Mar 28 14:03:43 2015
@@ -52,6 +52,7 @@ public class MapredContext {
HiveConf.getVar(jobConf, ConfVars.HIVE_EXECUTION_ENGINE).equals("tez") ?
new TezContext(isMap, jobConf) : new MapredContext(isMap, jobConf);
contexts.set(context);
+ logger.info("MapredContext initialized.");
return context;
}
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java Sat Mar 28 14:03:43 2015
@@ -379,7 +379,8 @@ public class MoveTask extends Task<MoveW
dpCtx.getNumDPCols(),
tbd.getHoldDDLTime(),
isSkewedStoredAsDirs(tbd),
- work.getLoadTableWork().getWriteType() != AcidUtils.Operation.NOT_ACID);
+ work.getLoadTableWork().getWriteType() != AcidUtils.Operation.NOT_ACID,
+ SessionState.get().getCurrentTxn());
console.printInfo("\t Time taken for load dynamic partitions : " +
(System.currentTimeMillis() - startTime));
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MuxOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MuxOperator.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MuxOperator.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/MuxOperator.java Sat Mar 28 14:03:43 2015
@@ -21,7 +21,9 @@ package org.apache.hadoop.hive.ql.exec;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
+import java.util.concurrent.Future;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -169,7 +171,9 @@ public class MuxOperator extends Operato
private transient long[] nextCntrs;
@Override
- protected void initializeOp(Configuration hconf) throws HiveException {
+ protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ Collection<Future<?>> result = super.initializeOp(hconf);
+
// A MuxOperator should only have a single child
if (childOperatorsArray.length != 1) {
throw new HiveException(
@@ -204,7 +208,7 @@ public class MuxOperator extends Operato
cntrs[i] = 0;
nextCntrs[i] = 1;
}
- initializeChildren(hconf);
+ return result;
}
/**
@@ -230,7 +234,7 @@ public class MuxOperator extends Operato
}
@Override
- public void processOp(Object row, int tag) throws HiveException {
+ public void process(Object row, int tag) throws HiveException {
if (isLogInfoEnabled) {
cntrs[tag]++;
if (cntrs[tag] == nextCntrs[tag]) {
@@ -247,11 +251,11 @@ public class MuxOperator extends Operato
} else {
if (forward[tag]) {
// No need to evaluate, just forward it.
- child.processOp(row, tag);
+ child.process(row, tag);
} else {
// Call the corresponding handler to evaluate this row and
// forward the result
- child.processOp(handlers[tag].process(row), handlers[tag].getTag());
+ child.process(handlers[tag].process(row), handlers[tag].getTag());
}
}
}
@@ -269,7 +273,7 @@ public class MuxOperator extends Operato
// we cannot pass new tag to this method which is used to get
// the old tag from the mapping of newTagToOldTag, we bypass
// this method in MuxOperator and directly call process on children
- // in processOp() method..
+ // in process() method..
}
@Override
@@ -308,7 +312,7 @@ public class MuxOperator extends Operato
protected void closeOp(boolean abort) throws HiveException {
if (isLogInfoEnabled) {
for (int i = 0; i < numParents; i++) {
- LOG.info(id + ", tag=" + i + ", forwarded " + cntrs[i] + " rows");
+ LOG.info(id + ", tag=" + i + ", forwarded " + cntrs[i] + " rows");
}
}
}
Modified: hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ObjectCache.java
URL: http://svn.apache.org/viewvc/hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ObjectCache.java?rev=1669775&r1=1669774&r2=1669775&view=diff
==============================================================================
--- hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ObjectCache.java (original)
+++ hive/branches/spark/ql/src/java/org/apache/hadoop/hive/ql/exec/ObjectCache.java Sat Mar 28 14:03:43 2015
@@ -18,6 +18,8 @@
package org.apache.hadoop.hive.ql.exec;
import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
import org.apache.hadoop.hive.ql.metadata.HiveException;
/**
@@ -32,9 +34,23 @@ public interface ObjectCache {
/**
* Retrieve object from cache.
+ *
+ * @param <T>
+ * @param key
+ * @param fn
+ * function to generate the object if it's not there
+ * @return the last cached object with the key, null if none.
+ */
+ public <T> T retrieve(String key, Callable<T> fn) throws HiveException;
+
+ /**
+ * Retrieve object from cache asynchronously.
+ *
+ * @param <T>
* @param key
- * @param fn function to generate the object if it's not there
+ * @param fn
+ * function to generate the object if it's not there
* @return the last cached object with the key, null if none.
*/
- public Object retrieve(String key, Callable<?> fn) throws HiveException;
+ public <T> Future<T> retrieveAsync(String key, Callable<T> fn) throws HiveException;
}