You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by gu...@apache.org on 2014/09/04 04:49:50 UTC
svn commit: r1622396 [3/8] - in /hive/branches/cbo: ./
accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/predicate/
beeline/src/java/org/apache/hive/beeline/
beeline/src/test/org/apache/hive/beeline/ bin/ bin/ext/ checkstyle/
common/src/java/or...
Modified: hive/branches/cbo/pom.xml
URL: http://svn.apache.org/viewvc/hive/branches/cbo/pom.xml?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/pom.xml (original)
+++ hive/branches/cbo/pom.xml Thu Sep 4 02:49:46 2014
@@ -60,6 +60,7 @@
<maven.repo.local>${settings.localRepository}</maven.repo.local>
<hive.path.to.root>.</hive.path.to.root>
<hive.jdbc.driver.classifier>standalone</hive.jdbc.driver.classifier>
+ <checkstyle.conf.dir>${hive.path.to.root}/checkstyle</checkstyle.conf.dir>
<!-- Test Properties -->
<test.extra.path></test.extra.path>
@@ -75,6 +76,7 @@
<datanucleus.maven.plugin.version>3.3.0-release</datanucleus.maven.plugin.version>
<maven.antrun.plugin.version>1.7</maven.antrun.plugin.version>
<maven.assembly.plugin.version>2.3</maven.assembly.plugin.version>
+ <maven.checkstyle.plugin.version>2.12.1</maven.checkstyle.plugin.version>
<maven.compiler.plugin.version>3.1</maven.compiler.plugin.version>
<maven.enforcer.plugin.version>1.3.1</maven.enforcer.plugin.version>
<maven.install.plugin.version>2.4</maven.install.plugin.version>
@@ -616,6 +618,11 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${maven.checkstyle.plugin.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven.enforcer.plugin.version}</version>
</plugin>
@@ -745,6 +752,13 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <configLocation>${checkstyle.conf.dir}/checkstyle.xml</configLocation>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/AutoProgressor.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/AutoProgressor.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/AutoProgressor.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/AutoProgressor.java Thu Sep 4 02:49:46 2014
@@ -44,7 +44,7 @@ public class AutoProgressor {
// Name of the class to report for
String logClassName = null;
int notificationInterval;
- int timeout;
+ long timeout;
Reporter reporter;
class ReporterTask extends TimerTask {
@@ -116,7 +116,7 @@ public class AutoProgressor {
* @param timeout - when the autoprogressor should stop reporting (in ms)
*/
AutoProgressor(String logClassName, Reporter reporter,
- int notificationInterval, int timeout) {
+ int notificationInterval, long timeout) {
this.logClassName = logClassName;
this.reporter = reporter;
this.notificationInterval = notificationInterval;
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java Thu Sep 4 02:49:46 2014
@@ -507,21 +507,19 @@ public class DDLTask extends Task<DDLWor
throw new HiveException("invalid configuration name " + showConf.getConfName());
}
String description = conf.getDescription();
- String defaltValue = conf.getDefaultValue();
+ String defaultValue = conf.getDefaultValue();
DataOutputStream output = getOutputStream(showConf.getResFile());
try {
+ if (defaultValue != null) {
+ output.write(defaultValue.getBytes());
+ }
+ output.write(separator);
+ output.write(conf.typeString().getBytes());
+ output.write(separator);
if (description != null) {
- if (defaltValue != null) {
- output.write(defaltValue.getBytes());
- }
- output.write(separator);
- output.write(conf.typeString().getBytes());
- output.write(separator);
- if (description != null) {
- output.write(description.replaceAll(" *\n *", " ").getBytes());
- }
- output.write(terminator);
+ output.write(description.replaceAll(" *\n *", " ").getBytes());
}
+ output.write(terminator);
} finally {
output.close();
}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/Heartbeater.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/Heartbeater.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/Heartbeater.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/Heartbeater.java Thu Sep 4 02:49:46 2014
@@ -25,6 +25,7 @@ import org.apache.hadoop.hive.ql.lockmgr
import org.apache.hadoop.hive.ql.lockmgr.LockException;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
/**
* Class to handle heartbeats for MR and Tez tasks.
@@ -64,7 +65,8 @@ public class Heartbeater {
if (heartbeatInterval == 0) {
// Multiply the heartbeat interval by 1000 to convert to milliseconds,
// but divide by 2 to give us a safety factor.
- heartbeatInterval = HiveConf.getIntVar(conf, HiveConf.ConfVars.HIVE_TXN_TIMEOUT) * 500;
+ heartbeatInterval = HiveConf.getTimeVar(
+ conf, HiveConf.ConfVars.HIVE_TXN_TIMEOUT, TimeUnit.MILLISECONDS) / 2;
if (heartbeatInterval == 0) {
LOG.warn(HiveConf.ConfVars.HIVE_TXN_MANAGER.toString() + " not set, heartbeats won't be sent");
dontHeartbeat = true;
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/HiveTotalOrderPartitioner.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/HiveTotalOrderPartitioner.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/HiveTotalOrderPartitioner.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/HiveTotalOrderPartitioner.java Thu Sep 4 02:49:46 2014
@@ -20,24 +20,50 @@
package org.apache.hadoop.hive.ql.exec;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configurable;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.io.HiveKey;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.Partitioner;
import org.apache.hadoop.mapred.lib.TotalOrderPartitioner;
-public class HiveTotalOrderPartitioner implements Partitioner<HiveKey, Object> {
+public class HiveTotalOrderPartitioner implements Partitioner<HiveKey, Object>, Configurable {
- private Partitioner<BytesWritable, Object> partitioner
- = new TotalOrderPartitioner<BytesWritable, Object>();
+ private static final Log LOG = LogFactory.getLog(HiveTotalOrderPartitioner.class);
+ private Partitioner<BytesWritable, Object> partitioner;
+
+ @Override
public void configure(JobConf job) {
- JobConf newconf = new JobConf(job);
- newconf.setMapOutputKeyClass(BytesWritable.class);
- partitioner.configure(newconf);
+ if (partitioner == null) {
+ configurePartitioner(new JobConf(job));
+ }
+ }
+
+ @Override
+ public void setConf(Configuration conf) {
+ // walk-around of TEZ-1403
+ if (partitioner == null) {
+ configurePartitioner(new JobConf(conf));
+ }
}
public int getPartition(HiveKey key, Object value, int numPartitions) {
return partitioner.getPartition(key, value, numPartitions);
}
+
+ @Override
+ public Configuration getConf() {
+ return null;
+ }
+
+ private void configurePartitioner(JobConf conf) {
+ LOG.info(TotalOrderPartitioner.getPartitionFile(conf));
+ conf.setMapOutputKeyClass(BytesWritable.class);
+ partitioner = new TotalOrderPartitioner<BytesWritable, Object>();
+ partitioner.configure(conf);
+ }
}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java Thu Sep 4 02:49:46 2014
@@ -348,17 +348,17 @@ public class MoveTask extends Task<MoveW
// want to isolate any potential issue it may introduce.
ArrayList<LinkedHashMap<String, String>> dp =
db.loadDynamicPartitions(
- tbd.getSourcePath(),
- tbd.getTable().getTableName(),
- tbd.getPartitionSpec(),
- tbd.getReplace(),
- dpCtx.getNumDPCols(),
- tbd.getHoldDDLTime(),
- isSkewedStoredAsDirs(tbd));
+ tbd.getSourcePath(),
+ tbd.getTable().getTableName(),
+ tbd.getPartitionSpec(),
+ tbd.getReplace(),
+ dpCtx.getNumDPCols(),
+ tbd.getHoldDDLTime(),
+ isSkewedStoredAsDirs(tbd));
if (dp.size() == 0 && conf.getBoolVar(HiveConf.ConfVars.HIVE_ERROR_ON_EMPTY_PARTITION)) {
throw new HiveException("This query creates no partitions." +
- " To turn off this error, set hive.error.on.empty.partition=false.");
+ " To turn off this error, set hive.error.on.empty.partition=false.");
}
// for each partition spec, get the partition
@@ -412,13 +412,13 @@ public class MoveTask extends Task<MoveW
numBuckets, sortCols);
}
- dc = new DataContainer(table.getTTable(), partn.getTPartition());
- // add this partition to post-execution hook
- if (work.getOutputs() != null) {
- work.getOutputs().add(new WriteEntity(partn,
+ dc = new DataContainer(table.getTTable(), partn.getTPartition());
+ // add this partition to post-execution hook
+ if (work.getOutputs() != null) {
+ work.getOutputs().add(new WriteEntity(partn,
(tbd.getReplace() ? WriteEntity.WriteType.INSERT_OVERWRITE
: WriteEntity.WriteType.INSERT)));
- }
+ }
}
}
if (SessionState.get() != null && dc != null) {
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PTFOperator.java Thu Sep 4 02:49:46 2014
@@ -45,61 +45,60 @@ import org.apache.hadoop.hive.serde2.obj
public class PTFOperator extends Operator<PTFDesc> implements Serializable {
- private static final long serialVersionUID = 1L;
- boolean isMapOperator;
+ private static final long serialVersionUID = 1L;
+ boolean isMapOperator;
- transient KeyWrapperFactory keyWrapperFactory;
- protected transient KeyWrapper currentKeys;
- protected transient KeyWrapper newKeys;
- /*
- * for map-side invocation of PTFs, we cannot utilize the currentkeys null check
- * to decide on invoking startPartition in streaming mode. Hence this extra flag.
- */
- transient boolean firstMapRow;
- transient Configuration hiveConf;
- transient PTFInvocation ptfInvocation;
-
- /*
- * 1. Find out if the operator is invoked at Map-Side or Reduce-side
- * 2. Get the deserialized QueryDef
- * 3. Reconstruct the transient variables in QueryDef
- * 4. Create input partition to store rows coming from previous operator
- */
- @Override
- protected void initializeOp(Configuration jobConf) throws HiveException {
- hiveConf = jobConf;
- // if the parent is ExtractOperator, this invocation is from reduce-side
- isMapOperator = conf.isMapSide();
-
- reconstructQueryDef(hiveConf);
-
- if (isMapOperator) {
- PartitionedTableFunctionDef tDef = conf.getStartOfChain();
- outputObjInspector = tDef.getRawInputShape().getOI();
- } else {
- outputObjInspector = conf.getFuncDef().getOutputShape().getOI();
- }
-
- setupKeysWrapper(inputObjInspectors[0]);
-
- ptfInvocation = setupChain();
- ptfInvocation.initializeStreaming(jobConf, isMapOperator);
- firstMapRow = true;
-
- super.initializeOp(jobConf);
- }
-
- @Override
- protected void closeOp(boolean abort) throws HiveException {
- super.closeOp(abort);
+ transient KeyWrapperFactory keyWrapperFactory;
+ protected transient KeyWrapper currentKeys;
+ protected transient KeyWrapper newKeys;
+ /*
+ * for map-side invocation of PTFs, we cannot utilize the currentkeys null check
+ * to decide on invoking startPartition in streaming mode. Hence this extra flag.
+ */
+ transient boolean firstMapRow;
+ transient Configuration hiveConf;
+ transient PTFInvocation ptfInvocation;
+
+ /*
+ * 1. Find out if the operator is invoked at Map-Side or Reduce-side
+ * 2. Get the deserialized QueryDef
+ * 3. Reconstruct the transient variables in QueryDef
+ * 4. Create input partition to store rows coming from previous operator
+ */
+ @Override
+ protected void initializeOp(Configuration jobConf) throws HiveException {
+ hiveConf = jobConf;
+ // if the parent is ExtractOperator, this invocation is from reduce-side
+ isMapOperator = conf.isMapSide();
+
+ reconstructQueryDef(hiveConf);
+
+ if (isMapOperator) {
+ PartitionedTableFunctionDef tDef = conf.getStartOfChain();
+ outputObjInspector = tDef.getRawInputShape().getOI();
+ } else {
+ outputObjInspector = conf.getFuncDef().getOutputShape().getOI();
+ }
+
+ setupKeysWrapper(inputObjInspectors[0]);
+
+ ptfInvocation = setupChain();
+ ptfInvocation.initializeStreaming(jobConf, isMapOperator);
+ firstMapRow = true;
+
+ super.initializeOp(jobConf);
+ }
+
+ @Override
+ protected void closeOp(boolean abort) throws HiveException {
+ super.closeOp(abort);
ptfInvocation.finishPartition();
ptfInvocation.close();
}
- @Override
- public void processOp(Object row, int tag) throws HiveException
- {
- if (!isMapOperator ) {
+ @Override
+ public void processOp(Object row, int tag) throws HiveException {
+ if (!isMapOperator ) {
/*
* checkif current row belongs to the current accumulated Partition:
* - If not:
@@ -129,51 +128,51 @@ public class PTFOperator extends Operato
}
ptfInvocation.processRow(row);
- }
+ }
+
+ /**
+ * Initialize the visitor to use the QueryDefDeserializer Use the order
+ * defined in QueryDefWalker to visit the QueryDef
+ *
+ * @param hiveConf
+ * @throws HiveException
+ */
+ protected void reconstructQueryDef(Configuration hiveConf) throws HiveException {
+
+ PTFDeserializer dS =
+ new PTFDeserializer(conf, (StructObjectInspector)inputObjInspectors[0], hiveConf);
+ dS.initializePTFChain(conf.getFuncDef());
+ }
+
+ protected void setupKeysWrapper(ObjectInspector inputOI) throws HiveException {
+ PartitionDef pDef = conf.getStartOfChain().getPartition();
+ List<PTFExpressionDef> exprs = pDef.getExpressions();
+ int numExprs = exprs.size();
+ ExprNodeEvaluator[] keyFields = new ExprNodeEvaluator[numExprs];
+ ObjectInspector[] keyOIs = new ObjectInspector[numExprs];
+ ObjectInspector[] currentKeyOIs = new ObjectInspector[numExprs];
+
+ for(int i=0; i<numExprs; i++) {
+ PTFExpressionDef exprDef = exprs.get(i);
+ /*
+ * Why cannot we just use the ExprNodeEvaluator on the column?
+ * - because on the reduce-side it is initialized based on the rowOI of the HiveTable
+ * and not the OI of the ExtractOp ( the parent of this Operator on the reduce-side)
+ */
+ keyFields[i] = ExprNodeEvaluatorFactory.get(exprDef.getExprNode());
+ keyOIs[i] = keyFields[i].initialize(inputOI);
+ currentKeyOIs[i] =
+ ObjectInspectorUtils.getStandardObjectInspector(keyOIs[i],
+ ObjectInspectorCopyOption.WRITABLE);
+ }
+
+ keyWrapperFactory = new KeyWrapperFactory(keyFields, keyOIs, currentKeyOIs);
+ newKeys = keyWrapperFactory.getKeyWrapper();
+ }
- /**
- * Initialize the visitor to use the QueryDefDeserializer Use the order
- * defined in QueryDefWalker to visit the QueryDef
- *
- * @param hiveConf
- * @throws HiveException
- */
- protected void reconstructQueryDef(Configuration hiveConf) throws HiveException {
-
- PTFDeserializer dS =
- new PTFDeserializer(conf, (StructObjectInspector)inputObjInspectors[0], hiveConf);
- dS.initializePTFChain(conf.getFuncDef());
- }
-
- protected void setupKeysWrapper(ObjectInspector inputOI) throws HiveException {
- PartitionDef pDef = conf.getStartOfChain().getPartition();
- List<PTFExpressionDef> exprs = pDef.getExpressions();
- int numExprs = exprs.size();
- ExprNodeEvaluator[] keyFields = new ExprNodeEvaluator[numExprs];
- ObjectInspector[] keyOIs = new ObjectInspector[numExprs];
- ObjectInspector[] currentKeyOIs = new ObjectInspector[numExprs];
-
- for(int i=0; i<numExprs; i++) {
- PTFExpressionDef exprDef = exprs.get(i);
- /*
- * Why cannot we just use the ExprNodeEvaluator on the column?
- * - because on the reduce-side it is initialized based on the rowOI of the HiveTable
- * and not the OI of the ExtractOp ( the parent of this Operator on the reduce-side)
- */
- keyFields[i] = ExprNodeEvaluatorFactory.get(exprDef.getExprNode());
- keyOIs[i] = keyFields[i].initialize(inputOI);
- currentKeyOIs[i] =
- ObjectInspectorUtils.getStandardObjectInspector(keyOIs[i],
- ObjectInspectorCopyOption.WRITABLE);
- }
-
- keyWrapperFactory = new KeyWrapperFactory(keyFields, keyOIs, currentKeyOIs);
- newKeys = keyWrapperFactory.getKeyWrapper();
- }
-
- /**
- * @return the name of the operator
- */
+ /**
+ * @return the name of the operator
+ */
@Override
public String getName() {
return getOperatorName();
@@ -184,11 +183,11 @@ public class PTFOperator extends Operato
}
- @Override
- public OperatorType getType() {
- return OperatorType.PTF;
- }
-
+ @Override
+ public OperatorType getType() {
+ return OperatorType.PTF;
+ }
+
private PTFInvocation setupChain() {
Stack<PartitionedTableFunctionDef> fnDefs = new Stack<PartitionedTableFunctionDef>();
PTFInputDef iDef = conf.getFuncDef();
@@ -197,9 +196,9 @@ public class PTFOperator extends Operato
fnDefs.push((PartitionedTableFunctionDef) iDef);
iDef = ((PartitionedTableFunctionDef) iDef).getInput();
}
-
+
PTFInvocation curr = null, first = null;
-
+
while(!fnDefs.isEmpty()) {
PartitionedTableFunctionDef currFn = fnDefs.pop();
curr = new PTFInvocation(curr, currFn.getTFunction());
@@ -222,26 +221,26 @@ public class PTFOperator extends Operato
llFn.setpItr(pItr);
}
}
-
+
/*
* Responsible for the flow of rows through the PTF Chain.
- * An Invocation wraps a TableFunction.
- * The PTFOp hands the chain each row through the processRow call.
+ * An Invocation wraps a TableFunction.
+ * The PTFOp hands the chain each row through the processRow call.
* It also notifies the chain of when a Partition starts/finishes.
- *
+ *
* There are several combinations depending
* whether the TableFunction and its successor support Streaming or Batch mode.
- *
+ *
* Combination 1: Streaming + Streaming
* - Start Partition: invoke startPartition on tabFn.
- * - Process Row: invoke process Row on tabFn.
+ * - Process Row: invoke process Row on tabFn.
* Any output rows hand to next tabFn in chain or forward to next Operator.
* - Finish Partition: invoke finishPartition on tabFn.
* Any output rows hand to next tabFn in chain or forward to next Operator.
- *
+ *
* Combination 2: Streaming + Batch
* same as Combination 1
- *
+ *
* Combination 3: Batch + Batch
* - Start Partition: create or reset the Input Partition for the tabFn
* caveat is: if prev is also batch and it is not providing an Output Iterator
@@ -251,22 +250,22 @@ public class PTFOperator extends Operato
* If function gives an Output Partition: set it on next Invocation's Input Partition
* If function gives an Output Iterator: iterate and call processRow on next Invocation.
* For last Invocation in chain: forward rows to next Operator.
- *
+ *
* Combination 3: Batch + Stream
* Similar to Combination 3, except Finish Partition behavior slightly different
* - Finish Partition : invoke evaluate on tabFn on Input Partition
* iterate output rows: hand to next tabFn in chain or forward to next Operator.
- *
+ *
*/
class PTFInvocation {
-
+
PTFInvocation prev;
PTFInvocation next;
TableFunctionEvaluator tabFn;
PTFPartition inputPart;
PTFPartition outputPart;
Iterator<Object> outputPartRowsItr;
-
+
public PTFInvocation(PTFInvocation prev, TableFunctionEvaluator tabFn) {
this.prev = prev;
this.tabFn = tabFn;
@@ -274,19 +273,19 @@ public class PTFOperator extends Operato
prev.next = this;
}
}
-
+
boolean isOutputIterator() {
return tabFn.canAcceptInputAsStream() || tabFn.canIterateOutput();
}
-
+
boolean isStreaming() {
return tabFn.canAcceptInputAsStream();
}
-
+
void initializeStreaming(Configuration cfg, boolean isMapSide) throws HiveException {
PartitionedTableFunctionDef tabDef = tabFn.getTableDef();
PTFInputDef inputDef = tabDef.getInput();
- ObjectInspector inputOI = conf.getStartOfChain() == tabDef ?
+ ObjectInspector inputOI = conf.getStartOfChain() == tabDef ?
inputObjInspectors[0] : inputDef.getOutputShape().getOI();
tabFn.initializeStreaming(cfg, (StructObjectInspector) inputOI, isMapSide);
@@ -295,7 +294,7 @@ public class PTFOperator extends Operato
next.initializeStreaming(cfg, isMapSide);
}
}
-
+
void startPartition() throws HiveException {
if ( isStreaming() ) {
tabFn.startPartition();
@@ -312,7 +311,7 @@ public class PTFOperator extends Operato
next.startPartition();
}
}
-
+
void processRow(Object row) throws HiveException {
if ( isStreaming() ) {
handleOutputRows(tabFn.processRow(row));
@@ -320,7 +319,7 @@ public class PTFOperator extends Operato
inputPart.append(row);
}
}
-
+
void handleOutputRows(List<Object> outRows) throws HiveException {
if ( outRows != null ) {
for (Object orow : outRows ) {
@@ -332,7 +331,7 @@ public class PTFOperator extends Operato
}
}
}
-
+
void finishPartition() throws HiveException {
if ( isStreaming() ) {
handleOutputRows(tabFn.finishPartition());
@@ -353,7 +352,7 @@ public class PTFOperator extends Operato
}
}
}
-
+
if ( next != null ) {
next.finishPartition();
} else {
@@ -364,7 +363,7 @@ public class PTFOperator extends Operato
}
}
}
-
+
/**
* Create a new Partition.
* A partition has 2 OIs: the OI for the rows being put in and the OI for the rows
@@ -388,7 +387,7 @@ public class PTFOperator extends Operato
private void createInputPartition() throws HiveException {
PartitionedTableFunctionDef tabDef = tabFn.getTableDef();
PTFInputDef inputDef = tabDef.getInput();
- ObjectInspector inputOI = conf.getStartOfChain() == tabDef ?
+ ObjectInspector inputOI = conf.getStartOfChain() == tabDef ?
inputObjInspectors[0] : inputDef.getOutputShape().getOI();
SerDe serde = conf.isMapSide() ? tabDef.getInput().getOutputShape().getSerde() :
@@ -400,7 +399,7 @@ public class PTFOperator extends Operato
(StructObjectInspector) inputOI,
outputOI);
}
-
+
void close() {
if ( inputPart != null ) {
inputPart.close();
@@ -411,5 +410,5 @@ public class PTFOperator extends Operato
}
}
}
-
+
}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PartitionKeySampler.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PartitionKeySampler.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PartitionKeySampler.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PartitionKeySampler.java Thu Sep 4 02:49:46 2014
@@ -27,6 +27,8 @@ import java.util.Comparator;
import java.util.List;
import java.util.Random;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -45,6 +47,8 @@ import org.apache.hadoop.mapred.OutputCo
public class PartitionKeySampler implements OutputCollector<HiveKey, Object> {
+ private static final Log LOG = LogFactory.getLog(PartitionKeySampler.class);
+
public static final Comparator<byte[]> C = new Comparator<byte[]>() {
public final int compare(byte[] o1, byte[] o2) {
return WritableComparator.compareBytes(o1, 0, o1.length, o2, 0, o2.length);
@@ -74,32 +78,46 @@ public class PartitionKeySampler impleme
}
// sort and pick partition keys
- // copied from org.apache.hadoop.mapred.lib.InputSampler
+ // originally copied from org.apache.hadoop.mapred.lib.InputSampler but seemed to have a bug
private byte[][] getPartitionKeys(int numReduce) {
if (sampled.size() < numReduce - 1) {
throw new IllegalStateException("not enough number of sample");
}
byte[][] sorted = sampled.toArray(new byte[sampled.size()][]);
Arrays.sort(sorted, C);
- byte[][] partitionKeys = new byte[numReduce - 1][];
- float stepSize = sorted.length / (float) numReduce;
- int last = -1;
- for(int i = 1; i < numReduce; ++i) {
- int k = Math.round(stepSize * i);
- while (last >= k && C.compare(sorted[last], sorted[k]) == 0) {
- k++;
+
+ return toPartitionKeys(sorted, numReduce);
+ }
+
+ static final byte[][] toPartitionKeys(byte[][] sorted, int numPartition) {
+ byte[][] partitionKeys = new byte[numPartition - 1][];
+
+ int last = 0;
+ int current = 0;
+ for(int i = 0; i < numPartition - 1; i++) {
+ current += Math.round((float)(sorted.length - current) / (numPartition - i));
+ while (i > 0 && current < sorted.length && C.compare(sorted[last], sorted[current]) == 0) {
+ current++;
+ }
+ if (current >= sorted.length) {
+ return Arrays.copyOfRange(partitionKeys, 0, i);
}
- if (k >= sorted.length) {
- throw new IllegalStateException("not enough number of sample");
+ if (LOG.isDebugEnabled()) {
+ // print out nth partition key for debugging
+ LOG.debug("Partition key " + current + "th :" + new BytesWritable(sorted[current]));
}
- partitionKeys[i - 1] = sorted[k];
- last = k;
+ partitionKeys[i] = sorted[current];
+ last = current;
}
return partitionKeys;
}
- public void writePartitionKeys(Path path, JobConf job) throws IOException {
+ public void writePartitionKeys(Path path, HiveConf conf, JobConf job) throws IOException {
byte[][] partitionKeys = getPartitionKeys(job.getNumReduceTasks());
+ int numPartition = partitionKeys.length + 1;
+ if (numPartition != job.getNumReduceTasks()) {
+ job.setNumReduceTasks(numPartition);
+ }
FileSystem fs = path.getFileSystem(job);
SequenceFile.Writer writer = SequenceFile.createWriter(fs, job, path,
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PartitionTableFunctionDescription.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PartitionTableFunctionDescription.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PartitionTableFunctionDescription.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/PartitionTableFunctionDescription.java Thu Sep 4 02:49:46 2014
@@ -27,14 +27,13 @@ import java.lang.annotation.Target;
import org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction;
@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
+@Target(ElementType.TYPE)
@Documented
-public @interface PartitionTableFunctionDescription
-{
- Description description ();
+public @interface PartitionTableFunctionDescription {
+ Description description ();
- /**
- * if true it is not usable in the language. {@link WindowingTableFunction} is the only internal function.
- */
- boolean isInternal() default false;
+ /**
+ * if true it is not usable in the language. {@link WindowingTableFunction} is the only internal function.
+ */
+ boolean isInternal() default false;
}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java Thu Sep 4 02:49:46 2014
@@ -31,6 +31,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
+import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.conf.HiveConf;
@@ -157,12 +158,12 @@ public class ScriptOperator extends Oper
}
/**
- * Maps a relative pathname to an absolute pathname using the PATH enviroment.
+ * Maps a relative pathname to an absolute pathname using the PATH environment.
*/
public class PathFinder {
String pathenv; // a string of pathnames
- String pathSep; // the path seperator
- String fileSep; // the file seperator in a directory
+ String pathSep; // the path separator
+ String fileSep; // the file separator in a directory
/**
* Construct a PathFinder object using the path from the specified system
@@ -284,7 +285,7 @@ public class ScriptOperator extends Oper
@Override
public void processOp(Object row, int tag) throws HiveException {
- // initialize the user's process only when you recieve the first row
+ // initialize the user's process only when you receive the first row
if (firstRow) {
firstRow = false;
try {
@@ -358,7 +359,8 @@ public class ScriptOperator extends Oper
.getBoolVar(hconf, HiveConf.ConfVars.HIVESCRIPTAUTOPROGRESS)) {
autoProgressor = new AutoProgressor(this.getClass().getName(),
reporter, Utilities.getDefaultNotificationInterval(hconf),
- HiveConf.getIntVar(hconf, HiveConf.ConfVars.HIVES_AUTO_PROGRESS_TIMEOUT) * 1000);
+ HiveConf.getTimeVar(
+ hconf, HiveConf.ConfVars.HIVES_AUTO_PROGRESS_TIMEOUT, TimeUnit.MILLISECONDS));
autoProgressor.go();
}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/UDTFOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/UDTFOperator.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/UDTFOperator.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/UDTFOperator.java Thu Sep 4 02:49:46 2014
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.ql.exec;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -31,7 +32,6 @@ import org.apache.hadoop.hive.ql.plan.UD
import org.apache.hadoop.hive.ql.plan.api.OperatorType;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF;
import org.apache.hadoop.hive.ql.udf.generic.UDTFCollector;
-import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.StructField;
import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
@@ -86,7 +86,8 @@ public class UDTFOperator extends Operat
if (HiveConf.getBoolVar(hconf, HiveConf.ConfVars.HIVEUDTFAUTOPROGRESS)) {
autoProgressor = new AutoProgressor(this.getClass().getName(), reporter,
Utilities.getDefaultNotificationInterval(hconf),
- HiveConf.getIntVar(hconf, HiveConf.ConfVars.HIVES_AUTO_PROGRESS_TIMEOUT) * 1000);
+ HiveConf.getTimeVar(
+ hconf, HiveConf.ConfVars.HIVES_AUTO_PROGRESS_TIMEOUT, TimeUnit.MILLISECONDS));
autoProgressor.go();
}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java Thu Sep 4 02:49:46 2014
@@ -1363,8 +1363,8 @@ public final class Utilities {
codecClass = FileOutputFormat.getOutputCompressorClass(jc, DefaultCodec.class);
codec = (CompressionCodec) ReflectionUtils.newInstance(codecClass, jc);
}
- return (SequenceFile.createWriter(fs, jc, file, keyClass, valClass, compressionType, codec,
- progressable));
+ return SequenceFile.createWriter(fs, jc, file, keyClass, valClass, compressionType, codec,
+ progressable);
}
@@ -2743,7 +2743,7 @@ public final class Utilities {
* first time it is caught, or SQLTransientException when the maxRetries has reached.
*/
public static <T> T executeWithRetry(SQLCommand<T> cmd, PreparedStatement stmt,
- int baseWindow, int maxRetries) throws SQLException {
+ long baseWindow, int maxRetries) throws SQLException {
Random r = new Random();
T result = null;
@@ -2785,7 +2785,7 @@ public final class Utilities {
* first time it is caught, or SQLTransientException when the maxRetries has reached.
*/
public static Connection connectWithRetry(String connectionString,
- int waitWindow, int maxRetries) throws SQLException {
+ long waitWindow, int maxRetries) throws SQLException {
Random r = new Random();
@@ -2827,7 +2827,7 @@ public final class Utilities {
* first time it is caught, or SQLTransientException when the maxRetries has reached.
*/
public static PreparedStatement prepareWithRetry(Connection conn, String stmt,
- int waitWindow, int maxRetries) throws SQLException {
+ long waitWindow, int maxRetries) throws SQLException {
Random r = new Random();
@@ -2867,7 +2867,7 @@ public final class Utilities {
* @param r a random generator.
* @return number of milliseconds for the next wait time.
*/
- public static long getRandomWaitTime(int baseWindow, int failures, Random r) {
+ public static long getRandomWaitTime(long baseWindow, int failures, Random r) {
return (long) (
baseWindow * failures + // grace period for the last round of attempt
baseWindow * (failures + 1) * r.nextDouble()); // expanding time window for each failure
@@ -3376,7 +3376,7 @@ public final class Utilities {
/**
* Returns true if a plan is both configured for vectorized execution
* and vectorization is allowed. The plan may be configured for vectorization
- * but vectorization dissalowed eg. for FetchOperator execution.
+ * but vectorization disallowed eg. for FetchOperator execution.
*/
public static boolean isVectorMode(Configuration conf) {
if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_VECTORIZATION_ENABLED) &&
@@ -3525,7 +3525,7 @@ public final class Utilities {
return createDirsWithPermission(conf, mkdir, fsPermission, recursive);
}
- private static void resetConfAndCloseFS (Configuration conf, boolean unsetUmask,
+ private static void resetConfAndCloseFS (Configuration conf, boolean unsetUmask,
String origUmask, FileSystem fs) throws IOException {
if (unsetUmask) {
if (origUmask != null) {
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionDescription.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionDescription.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionDescription.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionDescription.java Thu Sep 4 02:49:46 2014
@@ -28,39 +28,38 @@ import org.apache.hadoop.hive.ql.udf.gen
import org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction;
@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
+@Target(ElementType.TYPE)
@Documented
-public @interface WindowFunctionDescription
-{
- Description description ();
- /**
- * controls whether this function can be applied to a Window.
- * <p>
- * Ranking function: Rank, Dense_Rank, Percent_Rank and Cume_Dist don't operate on Windows.
- * Why? a window specification implies a row specific range i.e. every row gets its own set of rows to process the UDAF on.
- * For ranking defining a set of rows for every row makes no sense.
- * <p>
- * All other UDAFs can be computed for a Window.
- */
- boolean supportsWindow() default true;
- /**
- * A WindowFunc is implemented as {@link GenericUDAFResolver2}. It returns only one value.
- * If this is true then the function must return a List which is taken to be the column for this function in the Output table returned by the
- * {@link WindowingTableFunction}. Otherwise the output is assumed to be a single value, the column of the Output will contain the same value
- * for all the rows.
- */
- boolean pivotResult() default false;
+public @interface WindowFunctionDescription {
+ Description description ();
+ /**
+ * controls whether this function can be applied to a Window.
+ * <p>
+ * Ranking function: Rank, Dense_Rank, Percent_Rank and Cume_Dist don't operate on Windows.
+ * Why? a window specification implies a row specific range i.e. every row gets its own set of rows to process the UDAF on.
+ * For ranking defining a set of rows for every row makes no sense.
+ * <p>
+ * All other UDAFs can be computed for a Window.
+ */
+ boolean supportsWindow() default true;
+ /**
+ * A WindowFunc is implemented as {@link GenericUDAFResolver2}. It returns only one value.
+ * If this is true then the function must return a List which is taken to be the column for this function in the Output table returned by the
+ * {@link WindowingTableFunction}. Otherwise the output is assumed to be a single value, the column of the Output will contain the same value
+ * for all the rows.
+ */
+ boolean pivotResult() default false;
- /**
- * Used in translations process to validate arguments
- * @return true if ranking function
- */
- boolean rankingFunction() default false;
+ /**
+ * Used in translations process to validate arguments
+ * @return true if ranking function
+ */
+ boolean rankingFunction() default false;
- /**
- * Using in analytical functions to specify that UDF implies an ordering
- * @return true if the function implies order
- */
- boolean impliesOrder() default false;
+ /**
+ * Using in analytical functions to specify that UDF implies an ordering
+ * @return true if the function implies order
+ */
+ boolean impliesOrder() default false;
}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionInfo.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionInfo.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionInfo.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionInfo.java Thu Sep 4 02:49:46 2014
@@ -22,45 +22,39 @@ import org.apache.hadoop.hive.ql.udf.gen
import org.apache.hive.common.util.AnnotationUtils;
@SuppressWarnings("deprecation")
-public class WindowFunctionInfo implements CommonFunctionInfo
-{
- boolean supportsWindow = true;
- boolean pivotResult = false;
- boolean impliesOrder = false;
- FunctionInfo fInfo;
-
- WindowFunctionInfo(FunctionInfo fInfo)
- {
- assert fInfo.isGenericUDAF();
- this.fInfo = fInfo;
- Class<? extends GenericUDAFResolver> wfnCls = fInfo.getGenericUDAFResolver().getClass();
- WindowFunctionDescription def =
+public class WindowFunctionInfo implements CommonFunctionInfo {
+ boolean supportsWindow = true;
+ boolean pivotResult = false;
+ boolean impliesOrder = false;
+ FunctionInfo fInfo;
+
+ WindowFunctionInfo(FunctionInfo fInfo) {
+ assert fInfo.isGenericUDAF();
+ this.fInfo = fInfo;
+ Class<? extends GenericUDAFResolver> wfnCls = fInfo.getGenericUDAFResolver().getClass();
+ WindowFunctionDescription def =
AnnotationUtils.getAnnotation(wfnCls, WindowFunctionDescription.class);
- if ( def != null)
- {
- supportsWindow = def.supportsWindow();
- pivotResult = def.pivotResult();
- impliesOrder = def.impliesOrder();
- }
- }
-
- public boolean isSupportsWindow()
- {
- return supportsWindow;
- }
-
- public boolean isPivotResult()
- {
- return pivotResult;
- }
-
- public boolean isImpliesOrder(){
- return impliesOrder;
- }
- public FunctionInfo getfInfo()
- {
- return fInfo;
- }
+ if ( def != null) {
+ supportsWindow = def.supportsWindow();
+ pivotResult = def.pivotResult();
+ impliesOrder = def.impliesOrder();
+ }
+ }
+
+ public boolean isSupportsWindow() {
+ return supportsWindow;
+ }
+
+ public boolean isPivotResult() {
+ return pivotResult;
+ }
+
+ public boolean isImpliesOrder() {
+ return impliesOrder;
+ }
+ public FunctionInfo getfInfo() {
+ return fInfo;
+ }
@Override
public Class<?> getFunctionClass() {
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mapjoin/MapJoinMemoryExhaustionHandler.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mapjoin/MapJoinMemoryExhaustionHandler.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mapjoin/MapJoinMemoryExhaustionHandler.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mapjoin/MapJoinMemoryExhaustionHandler.java Thu Sep 4 02:49:46 2014
@@ -63,7 +63,7 @@ public class MapJoinMemoryExhaustionHand
if(maxHeapSize == -1) {
this.maxHeapSize = 200L * 1024L * 1024L;
LOG.warn("MemoryMXBean.getHeapMemoryUsage().getMax() returned -1, " +
- "defaulting maxHeapSize to 200MB");
+ "defaulting maxHeapSize to 200MB");
} else {
this.maxHeapSize = maxHeapSize;
}
@@ -91,4 +91,4 @@ public class MapJoinMemoryExhaustionHand
throw new MapJoinMemoryExhaustionException(msg);
}
}
-}
\ No newline at end of file
+}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecDriver.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecDriver.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecDriver.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecDriver.java Thu Sep 4 02:49:46 2014
@@ -371,7 +371,7 @@ public class ExecDriver extends Task<Map
Utilities.setMapRedWork(job, work, ctx.getMRTmpPath());
- if (mWork.getSamplingType() > 0 && rWork != null && rWork.getNumReduceTasks() > 1) {
+ if (mWork.getSamplingType() > 0 && rWork != null && job.getNumReduceTasks() > 1) {
try {
handleSampling(driverContext, mWork, job, conf);
job.setPartitionerClass(HiveTotalOrderPartitioner.class);
@@ -539,7 +539,7 @@ public class ExecDriver extends Task<Map
} else {
throw new IllegalArgumentException("Invalid sampling type " + mWork.getSamplingType());
}
- sampler.writePartitionKeys(partitionFile, job);
+ sampler.writePartitionKeys(partitionFile, conf, job);
}
/**
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HadoopJobExecHelper.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HadoopJobExecHelper.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HadoopJobExecHelper.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HadoopJobExecHelper.java Thu Sep 4 02:49:46 2014
@@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -219,8 +220,8 @@ public class HadoopJobExecHelper {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
//DecimalFormat longFormatter = new DecimalFormat("###,###");
long reportTime = System.currentTimeMillis();
- long maxReportInterval =
- HiveConf.getLongVar(job, HiveConf.ConfVars.HIVE_LOG_INCREMENTAL_PLAN_PROGRESS_INTERVAL);
+ long maxReportInterval = HiveConf.getTimeVar(
+ job, HiveConf.ConfVars.HIVE_LOG_INCREMENTAL_PLAN_PROGRESS_INTERVAL, TimeUnit.MILLISECONDS);
boolean fatal = false;
StringBuilder errMsg = new StringBuilder();
long pullInterval = HiveConf.getLongVar(job, HiveConf.ConfVars.HIVECOUNTERSPULLINTERVAL);
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinTableContainerSerDe.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinTableContainerSerDe.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinTableContainerSerDe.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinTableContainerSerDe.java Thu Sep 4 02:49:46 2014
@@ -32,7 +32,7 @@ import org.apache.hadoop.io.Writable;
@SuppressWarnings("deprecation")
public class MapJoinTableContainerSerDe {
-
+
private final MapJoinObjectSerDeContext keyContext;
private final MapJoinObjectSerDeContext valueContext;
public MapJoinTableContainerSerDe(MapJoinObjectSerDeContext keyContext,
@@ -70,7 +70,7 @@ public class MapJoinTableContainerSerDe
}
try {
Writable keyContainer = keySerDe.getSerializedClass().newInstance();
- Writable valueContainer = valueSerDe.getSerializedClass().newInstance();
+ Writable valueContainer = valueSerDe.getSerializedClass().newInstance();
int numKeys = in.readInt();
for (int keyIndex = 0; keyIndex < numKeys; keyIndex++) {
MapJoinKeyObject key = new MapJoinKeyObject();
@@ -89,7 +89,7 @@ public class MapJoinTableContainerSerDe
public void persist(ObjectOutputStream out, MapJoinPersistableTableContainer tableContainer)
throws HiveException {
int numKeys = tableContainer.size();
- try {
+ try {
out.writeUTF(tableContainer.getClass().getName());
out.writeObject(tableContainer.getMetaData());
out.writeInt(numKeys);
@@ -108,7 +108,7 @@ public class MapJoinTableContainerSerDe
throw new ConcurrentModificationException("TableContainer was modified while persisting: " + tableContainer);
}
}
-
+
public static void persistDummyTable(ObjectOutputStream out) throws IOException {
MapJoinPersistableTableContainer tableContainer = new HashMapWrapper();
out.writeUTF(tableContainer.getClass().getName());
@@ -127,8 +127,8 @@ public class MapJoinTableContainerSerDe
return constructor.newInstance(metaData);
} catch (Exception e) {
String msg = "Error while attemping to create table container" +
- " of type: " + name + ", with metaData: " + metaData;
+ " of type: " + name + ", with metaData: " + metaData;
throw new HiveException(msg, e);
}
}
-}
\ No newline at end of file
+}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/PTFRowContainer.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/PTFRowContainer.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/PTFRowContainer.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/PTFRowContainer.java Thu Sep 4 02:49:46 2014
@@ -270,7 +270,7 @@ public class PTFRowContainer<Row extends
FileSystem fs = finalOutPath.getFileSystem(jc);
final SequenceFile.Writer outStream = Utilities.createSequenceWriter(jc, fs, finalOutPath,
- BytesWritable.class, valueClass, isCompressed, progress);
+ BytesWritable.class, valueClass, isCompressed, progress);
return new PTFRecordWriter(outStream);
}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DagUtils.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DagUtils.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DagUtils.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DagUtils.java Thu Sep 4 02:49:46 2014
@@ -29,6 +29,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import javax.security.auth.login.LoginException;
@@ -95,7 +96,6 @@ import org.apache.tez.dag.api.ProcessorD
import org.apache.tez.dag.api.TezException;
import org.apache.tez.dag.api.Vertex;
import org.apache.tez.dag.api.VertexGroup;
-import org.apache.tez.dag.api.VertexLocationHint;
import org.apache.tez.dag.api.VertexManagerPluginDescriptor;
import org.apache.tez.dag.library.vertexmanager.ShuffleVertexManager;
import org.apache.tez.mapreduce.hadoop.InputSplitInfo;
@@ -131,7 +131,7 @@ public class DagUtils {
private void addCredentials(MapWork mapWork, DAG dag) {
Set<String> paths = mapWork.getPathToAliases().keySet();
- if (paths != null && !paths.isEmpty()) {
+ if (!paths.isEmpty()) {
Iterator<URI> pathIterator = Iterators.transform(paths.iterator(), new Function<String, URI>() {
@Override
public URI apply(String input) {
@@ -201,6 +201,12 @@ public class DagUtils {
inpFormat = CombineHiveInputFormat.class.getName();
}
+ if (mapWork.getDummyTableScan()) {
+ // hive input format doesn't handle the special condition of no paths + 1
+ // split correctly.
+ inpFormat = CombineHiveInputFormat.class.getName();
+ }
+
conf.set(TEZ_TMP_DIR_KEY, context.getMRTmpPath().toUri().toString());
conf.set("mapred.mapper.class", ExecMapper.class.getName());
conf.set("mapred.input.format.class", inpFormat);
@@ -710,7 +716,7 @@ public class DagUtils {
/**
* Localizes files, archives and jars from a provided array of names.
- * @param hdfsDirPathStr Destination directoty in HDFS.
+ * @param hdfsDirPathStr Destination directory in HDFS.
* @param conf Configuration.
* @param inputOutputJars The file names to localize.
* @return List<LocalResource> local resources to add to execution
@@ -784,7 +790,7 @@ public class DagUtils {
}
/**
- * @param pathStr - the string from which we try to determine the resource base name
+ * @param path - the path from which we try to determine the resource base name
* @return the name of the resource from a given path string.
*/
public String getResourceBaseName(Path path) {
@@ -830,9 +836,8 @@ public class DagUtils {
int waitAttempts =
conf.getInt(HiveConf.ConfVars.HIVE_LOCALIZE_RESOURCE_NUM_WAIT_ATTEMPTS.varname,
HiveConf.ConfVars.HIVE_LOCALIZE_RESOURCE_NUM_WAIT_ATTEMPTS.defaultIntVal);
- long sleepInterval =
- conf.getLong(HiveConf.ConfVars.HIVE_LOCALIZE_RESOURCE_WAIT_INTERVAL.varname,
- HiveConf.ConfVars.HIVE_LOCALIZE_RESOURCE_WAIT_INTERVAL.defaultLongVal);
+ long sleepInterval = HiveConf.getTimeVar(
+ conf, HiveConf.ConfVars.HIVE_LOCALIZE_RESOURCE_WAIT_INTERVAL, TimeUnit.MILLISECONDS);
LOG.info("Number of wait attempts: " + waitAttempts + ". Wait interval: "
+ sleepInterval);
boolean found = false;
@@ -919,7 +924,6 @@ public class DagUtils {
* @param work The instance of BaseWork representing the actual work to be performed
* by this vertex.
* @param scratchDir HDFS scratch dir for this execution unit.
- * @param list
* @param appJarLr Local resource for hive-exec.
* @param additionalLr
* @param fileSystem FS corresponding to scratchDir and LocalResources
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorHashKeyWrapper.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorHashKeyWrapper.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorHashKeyWrapper.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorHashKeyWrapper.java Thu Sep 4 02:49:46 2014
@@ -146,7 +146,7 @@ public class VectorHashKeyWrapper extend
duplicateTo(clone);
return clone;
}
-
+
public void duplicateTo(VectorHashKeyWrapper clone) {
clone.longValues = longValues.clone();
clone.doubleValues = doubleValues.clone();
@@ -155,7 +155,7 @@ public class VectorHashKeyWrapper extend
// Decimal128 requires deep clone
clone.decimalValues = new Decimal128[decimalValues.length];
for(int i = 0; i < decimalValues.length; ++i) {
- clone.decimalValues[i] = new Decimal128().update(decimalValues[i]);
+ clone.decimalValues[i] = new Decimal128().update(decimalValues[i]);
}
clone.byteValues = new byte[byteValues.length][];
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java Thu Sep 4 02:49:46 2014
@@ -325,11 +325,11 @@ public class VectorizationContext {
childExpressions, mode, exprDesc.getTypeInfo());
}
} else if (exprDesc instanceof ExprNodeNullDesc) {
- ve = getConstantVectorExpression(null, exprDesc.getTypeInfo(), mode);
+ ve = getConstantVectorExpression(null, exprDesc.getTypeInfo(), mode);
} else if (exprDesc instanceof ExprNodeConstantDesc) {
ve = getConstantVectorExpression(((ExprNodeConstantDesc) exprDesc).getValue(), exprDesc.getTypeInfo(),
mode);
- }
+ }
if (ve == null) {
throw new HiveException("Could not vectorize expression: "+exprDesc.getName());
}
@@ -413,8 +413,8 @@ public class VectorizationContext {
}
}
} else {
- for (ExprNodeDesc child : children) {
- ExprNodeDesc castExpression = getImplicitCastExpression(genericUDF, child, commonType);
+ for (ExprNodeDesc child : children) {
+ ExprNodeDesc castExpression = getImplicitCastExpression(genericUDF, child, commonType);
if (castExpression != null) {
atleastOneCastNeeded = true;
childrenWithCasts.add(castExpression);
@@ -515,7 +515,7 @@ public class VectorizationContext {
}
return null;
}
-
+
private int getPrecisionForType(PrimitiveTypeInfo typeInfo) {
if (isFloatFamily(typeInfo.getTypeName())) {
return HiveDecimal.MAX_PRECISION;
@@ -572,8 +572,8 @@ public class VectorizationContext {
((GenericUDFBridge) genericUdf).setUdfClassName(udfClass.getClass().getName());
}
if (genericUdf instanceof SettableUDF) {
- ((SettableUDF)genericUdf).setTypeInfo(castType);
- }
+ ((SettableUDF) genericUdf).setTypeInfo(castType);
+ }
return genericUdf;
}
@@ -662,63 +662,63 @@ public class VectorizationContext {
* @throws HiveException
*/
ExprNodeDesc evaluateCastOnConstants(ExprNodeDesc exprDesc) throws HiveException {
- if (!(exprDesc instanceof ExprNodeGenericFuncDesc)) {
- return exprDesc;
- }
-
- if (exprDesc.getChildren() == null || (exprDesc.getChildren().size() != 1) ) {
- return exprDesc;
- }
-
- ExprNodeConstantDesc foldedChild = null;
- if (!( exprDesc.getChildren().get(0) instanceof ExprNodeConstantDesc)) {
-
- // try recursive folding
- ExprNodeDesc expr = evaluateCastOnConstants(exprDesc.getChildren().get(0));
- if (expr instanceof ExprNodeConstantDesc) {
- foldedChild = (ExprNodeConstantDesc) expr;
- }
- } else {
- foldedChild = (ExprNodeConstantDesc) exprDesc.getChildren().get(0);
- }
-
- if (foldedChild == null) {
- return exprDesc;
- }
-
- ObjectInspector childoi = foldedChild.getWritableObjectInspector();
- GenericUDF gudf = ((ExprNodeGenericFuncDesc) exprDesc).getGenericUDF();
-
- // Only evaluate +ve/-ve or cast on constant or recursive casting.
- if (gudf instanceof GenericUDFOPNegative || gudf instanceof GenericUDFOPPositive ||
- castExpressionUdfs.contains(gudf.getClass())
- || ((gudf instanceof GenericUDFBridge)
- && castExpressionUdfs.contains(((GenericUDFBridge) gudf).getUdfClass()))) {
- ExprNodeEvaluator<?> evaluator = ExprNodeEvaluatorFactory.get(exprDesc);
- ObjectInspector output = evaluator.initialize(childoi);
- Object constant = evaluator.evaluate(null);
- Object java = ObjectInspectorUtils.copyToStandardJavaObject(constant, output);
- return new ExprNodeConstantDesc(exprDesc.getTypeInfo(), java);
- }
-
- return exprDesc;
+ if (!(exprDesc instanceof ExprNodeGenericFuncDesc)) {
+ return exprDesc;
+ }
+
+ if (exprDesc.getChildren() == null || (exprDesc.getChildren().size() != 1) ) {
+ return exprDesc;
+ }
+
+ ExprNodeConstantDesc foldedChild = null;
+ if (!( exprDesc.getChildren().get(0) instanceof ExprNodeConstantDesc)) {
+
+ // try recursive folding
+ ExprNodeDesc expr = evaluateCastOnConstants(exprDesc.getChildren().get(0));
+ if (expr instanceof ExprNodeConstantDesc) {
+ foldedChild = (ExprNodeConstantDesc) expr;
+ }
+ } else {
+ foldedChild = (ExprNodeConstantDesc) exprDesc.getChildren().get(0);
+ }
+
+ if (foldedChild == null) {
+ return exprDesc;
+ }
+
+ ObjectInspector childoi = foldedChild.getWritableObjectInspector();
+ GenericUDF gudf = ((ExprNodeGenericFuncDesc) exprDesc).getGenericUDF();
+
+ // Only evaluate +ve/-ve or cast on constant or recursive casting.
+ if (gudf instanceof GenericUDFOPNegative || gudf instanceof GenericUDFOPPositive ||
+ castExpressionUdfs.contains(gudf.getClass())
+ || ((gudf instanceof GenericUDFBridge)
+ && castExpressionUdfs.contains(((GenericUDFBridge) gudf).getUdfClass()))) {
+ ExprNodeEvaluator<?> evaluator = ExprNodeEvaluatorFactory.get(exprDesc);
+ ObjectInspector output = evaluator.initialize(childoi);
+ Object constant = evaluator.evaluate(null);
+ Object java = ObjectInspectorUtils.copyToStandardJavaObject(constant, output);
+ return new ExprNodeConstantDesc(exprDesc.getTypeInfo(), java);
+ }
+
+ return exprDesc;
}
-
+
/* For cast on constant operator in all members of the input list and return new list
* containing results.
*/
private List<ExprNodeDesc> evaluateCastOnConstants(List<ExprNodeDesc> childExpr)
- throws HiveException {
- List<ExprNodeDesc> evaluatedChildren = new ArrayList<ExprNodeDesc>();
- if (childExpr != null) {
+ throws HiveException {
+ List<ExprNodeDesc> evaluatedChildren = new ArrayList<ExprNodeDesc>();
+ if (childExpr != null) {
for (ExprNodeDesc expr : childExpr) {
- expr = this.evaluateCastOnConstants(expr);
- evaluatedChildren.add(expr);
+ expr = this.evaluateCastOnConstants(expr);
+ evaluatedChildren.add(expr);
}
- }
- return evaluatedChildren;
+ }
+ return evaluatedChildren;
}
-
+
private VectorExpression getConstantVectorExpression(Object constantValue, TypeInfo typeInfo,
Mode mode) throws HiveException {
String type = typeInfo.getTypeName();
@@ -728,7 +728,7 @@ public class VectorizationContext {
outCol = ocm.allocateOutputColumn(colVectorType);
}
if (constantValue == null) {
- return new ConstantVectorExpression(outCol, type, true);
+ return new ConstantVectorExpression(outCol, type, true);
} else if (decimalTypePattern.matcher(type).matches()) {
VectorExpression ve = new ConstantVectorExpression(outCol, (Decimal128) constantValue);
ve.setOutputType(typeInfo.getTypeName());
@@ -907,9 +907,9 @@ public class VectorizationContext {
private VectorExpression getGenericUdfVectorExpression(GenericUDF udf,
List<ExprNodeDesc> childExpr, Mode mode, TypeInfo returnType) throws HiveException {
- List<ExprNodeDesc> castedChildren = evaluateCastOnConstants(childExpr);
- childExpr = castedChildren;
-
+ List<ExprNodeDesc> castedChildren = evaluateCastOnConstants(childExpr);
+ childExpr = castedChildren;
+
//First handle special cases
if (udf instanceof GenericUDFBetween) {
return getBetweenFilterExpression(childExpr, mode, returnType);
@@ -933,8 +933,8 @@ public class VectorizationContext {
}
} else if (udf instanceof GenericUDFToDecimal) {
return getCastToDecimal(childExpr, returnType);
- }
-
+ }
+
// Now do a general lookup
Class<?> udfClass = udf.getClass();
if (udf instanceof GenericUDFBridge) {
@@ -1003,7 +1003,7 @@ public class VectorizationContext {
}
}
}
-
+
/**
* Create a filter or boolean-valued expression for column IN ( <list-of-constants> )
*/
@@ -1014,8 +1014,8 @@ public class VectorizationContext {
String colType = colExpr.getTypeString();
// prepare arguments for createVectorExpression
- List<ExprNodeDesc> childrenForInList = evaluateCastOnConstants(childExpr.subList(1, childExpr.size()));
-
+ List<ExprNodeDesc> childrenForInList = evaluateCastOnConstants(childExpr.subList(1, childExpr.size()));
+
/* This method assumes that the IN list has no NULL entries. That is enforced elsewhere,
* in the Vectorizer class. If NULL is passed in as a list entry, behavior is not defined.
* If in the future, NULL values are allowed in the IN list, be sure to handle 3-valued
@@ -1110,105 +1110,105 @@ public class VectorizationContext {
return getCastToString(childExpr, returnType);
}
return null;
- }
-
+ }
+
private Decimal128 castConstantToDecimal(Object scalar, TypeInfo type) throws HiveException {
- PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) type;
- String typename = type.getTypeName();
- Decimal128 d = new Decimal128();
- int scale = HiveDecimalUtils.getScaleForType(ptinfo);
- switch (ptinfo.getPrimitiveCategory()) {
- case FLOAT:
- float floatVal = ((Float) scalar).floatValue();
- d.update(floatVal, (short) scale);
- break;
- case DOUBLE:
- double doubleVal = ((Double) scalar).doubleValue();
- d.update(doubleVal, (short) scale);
- break;
- case BYTE:
- byte byteVal = ((Byte) scalar).byteValue();
- d.update(byteVal, (short) scale);
- break;
- case SHORT:
- short shortVal = ((Short) scalar).shortValue();
- d.update(shortVal, (short) scale);
- break;
- case INT:
- int intVal = ((Integer) scalar).intValue();
- d.update(intVal, (short) scale);
- break;
- case LONG:
- long longVal = ((Long) scalar).longValue();
- d.update(longVal, (short) scale);
- break;
- case DECIMAL:
- HiveDecimal decimalVal = (HiveDecimal) scalar;
- d.update(decimalVal.unscaledValue(), (short) scale);
- break;
- default:
- throw new HiveException("Unsupported type "+typename+" for cast to Decimal128");
- }
- return d;
+ PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) type;
+ String typename = type.getTypeName();
+ Decimal128 d = new Decimal128();
+ int scale = HiveDecimalUtils.getScaleForType(ptinfo);
+ switch (ptinfo.getPrimitiveCategory()) {
+ case FLOAT:
+ float floatVal = ((Float) scalar).floatValue();
+ d.update(floatVal, (short) scale);
+ break;
+ case DOUBLE:
+ double doubleVal = ((Double) scalar).doubleValue();
+ d.update(doubleVal, (short) scale);
+ break;
+ case BYTE:
+ byte byteVal = ((Byte) scalar).byteValue();
+ d.update(byteVal, (short) scale);
+ break;
+ case SHORT:
+ short shortVal = ((Short) scalar).shortValue();
+ d.update(shortVal, (short) scale);
+ break;
+ case INT:
+ int intVal = ((Integer) scalar).intValue();
+ d.update(intVal, (short) scale);
+ break;
+ case LONG:
+ long longVal = ((Long) scalar).longValue();
+ d.update(longVal, (short) scale);
+ break;
+ case DECIMAL:
+ HiveDecimal decimalVal = (HiveDecimal) scalar;
+ d.update(decimalVal.unscaledValue(), (short) scale);
+ break;
+ default:
+ throw new HiveException("Unsupported type "+typename+" for cast to Decimal128");
+ }
+ return d;
}
private String castConstantToString(Object scalar, TypeInfo type) throws HiveException {
- PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) type;
- String typename = type.getTypeName();
- switch (ptinfo.getPrimitiveCategory()) {
- case FLOAT:
- case DOUBLE:
- case BYTE:
- case SHORT:
- case INT:
- case LONG:
- return ((Number) scalar).toString();
- case DECIMAL:
- HiveDecimal decimalVal = (HiveDecimal) scalar;
- return decimalVal.toString();
- default:
- throw new HiveException("Unsupported type "+typename+" for cast to String");
- }
+ PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) type;
+ String typename = type.getTypeName();
+ switch (ptinfo.getPrimitiveCategory()) {
+ case FLOAT:
+ case DOUBLE:
+ case BYTE:
+ case SHORT:
+ case INT:
+ case LONG:
+ return ((Number) scalar).toString();
+ case DECIMAL:
+ HiveDecimal decimalVal = (HiveDecimal) scalar;
+ return decimalVal.toString();
+ default:
+ throw new HiveException("Unsupported type "+typename+" for cast to String");
+ }
}
private Double castConstantToDouble(Object scalar, TypeInfo type) throws HiveException {
- PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) type;
- String typename = type.getTypeName();
- switch (ptinfo.getPrimitiveCategory()) {
- case FLOAT:
- case DOUBLE:
- case BYTE:
- case SHORT:
- case INT:
- case LONG:
- return ((Number) scalar).doubleValue();
- case DECIMAL:
- HiveDecimal decimalVal = (HiveDecimal) scalar;
- return decimalVal.doubleValue();
- default:
- throw new HiveException("Unsupported type "+typename+" for cast to Double");
- }
- }
+ PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) type;
+ String typename = type.getTypeName();
+ switch (ptinfo.getPrimitiveCategory()) {
+ case FLOAT:
+ case DOUBLE:
+ case BYTE:
+ case SHORT:
+ case INT:
+ case LONG:
+ return ((Number) scalar).doubleValue();
+ case DECIMAL:
+ HiveDecimal decimalVal = (HiveDecimal) scalar;
+ return decimalVal.doubleValue();
+ default:
+ throw new HiveException("Unsupported type "+typename+" for cast to Double");
+ }
+ }
private Long castConstantToLong(Object scalar, TypeInfo type) throws HiveException {
- PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) type;
- String typename = type.getTypeName();
- switch (ptinfo.getPrimitiveCategory()) {
- case FLOAT:
- case DOUBLE:
- case BYTE:
- case SHORT:
- case INT:
- case LONG:
- return ((Number) scalar).longValue();
- case DECIMAL:
- HiveDecimal decimalVal = (HiveDecimal) scalar;
- return decimalVal.longValue();
- default:
- throw new HiveException("Unsupported type "+typename+" for cast to Long");
- }
- }
-
+ PrimitiveTypeInfo ptinfo = (PrimitiveTypeInfo) type;
+ String typename = type.getTypeName();
+ switch (ptinfo.getPrimitiveCategory()) {
+ case FLOAT:
+ case DOUBLE:
+ case BYTE:
+ case SHORT:
+ case INT:
+ case LONG:
+ return ((Number) scalar).longValue();
+ case DECIMAL:
+ HiveDecimal decimalVal = (HiveDecimal) scalar;
+ return decimalVal.longValue();
+ default:
+ throw new HiveException("Unsupported type "+typename+" for cast to Long");
+ }
+ }
+
private VectorExpression getCastToDecimal(List<ExprNodeDesc> childExpr, TypeInfo returnType)
throws HiveException {
ExprNodeDesc child = childExpr.get(0);
@@ -1217,9 +1217,9 @@ public class VectorizationContext {
// Return a constant vector expression
Object constantValue = ((ExprNodeConstantDesc) child).getValue();
Decimal128 decimalValue = castConstantToDecimal(constantValue, child.getTypeInfo());
- return getConstantVectorExpression(decimalValue, returnType, Mode.PROJECTION);
+ return getConstantVectorExpression(decimalValue, returnType, Mode.PROJECTION);
} else if (child instanceof ExprNodeNullDesc) {
- return getConstantVectorExpression(null, returnType, Mode.PROJECTION);
+ return getConstantVectorExpression(null, returnType, Mode.PROJECTION);
}
if (isIntFamily(inputType)) {
return createVectorExpression(CastLongToDecimal.class, childExpr, Mode.PROJECTION, returnType);
@@ -1234,8 +1234,8 @@ public class VectorizationContext {
return createVectorExpression(CastTimestampToDecimal.class, childExpr, Mode.PROJECTION, returnType);
}
throw new HiveException("Unhandled cast input type: " + inputType);
- }
-
+ }
+
private VectorExpression getCastToString(List<ExprNodeDesc> childExpr, TypeInfo returnType)
throws HiveException {
ExprNodeDesc child = childExpr.get(0);
@@ -1244,9 +1244,9 @@ public class VectorizationContext {
// Return a constant vector expression
Object constantValue = ((ExprNodeConstantDesc) child).getValue();
String strValue = castConstantToString(constantValue, child.getTypeInfo());
- return getConstantVectorExpression(strValue, returnType, Mode.PROJECTION);
+ return getConstantVectorExpression(strValue, returnType, Mode.PROJECTION);
} else if (child instanceof ExprNodeNullDesc) {
- return getConstantVectorExpression(null, returnType, Mode.PROJECTION);
+ return getConstantVectorExpression(null, returnType, Mode.PROJECTION);
}
if (inputType.equals("boolean")) {
// Boolean must come before the integer family. It's a special case.
@@ -1273,9 +1273,9 @@ public class VectorizationContext {
// Return a constant vector expression
Object constantValue = ((ExprNodeConstantDesc) child).getValue();
Double doubleValue = castConstantToDouble(constantValue, child.getTypeInfo());
- return getConstantVectorExpression(doubleValue, returnType, Mode.PROJECTION);
+ return getConstantVectorExpression(doubleValue, returnType, Mode.PROJECTION);
} else if (child instanceof ExprNodeNullDesc) {
- return getConstantVectorExpression(null, returnType, Mode.PROJECTION);
+ return getConstantVectorExpression(null, returnType, Mode.PROJECTION);
}
if (isIntFamily(inputType)) {
return createVectorExpression(CastLongToDouble.class, childExpr, Mode.PROJECTION, returnType);
@@ -1286,7 +1286,7 @@ public class VectorizationContext {
// float types require no conversion, so use a no-op
return getIdentityExpression(childExpr);
- }
+ }
// The string type is deliberately omitted -- it's handled elsewhere. See isLegacyPathUDF.
return null;
@@ -1301,7 +1301,7 @@ public class VectorizationContext {
// Family of related JIRAs: HIVE-7421, HIVE-7422, and HIVE-7424.
return null;
} else if (child instanceof ExprNodeNullDesc) {
- return getConstantVectorExpression(null, TypeInfoFactory.booleanTypeInfo, Mode.PROJECTION);
+ return getConstantVectorExpression(null, TypeInfoFactory.booleanTypeInfo, Mode.PROJECTION);
}
// Long and double are handled using descriptors, string needs to be specially handled.
if (inputType.equals("string")) {
@@ -1329,9 +1329,9 @@ public class VectorizationContext {
// Return a constant vector expression
Object constantValue = ((ExprNodeConstantDesc) child).getValue();
Long longValue = castConstantToLong(constantValue, child.getTypeInfo());
- return getConstantVectorExpression(longValue, TypeInfoFactory.longTypeInfo, Mode.PROJECTION);
+ return getConstantVectorExpression(longValue, TypeInfoFactory.longTypeInfo, Mode.PROJECTION);
} else if (child instanceof ExprNodeNullDesc) {
- return getConstantVectorExpression(null, TypeInfoFactory.longTypeInfo, Mode.PROJECTION);
+ return getConstantVectorExpression(null, TypeInfoFactory.longTypeInfo, Mode.PROJECTION);
}
// Float family, timestamp are handled via descriptor based lookup, int family needs
// special handling.
@@ -1519,11 +1519,11 @@ public class VectorizationContext {
public static boolean isTimestampFamily(String resultType) {
return resultType.equalsIgnoreCase("timestamp");
}
-
+
public static boolean isDateFamily(String resultType) {
return resultType.equalsIgnoreCase("date");
}
-
+
// return true if this is any kind of float
public static boolean isFloatFamily(String resultType) {
return resultType.equalsIgnoreCase("double")
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/ConstantVectorExpression.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/ConstantVectorExpression.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/ConstantVectorExpression.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/ConstantVectorExpression.java Thu Sep 4 02:49:46 2014
@@ -75,23 +75,23 @@ public class ConstantVectorExpression ex
this(outputColumn, "decimal");
setDecimalValue(value);
}
-
+
/*
* Support for null constant object
*/
public ConstantVectorExpression(int outputColumn, String typeString, boolean isNull) {
- this(outputColumn, typeString);
- isNullValue = isNull;
+ this(outputColumn, typeString);
+ isNullValue = isNull;
}
-
+
private void evaluateLong(VectorizedRowBatch vrg) {
LongColumnVector cv = (LongColumnVector) vrg.cols[outputColumn];
cv.isRepeating = true;
cv.noNulls = !isNullValue;
if (!isNullValue) {
- cv.vector[0] = longValue;
+ cv.vector[0] = longValue;
} else {
- cv.isNull[0] = true;
+ cv.isNull[0] = true;
}
}
@@ -100,10 +100,10 @@ public class ConstantVectorExpression ex
cv.isRepeating = true;
cv.noNulls = !isNullValue;
if (!isNullValue) {
- cv.vector[0] = doubleValue;
+ cv.vector[0] = doubleValue;
} else {
- cv.isNull[0] = true;
- }
+ cv.isNull[0] = true;
+ }
}
private void evaluateBytes(VectorizedRowBatch vrg) {
@@ -112,9 +112,9 @@ public class ConstantVectorExpression ex
cv.noNulls = !isNullValue;
cv.initBuffer();
if (!isNullValue) {
- cv.setVal(0, bytesValue, 0, bytesValueLength);
+ cv.setVal(0, bytesValue, 0, bytesValueLength);
} else {
- cv.isNull[0] = true;
+ cv.isNull[0] = true;
}
}
@@ -123,9 +123,9 @@ public class ConstantVectorExpression ex
dcv.isRepeating = true;
dcv.noNulls = !isNullValue;
if (!isNullValue) {
- dcv.vector[0].update(decimalValue);
+ dcv.vector[0].update(decimalValue);
} else {
- dcv.isNull[0] = true;
+ dcv.isNull[0] = true;
}
}
@@ -194,7 +194,7 @@ public class ConstantVectorExpression ex
} else if (VectorizationContext.isDecimalFamily(typeString)){
this.type = Type.DECIMAL;
} else {
- // everything else that does not belong to string, double, decimal is treated as long.
+ // everything else that does not belong to string, double, decimal is treated as long.
this.type = Type.LONG;
}
}
Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/IdentityExpression.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/IdentityExpression.java?rev=1622396&r1=1622395&r2=1622396&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/IdentityExpression.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/IdentityExpression.java Thu Sep 4 02:49:46 2014
@@ -33,17 +33,17 @@ public class IdentityExpression extends
public IdentityExpression() {
}
- public IdentityExpression(int colNum, String type) {
- this.colNum = colNum;
+ public IdentityExpression(int colNum, String type) {
+ this.colNum = colNum;
this.type = type;
- }
+ }
- @Override
+ @Override
public void evaluate(VectorizedRowBatch batch) {
if (childExpressions != null) {
this.evaluateChildren(batch);
}
- }
+ }
@Override
public int getOutputColumn() {