You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2015/03/28 01:22:27 UTC
svn commit: r1669718 [9/29] - in /hive/branches/llap: ./
ant/src/org/apache/hadoop/hive/ant/
common/src/java/org/apache/hadoop/hive/common/
common/src/java/org/apache/hadoop/hive/common/type/
common/src/java/org/apache/hadoop/hive/conf/ common/src/java...
Added: hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalColumnArithmeticDateTimeColumnWithConvert.txt
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalColumnArithmeticDateTimeColumnWithConvert.txt?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalColumnArithmeticDateTimeColumnWithConvert.txt (added)
+++ hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalColumnArithmeticDateTimeColumnWithConvert.txt Sat Mar 28 00:22:15 2015
@@ -0,0 +1,177 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
+
+import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
+import org.apache.hadoop.hive.ql.exec.vector.*;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.util.DateTimeMath;
+
+/**
+ * Generated from template IntervalColumnArithmeticDateTimeColumnWithConvert.txt, which covers binary arithmetic
+ * expressions between columns.
+ */
+public class <ClassName> extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum1;
+ private int colNum2;
+ private int outputColumn;
+ private DateTimeMath dtm = new DateTimeMath();
+
+ public <ClassName>(int colNum1, int colNum2, int outputColumn) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ this.outputColumn = outputColumn;
+ }
+
+ public <ClassName>() {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ <InputColumnVectorType1> inputColVector1 = (<InputColumnVectorType1>) batch.cols[colNum1];
+ <InputColumnVectorType2> inputColVector2 = (<InputColumnVectorType2>) batch.cols[colNum2];
+ <OutputColumnVectorType> outputColVector = (<OutputColumnVectorType>) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ <VectorOperandType1>[] vector1 = inputColVector1.vector;
+ <VectorOperandType2>[] vector2 = inputColVector2.vector;
+ <VectorReturnType>[] outputVector = outputColVector.vector;
+
+ // arg1 is interval type, arg2 is datetime type
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ outputColVector.isRepeating =
+ inputColVector1.isRepeating && inputColVector2.isRepeating
+ || inputColVector1.isRepeating && !inputColVector1.noNulls && inputColVector1.isNull[0]
+ || inputColVector2.isRepeating && !inputColVector2.noNulls && inputColVector2.isNull[0];
+
+ // Handle nulls first
+ NullUtil.propagateNullsColCol(
+ inputColVector1, inputColVector2, outputColVector, sel, n, batch.selectedInUse);
+
+ /* Disregard nulls for processing. In other words,
+ * the arithmetic operation is performed even if one or
+ * more inputs are null. This is to improve speed by avoiding
+ * conditional checks in the inner loop.
+ */
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ outputVector[0] = <OperatorFunction>(<TypeConversionToMillis>(vector2[0]), <OperatorSymbol> (int) vector1[0]);
+ } else if (inputColVector1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = <OperatorFunction>(<TypeConversionToMillis>(vector2[0]), <OperatorSymbol> (int) vector1[i]);
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = <OperatorFunction>(<TypeConversionToMillis>(vector2[0]), <OperatorSymbol> (int) vector1[i]);
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = <OperatorFunction>(<TypeConversionToMillis>(vector2[i]), <OperatorSymbol> (int) vector1[0]);
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = <OperatorFunction>(<TypeConversionToMillis>(vector2[i]), <OperatorSymbol> (int) vector1[0]);
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = <OperatorFunction>(<TypeConversionToMillis>(vector2[i]), <OperatorSymbol> (int) vector1[i]);
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = <OperatorFunction>(<TypeConversionToMillis>(vector2[i]), <OperatorSymbol> (int) vector1[i]);
+ }
+ }
+ }
+
+ /* For the case when the output can have null values, follow
+ * the convention that the data values must be 1 for long and
+ * NaN for double. This is to prevent possible later zero-divide errors
+ * in complex arithmetic expressions like col2 / (col1 - 1)
+ * in the case when some col1 entries are null.
+ */
+ NullUtil.setNullDataEntries<CamelReturnType>(outputColVector, batch.selectedInUse, sel, n);
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "<VectorReturnType>";
+ }
+
+ public int getColNum1() {
+ return colNum1;
+ }
+
+ public void setColNum1(int colNum1) {
+ this.colNum1 = colNum1;
+ }
+
+ public int getColNum2() {
+ return colNum2;
+ }
+
+ public void setColNum2(int colNum2) {
+ this.colNum2 = colNum2;
+ }
+
+ public void setOutputColumn(int outputColumn) {
+ this.outputColumn = outputColumn;
+ }
+
+ @Override
+ public VectorExpressionDescriptor.Descriptor getDescriptor() {
+ return (new VectorExpressionDescriptor.Builder())
+ .setMode(
+ VectorExpressionDescriptor.Mode.PROJECTION)
+ .setNumArguments(2)
+ .setArgumentTypes(
+ VectorExpressionDescriptor.ArgumentType.getType("<OperandType1>"),
+ VectorExpressionDescriptor.ArgumentType.getType("<OperandType2>"))
+ .setInputExpressionTypes(
+ VectorExpressionDescriptor.InputExpressionType.COLUMN,
+ VectorExpressionDescriptor.InputExpressionType.COLUMN).build();
+ }
+}
+
Added: hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalColumnArithmeticDateTimeScalarWithConvert.txt
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalColumnArithmeticDateTimeScalarWithConvert.txt?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalColumnArithmeticDateTimeScalarWithConvert.txt (added)
+++ hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalColumnArithmeticDateTimeScalarWithConvert.txt Sat Mar 28 00:22:15 2015
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
+
+import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.<InputColumnVectorType>;
+import org.apache.hadoop.hive.ql.exec.vector.<OutputColumnVectorType>;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.*;
+import org.apache.hadoop.hive.ql.util.DateTimeMath;
+
+/**
+ * Generated from template IntervalColumnArithmeticDateTimeScalarWithConvert.txt, which covers binary arithmetic
+ * expressions between a column and a scalar.
+ */
+public class <ClassName> extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private <VectorOperandType2> value;
+ private int outputColumn;
+ private DateTimeMath dtm = new DateTimeMath();
+
+ public <ClassName>(int colNum, <VectorOperandType2> value, int outputColumn) {
+ this.colNum = colNum;
+ this.value = <TypeConversionToMillis>(value);
+ this.outputColumn = outputColumn;
+ }
+
+ public <ClassName>() {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ <InputColumnVectorType> inputColVector = (<InputColumnVectorType>) batch.cols[colNum];
+ <OutputColumnVectorType> outputColVector = (<OutputColumnVectorType>) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ boolean[] inputIsNull = inputColVector.isNull;
+ boolean[] outputIsNull = outputColVector.isNull;
+ outputColVector.noNulls = inputColVector.noNulls;
+ outputColVector.isRepeating = inputColVector.isRepeating;
+ int n = batch.size;
+ <VectorOperandType1>[] vector = inputColVector.vector;
+ <VectorReturnType>[] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ // arg1 is interval, arg2 is datetime
+
+ if (inputColVector.isRepeating) {
+ outputVector[0] = <OperatorFunction>(value, <OperatorSymbol> (int) vector[0]);
+
+ // Even if there are no nulls, we always copy over entry 0. Simplifies code.
+ outputIsNull[0] = inputIsNull[0];
+ } else if (inputColVector.noNulls) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = <OperatorFunction>(value, <OperatorSymbol> (int) vector[i]);
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = <OperatorFunction>(value, <OperatorSymbol> (int) vector[i]);
+ }
+ }
+ } else /* there are nulls */ {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = <OperatorFunction>(value, <OperatorSymbol> (int) vector[i]);
+ outputIsNull[i] = inputIsNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = <OperatorFunction>(value, <OperatorSymbol> (int) vector[i]);
+ }
+ System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
+ }
+ }
+
+ NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "<VectorReturnType>";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public <VectorOperandType2> getValue() {
+ return value;
+ }
+
+ public void setValue(<VectorOperandType2> value) {
+ this.value = value;
+ }
+
+ public void setOutputColumn(int outputColumn) {
+ this.outputColumn = outputColumn;
+ }
+
+ @Override
+ public VectorExpressionDescriptor.Descriptor getDescriptor() {
+ return (new VectorExpressionDescriptor.Builder())
+ .setMode(
+ VectorExpressionDescriptor.Mode.PROJECTION)
+ .setNumArguments(2)
+ .setArgumentTypes(
+ VectorExpressionDescriptor.ArgumentType.getType("<OperandType1>"),
+ VectorExpressionDescriptor.ArgumentType.getType("<OperandType2>"))
+ .setInputExpressionTypes(
+ VectorExpressionDescriptor.InputExpressionType.COLUMN,
+ VectorExpressionDescriptor.InputExpressionType.SCALAR).build();
+ }
+}
Added: hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalScalarArithmeticDateTimeColumnWithConvert.txt
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalScalarArithmeticDateTimeColumnWithConvert.txt?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalScalarArithmeticDateTimeColumnWithConvert.txt (added)
+++ hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/IntervalScalarArithmeticDateTimeColumnWithConvert.txt Sat Mar 28 00:22:15 2015
@@ -0,0 +1,167 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
+
+import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.*;
+
+
+/*
+ * Because of the templatized nature of the code, either or both
+ * of these ColumnVector imports may be needed. Listing both of them
+ * rather than using ....vectorization.*;
+ */
+import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
+import org.apache.hadoop.hive.ql.util.DateTimeMath;
+
+/**
+ * Generated from template IntervalScalarArithmeticDateTimeColumnWithConvert.txt.
+ * Implements a vectorized arithmetic operator with a scalar on the left and a
+ * column vector on the right. The result is output to an output column vector.
+ */
+public class <ClassName> extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private <VectorOperandType1> value;
+ private int outputColumn;
+ private DateTimeMath dtm = new DateTimeMath();
+
+ public <ClassName>(<VectorOperandType1> value, int colNum, int outputColumn) {
+ this.colNum = colNum;
+ this.value = value;
+ this.outputColumn = outputColumn;
+ }
+
+ public <ClassName>() {
+ }
+
+ @Override
+ /**
+ * Method to evaluate scalar-column operation in vectorized fashion.
+ *
+ * @batch a package of rows with each column stored in a vector
+ */
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ <InputColumnVectorType> inputColVector = (<InputColumnVectorType>) batch.cols[colNum];
+ <OutputColumnVectorType> outputColVector = (<OutputColumnVectorType>) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ boolean[] inputIsNull = inputColVector.isNull;
+ boolean[] outputIsNull = outputColVector.isNull;
+ outputColVector.noNulls = inputColVector.noNulls;
+ outputColVector.isRepeating = inputColVector.isRepeating;
+ int n = batch.size;
+ <VectorOperandType2>[] vector = inputColVector.vector;
+ <VectorReturnType>[] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ // arg1 is interval, arg2 is datetime
+
+ if (inputColVector.isRepeating) {
+ outputVector[0] = <OperatorFunction>(<TypeConversionToMillis>(vector[0]), <OperatorSymbol> (int) value);
+
+ // Even if there are no nulls, we always copy over entry 0. Simplifies code.
+ outputIsNull[0] = inputIsNull[0];
+ } else if (inputColVector.noNulls) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = <OperatorFunction>(<TypeConversionToMillis>(vector[i]), <OperatorSymbol> (int) value);
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = <OperatorFunction>(<TypeConversionToMillis>(vector[i]), <OperatorSymbol> (int) value);
+ }
+ }
+ } else { /* there are nulls */
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = <OperatorFunction>(<TypeConversionToMillis>(vector[i]), <OperatorSymbol> (int) value);
+ outputIsNull[i] = inputIsNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = <OperatorFunction>(<TypeConversionToMillis>(vector[i]), <OperatorSymbol> (int) value);
+ }
+ System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
+ }
+ }
+
+ NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "<VectorReturnType>";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public <VectorOperandType1> getValue() {
+ return value;
+ }
+
+ public void setValue(<VectorOperandType1> value) {
+ this.value = value;
+ }
+
+ public void setOutputColumn(int outputColumn) {
+ this.outputColumn = outputColumn;
+ }
+
+ @Override
+ public VectorExpressionDescriptor.Descriptor getDescriptor() {
+ return (new VectorExpressionDescriptor.Builder())
+ .setMode(
+ VectorExpressionDescriptor.Mode.PROJECTION)
+ .setNumArguments(2)
+ .setArgumentTypes(
+ VectorExpressionDescriptor.ArgumentType.getType("<OperandType1>"),
+ VectorExpressionDescriptor.ArgumentType.getType("<OperandType2>"))
+ .setInputExpressionTypes(
+ VectorExpressionDescriptor.InputExpressionType.SCALAR,
+ VectorExpressionDescriptor.InputExpressionType.COLUMN).build();
+ }
+}
Added: hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumnWithConvert.txt
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumnWithConvert.txt?rev=1669718&view=auto
==============================================================================
--- hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumnWithConvert.txt (added)
+++ hive/branches/llap/ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumnWithConvert.txt Sat Mar 28 00:22:15 2015
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
+
+import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
+import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
+import org.apache.hadoop.hive.ql.exec.vector.*;
+
+
+/*
+ * Because of the templatized nature of the code, either or both
+ * of these ColumnVector imports may be needed. Listing both of them
+ * rather than using ....vectorization.*;
+ */
+import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
+
+/**
+ * Generated from template ScalarArithmeticColumnWithConvert.txt.
+ * Implements a vectorized arithmetic operator with a scalar on the left and a
+ * column vector on the right. The result is output to an output column vector.
+ */
+public class <ClassName> extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private <VectorOperandType1> value;
+ private int outputColumn;
+
+ public <ClassName>(<VectorOperandType1> value, int colNum, int outputColumn) {
+ this.colNum = colNum;
+ this.value = <TypeConversion1>(value);
+ this.outputColumn = outputColumn;
+ }
+
+ public <ClassName>() {
+ }
+
+ @Override
+ /**
+ * Method to evaluate scalar-column operation in vectorized fashion.
+ *
+ * @batch a package of rows with each column stored in a vector
+ */
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ <InputColumnVectorType> inputColVector = (<InputColumnVectorType>) batch.cols[colNum];
+ <OutputColumnVectorType> outputColVector = (<OutputColumnVectorType>) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ boolean[] inputIsNull = inputColVector.isNull;
+ boolean[] outputIsNull = outputColVector.isNull;
+ outputColVector.noNulls = inputColVector.noNulls;
+ outputColVector.isRepeating = inputColVector.isRepeating;
+ int n = batch.size;
+ <VectorOperandType2>[] vector = inputColVector.vector;
+ <VectorReturnType>[] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ if (inputColVector.isRepeating) {
+ outputVector[0] = value <OperatorSymbol> <TypeConversion2>(vector[0]);
+
+ // Even if there are no nulls, we always copy over entry 0. Simplifies code.
+ outputIsNull[0] = inputIsNull[0];
+ } else if (inputColVector.noNulls) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = value <OperatorSymbol> <TypeConversion2>(vector[i]);
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = value <OperatorSymbol> <TypeConversion2>(vector[i]);
+ }
+ }
+ } else { /* there are nulls */
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = value <OperatorSymbol> <TypeConversion2>(vector[i]);
+ outputIsNull[i] = inputIsNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = value <OperatorSymbol> <TypeConversion2>(vector[i]);
+ }
+ System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
+ }
+ }
+
+ NullUtil.setNullOutputEntriesColScalar(outputColVector, batch.selectedInUse, sel, n);
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "<VectorReturnType>";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public <VectorOperandType1> getValue() {
+ return value;
+ }
+
+ public void setValue(<VectorOperandType1> value) {
+ this.value = value;
+ }
+
+ public void setOutputColumn(int outputColumn) {
+ this.outputColumn = outputColumn;
+ }
+
+ @Override
+ public VectorExpressionDescriptor.Descriptor getDescriptor() {
+ return (new VectorExpressionDescriptor.Builder())
+ .setMode(
+ VectorExpressionDescriptor.Mode.PROJECTION)
+ .setNumArguments(2)
+ .setArgumentTypes(
+ VectorExpressionDescriptor.ArgumentType.getType("<OperandType1>"),
+ VectorExpressionDescriptor.ArgumentType.getType("<OperandType2>"))
+ .setInputExpressionTypes(
+ VectorExpressionDescriptor.InputExpressionType.SCALAR,
+ VectorExpressionDescriptor.InputExpressionType.COLUMN).build();
+ }
+}
Modified: hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/Driver.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/Driver.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/Driver.java Sat Mar 28 00:22:15 2015
@@ -440,15 +440,13 @@ public class Driver implements CommandPr
sem.validate();
perfLogger.PerfLogEnd(CLASS_NAME, PerfLogger.ANALYZE);
- plan = new QueryPlan(command, sem, perfLogger.getStartTime(PerfLogger.DRIVER_RUN), queryId,
- SessionState.get().getCommandType());
+ // Command should be redacted before passing it to the QueryPlan in order
+ // to avoid returning sensitive data
+ String queryStr = HookUtils.redactLogString(conf, command);
+
+ plan = new QueryPlan(queryStr, sem, perfLogger.getStartTime(PerfLogger.DRIVER_RUN), queryId,
+ SessionState.get().getCommandType());
- String queryStr = plan.getQueryStr();
- List<Redactor> queryRedactors = getHooks(ConfVars.QUERYREDACTORHOOKS, Redactor.class);
- for (Redactor redactor : queryRedactors) {
- redactor.setConf(conf);
- queryStr = redactor.redactQuery(queryStr);
- }
conf.setVar(HiveConf.ConfVars.HIVEQUERYSTRING, queryStr);
conf.set("mapreduce.workflow.id", "hive_" + queryId);
@@ -973,6 +971,7 @@ public class Driver implements CommandPr
if (txnId == SessionState.NO_CURRENT_TXN) {
txnId = txnMgr.openTxn(userFromUGI);
ss.setCurrentTxn(txnId);
+ LOG.debug("Setting current transaction to " + txnId);
}
// Set the transaction id in all of the acid file sinks
if (acidSinks != null) {
Modified: hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsTask.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsTask.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsTask.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsTask.java Sat Mar 28 00:22:15 2015
@@ -267,7 +267,7 @@ public class ColumnStatsTask extends Tas
private List<ColumnStatistics> constructColumnStatsFromPackedRows() throws HiveException, MetaException, IOException {
- String dbName = SessionState.get().getCurrentDatabase();
+ String currentDb = SessionState.get().getCurrentDatabase();
String tableName = work.getColStats().getTableName();
String partName = null;
List<String> colName = work.getColStats().getColName();
@@ -286,7 +286,7 @@ public class ColumnStatsTask extends Tas
List<? extends StructField> fields = soi.getAllStructFieldRefs();
List<Object> list = soi.getStructFieldsDataAsList(packedRow.o);
- Table tbl = db.getTable(dbName,tableName);
+ Table tbl = db.getTable(currentDb,tableName);
List<FieldSchema> partColSchema = tbl.getPartCols();
// Partition columns are appended at end, we only care about stats column
int numOfStatCols = isTblLevel ? fields.size() : fields.size() - partColSchema.size();
@@ -313,8 +313,8 @@ public class ColumnStatsTask extends Tas
}
partName = Warehouse.makePartName(partColSchema, partVals);
}
-
- ColumnStatisticsDesc statsDesc = getColumnStatsDesc(dbName, tableName, partName, isTblLevel);
+ String [] names = Utilities.getDbTableName(currentDb, tableName);
+ ColumnStatisticsDesc statsDesc = getColumnStatsDesc(names[0], names[1], partName, isTblLevel);
ColumnStatistics colStats = new ColumnStatistics();
colStats.setStatsDesc(statsDesc);
colStats.setStatsObj(statsObjs);
Modified: hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java Sat Mar 28 00:22:15 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/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java Sat Mar 28 00:22:15 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/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java Sat Mar 28 00:22:15 2015
@@ -118,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.
@@ -420,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();
@@ -705,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/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java Sat Mar 28 00:22:15 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;
@@ -294,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);
@@ -337,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/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinUtil.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinUtil.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinUtil.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/JoinUtil.java Sat Mar 28 00:22:15 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/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MapJoinOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MapJoinOperator.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MapJoinOperator.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MapJoinOperator.java Sat Mar 28 00:22:15 2015
@@ -18,6 +18,7 @@
package org.apache.hadoop.hive.ql.exec;
+import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -31,6 +32,7 @@ import org.apache.commons.lang3.tuple.Pa
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;
@@ -39,9 +41,15 @@ import org.apache.hadoop.hive.ql.exec.pe
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;
@@ -51,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.
*/
@@ -74,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() {
}
@@ -99,6 +118,7 @@ public class MapJoinOperator extends Abs
@Override
protected Collection<Future<?>> initializeOp(Configuration hconf) throws HiveException {
+ this.hconf = hconf;
unwrapContainer = new UnwrapRowContainer[conf.getTagLength()];
Collection<Future<?>> result = super.initializeOp(hconf);
@@ -121,13 +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();
final ExecMapperContext mapContext = getExecContext();
final MapredContext mrContext = MapredContext.get();
- if (!conf.isBucketMapJoin()) {
+ 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,
@@ -278,9 +300,9 @@ public class MapJoinOperator extends Abs
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) {
@@ -297,6 +319,18 @@ public class MapJoinOperator extends Abs
@Override
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 {
// compute keys and values as StandardObjects
ReusableGetAdaptor firstSetKey = null;
@@ -304,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) {
@@ -321,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;
}
@@ -331,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) {
@@ -354,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)
@@ -375,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/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MapOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MapOperator.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MapOperator.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MapOperator.java Sat Mar 28 00:22:15 2015
@@ -35,6 +35,7 @@ import java.util.concurrent.Future;
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;
@@ -91,6 +92,7 @@ public class MapOperator extends Operato
protected transient long cntr = 1;
private final Map<Integer, DummyStoreOperator> connectedOperators
= new TreeMap<Integer, DummyStoreOperator>();
+ protected transient long logEveryNRows = 0;
// input path --> {operator --> context}
private final Map<String, Map<Operator<?>, MapOpCtx>> opCtxMap =
@@ -429,6 +431,8 @@ public class MapOperator extends Operato
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()) {
@@ -524,7 +528,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);
}
}
Modified: hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java Sat Mar 28 00:22:15 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/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ReduceSinkOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ReduceSinkOperator.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ReduceSinkOperator.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/ReduceSinkOperator.java Sat Mar 28 00:22:15 2015
@@ -152,6 +152,7 @@ public class ReduceSinkOperator extends
protected transient long numRows = 0;
protected transient long cntr = 1;
+ protected transient long logEveryNRows = 0;
private final transient LongWritable recordCounter = new LongWritable();
@Override
@@ -160,6 +161,8 @@ public class ReduceSinkOperator extends
try {
numRows = 0;
+ cntr = 1;
+ logEveryNRows = HiveConf.getLongVar(hconf, HiveConf.ConfVars.HIVE_LOG_N_RECORDS);
String context = hconf.get(Operator.CONTEXT_NAME_KEY, "");
if (context != null && !context.isEmpty()) {
@@ -531,7 +534,11 @@ public class ReduceSinkOperator extends
numRows++;
if (isLogInfoEnabled) {
if (numRows == cntr) {
- cntr *= 10;
+ cntr = logEveryNRows == 0 ? cntr * 10 : numRows + logEveryNRows;
+ if (cntr < 0 || numRows < 0) {
+ cntr = 0;
+ numRows = 1;
+ }
LOG.info(toString() + ": records written - " + numRows);
}
}
Modified: hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/BytesBytesMultiHashMap.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/BytesBytesMultiHashMap.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/BytesBytesMultiHashMap.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/BytesBytesMultiHashMap.java Sat Mar 28 00:22:15 2015
@@ -124,6 +124,7 @@ public final class BytesBytesMultiHashMa
private int resizeThreshold;
private int keysAssigned;
+ private int numValues;
/**
* Largest number of probe steps ever taken to find location for a key. When getting, we can
@@ -154,7 +155,7 @@ public final class BytesBytesMultiHashMa
private final static int DEFAULT_MAX_CAPACITY = 1024 * 1024 * 1024;
public BytesBytesMultiHashMap(int initialCapacity,
- float loadFactor, int wbSize, long memUsage, int defaultCapacity) {
+ float loadFactor, int wbSize, long memUsage) {
if (loadFactor < 0 || loadFactor > 1) {
throw new AssertionError("Load factor must be between (0, 1].");
}
@@ -180,7 +181,7 @@ public final class BytesBytesMultiHashMa
@VisibleForTesting
BytesBytesMultiHashMap(int initialCapacity, float loadFactor, int wbSize) {
- this(initialCapacity, loadFactor, wbSize, -1, 100000);
+ this(initialCapacity, loadFactor, wbSize, -1);
}
/** The source of keys and values to put into hashtable; avoids byte copying. */
@@ -204,7 +205,7 @@ public final class BytesBytesMultiHashMa
* @param kv Keyvalue writer. Each method will be called at most once.
*/
private static final byte[] FOUR_ZEROES = new byte[] { 0, 0, 0, 0 };
- public void put(KvSource kv) throws SerDeException {
+ public void put(KvSource kv, int keyHashCode) throws SerDeException {
if (resizeThreshold <= keysAssigned) {
expandAndRehash();
}
@@ -218,7 +219,7 @@ public final class BytesBytesMultiHashMa
kv.writeKey(writeBuffers);
int keyLength = (int)(writeBuffers.getWritePoint() - keyOffset);
- int hashCode = writeBuffers.hashCode(keyOffset, keyLength);
+ int hashCode = (keyHashCode == -1) ? writeBuffers.hashCode(keyOffset, keyLength) : keyHashCode;
int slot = findKeySlotToWrite(keyOffset, keyLength, hashCode);
// LOG.info("Write hash code is " + Integer.toBinaryString(hashCode) + " - " + slot);
@@ -243,6 +244,7 @@ public final class BytesBytesMultiHashMa
}
refs[slot] = Ref.setListFlag(ref);
}
+ ++numValues;
}
/**
@@ -301,10 +303,33 @@ public final class BytesBytesMultiHashMa
writeBuffers.populateValue(valueRef);
}
+ /**
+ * Number of keys in the hashmap
+ * @return number of keys
+ */
public int size() {
return keysAssigned;
}
+ /**
+ * Number of values in the hashmap
+ * This is equal to or bigger than number of keys, since some values may share the same key
+ * @return number of values
+ */
+ public int getNumValues() {
+ return numValues;
+ }
+
+ /**
+ * Number of bytes used by the hashmap
+ * There are two main components that take most memory: writeBuffers and refs
+ * Others include instance fields: 100
+ * @return number of bytes
+ */
+ public long memorySize() {
+ return writeBuffers.size() + refs.length * 8 + 100;
+ }
+
public void seal() {
writeBuffers.seal();
}
Modified: hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HashMapWrapper.java
URL: http://svn.apache.org/viewvc/hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HashMapWrapper.java?rev=1669718&r1=1669717&r2=1669718&view=diff
==============================================================================
--- hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HashMapWrapper.java (original)
+++ hive/branches/llap/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/HashMapWrapper.java Sat Mar 28 00:22:15 2015
@@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFac
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator;
+import org.apache.hadoop.hive.ql.exec.JoinUtil;
import org.apache.hadoop.hive.ql.exec.vector.VectorHashKeyWrapper;
import org.apache.hadoop.hive.ql.exec.vector.VectorHashKeyWrapperBatch;
import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpressionWriter;
@@ -153,8 +154,9 @@ public class HashMapWrapper extends Abst
}
@Override
- public void setFromVector(VectorHashKeyWrapper kw, VectorExpressionWriter[] keyOutputWriters,
- VectorHashKeyWrapperBatch keyWrapperBatch) throws HiveException {
+ public JoinUtil.JoinResult setFromVector(VectorHashKeyWrapper kw,
+ VectorExpressionWriter[] keyOutputWriters, VectorHashKeyWrapperBatch keyWrapperBatch)
+ throws HiveException {
if (currentKey == null) {
currentKey = new Object[keyOutputWriters.length];
vectorKeyOIs = new ArrayList<ObjectInspector>();
@@ -168,10 +170,16 @@ public class HashMapWrapper extends Abst
key = MapJoinKey.readFromVector(output, key, currentKey, vectorKeyOIs, !isFirstKey);
isFirstKey = false;
this.currentValue = mHash.get(key);
+ if (this.currentValue == null) {
+ return JoinUtil.JoinResult.NOMATCH;
+ }
+ else {
+ return JoinUtil.JoinResult.MATCH;
+ }
}
@Override
- public void setFromRow(Object row, List<ExprNodeEvaluator> fields,
+ public JoinUtil.JoinResult setFromRow(Object row, List<ExprNodeEvaluator> fields,
List<ObjectInspector> ois) throws HiveException {
if (currentKey == null) {
currentKey = new Object[fields.size()];
@@ -182,15 +190,27 @@ public class HashMapWrapper extends Abst
key = MapJoinKey.readFromRow(output, key, currentKey, ois, !isFirstKey);
isFirstKey = false;
this.currentValue = mHash.get(key);
+ if (this.currentValue == null) {
+ return JoinUtil.JoinResult.NOMATCH;
+ }
+ else {
+ return JoinUtil.JoinResult.MATCH;
+ }
}
@Override
- public void setFromOther(ReusableGetAdaptor other) {
+ public JoinUtil.JoinResult setFromOther(ReusableGetAdaptor other) {
assert other instanceof GetAdaptor;
GetAdaptor other2 = (GetAdaptor)other;
this.key = other2.key;
this.isFirstKey = other2.isFirstKey;
this.currentValue = mHash.get(key);
+ if (this.currentValue == null) {
+ return JoinUtil.JoinResult.NOMATCH;
+ }
+ else {
+ return JoinUtil.JoinResult.MATCH;
+ }
}
@Override
@@ -223,4 +243,9 @@ public class HashMapWrapper extends Abst
public void dumpMetrics() {
// Nothing to do.
}
+
+ @Override
+ public boolean hasSpill() {
+ return false;
+ }
}