You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2013/04/23 23:41:06 UTC
svn commit: r1471159 [4/4] - in /hive/branches/vectorization/ql/src:
java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/
java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/
test/org/apache/hadoop/hive/ql/exec/vector/expressions/
Added: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java?rev=1471159&view=auto
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java (added)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java Tue Apr 23 21:41:05 2013
@@ -0,0 +1,173 @@
+/**
+ * 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.*;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+public class LongColModuloLongColumn extends VectorExpression {
+ int colNum1;
+ int colNum2;
+ int outputColumn;
+
+ public LongColModuloLongColumn(int colNum1, int colNum2, int outputColumn) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ this.outputColumn = outputColumn;
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ LongColumnVector inputColVector1 = (LongColumnVector) batch.cols[colNum1];
+ LongColumnVector inputColVector2 = (LongColumnVector) batch.cols[colNum2];
+ LongColumnVector outputColVector = (LongColumnVector) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ long[] vector1 = inputColVector1.vector;
+ long[] vector2 = inputColVector2.vector;
+
+ long[] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ //Handle nulls first
+ if (inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isNull[0] = true;
+ outputColVector.isRepeating = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ }
+ }
+ }
+
+
+ //Disregard nulls for processing
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ outputVector[0] = vector1[0] % vector2[0];
+ outputColVector.isRepeating = true;
+ } else if (inputColVector1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[0] % vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[0] % vector2[i];
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] % vector2[0];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] % vector2[0];
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] % vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] % vector2[i];
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "long";
+ }
+}
Added: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java?rev=1471159&view=auto
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java (added)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java Tue Apr 23 21:41:05 2013
@@ -0,0 +1,173 @@
+/**
+ * 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.*;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+public class LongColMultiplyDoubleColumn extends VectorExpression {
+ int colNum1;
+ int colNum2;
+ int outputColumn;
+
+ public LongColMultiplyDoubleColumn(int colNum1, int colNum2, int outputColumn) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ this.outputColumn = outputColumn;
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ LongColumnVector inputColVector1 = (LongColumnVector) batch.cols[colNum1];
+ DoubleColumnVector inputColVector2 = (DoubleColumnVector) batch.cols[colNum2];
+ DoubleColumnVector outputColVector = (DoubleColumnVector) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ long[] vector1 = inputColVector1.vector;
+ double[] vector2 = inputColVector2.vector;
+
+ double[] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ //Handle nulls first
+ if (inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isNull[0] = true;
+ outputColVector.isRepeating = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ }
+ }
+ }
+
+
+ //Disregard nulls for processing
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ outputVector[0] = vector1[0] * vector2[0];
+ outputColVector.isRepeating = true;
+ } else if (inputColVector1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[0] * vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[0] * vector2[i];
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] * vector2[0];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] * vector2[0];
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] * vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] * vector2[i];
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "double";
+ }
+}
Added: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java?rev=1471159&view=auto
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java (added)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java Tue Apr 23 21:41:05 2013
@@ -0,0 +1,173 @@
+/**
+ * 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.*;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+public class LongColMultiplyLongColumn extends VectorExpression {
+ int colNum1;
+ int colNum2;
+ int outputColumn;
+
+ public LongColMultiplyLongColumn(int colNum1, int colNum2, int outputColumn) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ this.outputColumn = outputColumn;
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ LongColumnVector inputColVector1 = (LongColumnVector) batch.cols[colNum1];
+ LongColumnVector inputColVector2 = (LongColumnVector) batch.cols[colNum2];
+ LongColumnVector outputColVector = (LongColumnVector) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ long[] vector1 = inputColVector1.vector;
+ long[] vector2 = inputColVector2.vector;
+
+ long[] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ //Handle nulls first
+ if (inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isNull[0] = true;
+ outputColVector.isRepeating = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ }
+ }
+ }
+
+
+ //Disregard nulls for processing
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ outputVector[0] = vector1[0] * vector2[0];
+ outputColVector.isRepeating = true;
+ } else if (inputColVector1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[0] * vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[0] * vector2[i];
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] * vector2[0];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] * vector2[0];
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] * vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] * vector2[i];
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "long";
+ }
+}
Added: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java?rev=1471159&view=auto
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java (added)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java Tue Apr 23 21:41:05 2013
@@ -0,0 +1,173 @@
+/**
+ * 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.*;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+public class LongColSubtractDoubleColumn extends VectorExpression {
+ int colNum1;
+ int colNum2;
+ int outputColumn;
+
+ public LongColSubtractDoubleColumn(int colNum1, int colNum2, int outputColumn) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ this.outputColumn = outputColumn;
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ LongColumnVector inputColVector1 = (LongColumnVector) batch.cols[colNum1];
+ DoubleColumnVector inputColVector2 = (DoubleColumnVector) batch.cols[colNum2];
+ DoubleColumnVector outputColVector = (DoubleColumnVector) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ long[] vector1 = inputColVector1.vector;
+ double[] vector2 = inputColVector2.vector;
+
+ double[] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ //Handle nulls first
+ if (inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isNull[0] = true;
+ outputColVector.isRepeating = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ }
+ }
+ }
+
+
+ //Disregard nulls for processing
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ outputVector[0] = vector1[0] - vector2[0];
+ outputColVector.isRepeating = true;
+ } else if (inputColVector1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[0] - vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[0] - vector2[i];
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] - vector2[0];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] - vector2[0];
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] - vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] - vector2[i];
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "double";
+ }
+}
Added: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java?rev=1471159&view=auto
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java (added)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java Tue Apr 23 21:41:05 2013
@@ -0,0 +1,173 @@
+/**
+ * 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.*;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+public class LongColSubtractLongColumn extends VectorExpression {
+ int colNum1;
+ int colNum2;
+ int outputColumn;
+
+ public LongColSubtractLongColumn(int colNum1, int colNum2, int outputColumn) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ this.outputColumn = outputColumn;
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ LongColumnVector inputColVector1 = (LongColumnVector) batch.cols[colNum1];
+ LongColumnVector inputColVector2 = (LongColumnVector) batch.cols[colNum2];
+ LongColumnVector outputColVector = (LongColumnVector) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ long[] vector1 = inputColVector1.vector;
+ long[] vector2 = inputColVector2.vector;
+
+ long[] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ //Handle nulls first
+ if (inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isNull[0] = true;
+ outputColVector.isRepeating = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ }
+ }
+ }
+
+
+ //Disregard nulls for processing
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ outputVector[0] = vector1[0] - vector2[0];
+ outputColVector.isRepeating = true;
+ } else if (inputColVector1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[0] - vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[0] - vector2[i];
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] - vector2[0];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] - vector2[0];
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] - vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] - vector2[i];
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "long";
+ }
+}
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/CodeGen.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/CodeGen.java?rev=1471159&r1=1471158&r2=1471159&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/CodeGen.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/CodeGen.java Tue Apr 23 21:41:05 2013
@@ -254,6 +254,10 @@ public class CodeGen {
generateFilterColumnCompareScalar(tdesc);
} else if (tdesc[0].equals("ScalarArithmeticColumn")) {
generateScalarArithmeticColumn(tdesc);
+ } else if (tdesc[0].equals("FilterColumnCompareColumn")) {
+ generateFilterColumnCompareColumn(tdesc);
+ } else if (tdesc[0].equals("ColumnArithmeticColumn")) {
+ generateColumnArithmeticColumn(tdesc);
} else {
continue;
}
Added: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt?rev=1471159&view=auto
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt (added)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt Tue Apr 23 21:41:05 2013
@@ -0,0 +1,173 @@
+/**
+ * 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.*;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+public class <ClassName> extends VectorExpression {
+ int colNum1;
+ int colNum2;
+ int outputColumn;
+
+ public <ClassName>(int colNum1, int colNum2, int outputColumn) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ this.outputColumn = outputColumn;
+ }
+
+ @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;
+ <OperandType1>[] vector1 = inputColVector1.vector;
+ <OperandType2>[] vector2 = inputColVector2.vector;
+
+ <ReturnType>[] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ //Handle nulls first
+ if (inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isNull[0] = true;
+ outputColVector.isRepeating = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector2.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i];
+ }
+ }
+ }
+ } else if (!inputColVector1.noNulls && !inputColVector2.noNulls) {
+ outputColVector.noNulls = false;
+ if (inputColVector1.isRepeating || inputColVector2.isRepeating) {
+ //Output will also be repeating and null
+ outputColVector.isRepeating = true;
+ outputColVector.isNull[0] = true;
+ //return as no further processing is needed
+ return;
+ } else {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputColVector.isNull[i] = inputColVector1.isNull[i] || inputColVector2.isNull[i];
+ }
+ }
+ }
+ }
+
+
+ //Disregard nulls for processing
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ outputVector[0] = vector1[0] <OperatorSymbol> vector2[0];
+ outputColVector.isRepeating = true;
+ } else if (inputColVector1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[0] <OperatorSymbol> vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[0] <OperatorSymbol> vector2[i];
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] <OperatorSymbol> vector2[0];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] <OperatorSymbol> vector2[0];
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector1[i] <OperatorSymbol> vector2[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector1[i] <OperatorSymbol> vector2[i];
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "<ReturnType>";
+ }
+}
Added: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/FilterColumnCompareColumn.txt
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/FilterColumnCompareColumn.txt?rev=1471159&view=auto
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/FilterColumnCompareColumn.txt (added)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/FilterColumnCompareColumn.txt Tue Apr 23 21:41:05 2013
@@ -0,0 +1,222 @@
+/**
+ * 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.*;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+public class <ClassName> extends VectorExpression {
+ int colNum1;
+ int colNum2;
+
+ public <ClassName>(int colNum1, int colNum2) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+ <InputColumnVectorType1> inputColVector1 = (<InputColumnVectorType1>) batch.cols[colNum1];
+ <InputColumnVectorType2> inputColVector2 = (<InputColumnVectorType2>) batch.cols[colNum2];
+ int[] sel = batch.selected;
+ boolean[] nullPos1 = inputColVector1.isNull;
+ boolean[] nullPos2 = inputColVector2.isNull;
+ int n = batch.size;
+ <OperandType1>[] vector1 = inputColVector1.vector;
+ <OperandType2>[] vector2 = inputColVector2.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ if (inputColVector1.noNulls && inputColVector2.noNulls) {
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ if (!(vector1[0] <OperatorSymbol> vector2[0])) {
+ batch.size = 0;
+ }
+ } else if (inputColVector1.isRepeating) {
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (vector1[0] <OperatorSymbol> vector2[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (vector1[0] <OperatorSymbol> vector2[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (vector1[i] <OperatorSymbol> vector2[0]) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (vector1[i] <OperatorSymbol> vector2[0]) {
+ sel[newSize++] = i;
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (vector1[i] <OperatorSymbol> vector2[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (vector1[i] <OperatorSymbol> vector2[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ if (nullPos1[0] || nullPos2[0]) {
+ batch.size = 0;
+ }
+ } else if (inputColVector1.isRepeating) {
+ if (nullPos1[0]) {
+ batch.size = 0;
+ } else {
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos2[i]) {
+ if (vector1[0] <OperatorSymbol> vector2[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos2[i]) {
+ if (vector1[0] <OperatorSymbol> vector2[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (nullPos2[0]) {
+ batch.size = 0;
+ } else {
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos1[i]) {
+ if (vector1[i] <OperatorSymbol> vector2[0]) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos1[i]) {
+ if (vector1[i] <OperatorSymbol> vector2[0]) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ }
+ } else if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos1[i] && !nullPos2[i]) {
+ if (vector1[i] <OperatorSymbol> vector2[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos1[i] && !nullPos2[i]) {
+ if (vector1[i] <OperatorSymbol> vector2[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ }
+
+ @Override
+ public String getOutputType() {
+ return "boolean";
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return -1;
+ }
+}
Modified: hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorArithmeticExpressions.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorArithmeticExpressions.java?rev=1471159&r1=1471158&r2=1471159&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorArithmeticExpressions.java (original)
+++ hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorArithmeticExpressions.java Tue Apr 23 21:41:05 2013
@@ -18,11 +18,15 @@
package org.apache.hadoop.hive.ql.exec.vector.expressions;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import junit.framework.Assert;
import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
import org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch;
import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongColumn;
import org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalar;
import org.junit.Test;
@@ -113,4 +117,64 @@ public class TestVectorArithmeticExpress
Assert.assertFalse(out.noNulls);
Assert.assertEquals(true, out.isNull[0]);
}
+
+ @Test
+ public void testLongColAddLongColumn() {
+ int seed = 17;
+ VectorizedRowBatch vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(
+ VectorizedRowBatch.DEFAULT_SIZE,
+ 6, seed);
+ LongColumnVector lcv0 = (LongColumnVector) vrg.cols[0];
+ LongColumnVector lcv1 = (LongColumnVector) vrg.cols[1];
+ LongColumnVector lcv2 = (LongColumnVector) vrg.cols[2];
+ LongColumnVector lcv3 = (LongColumnVector) vrg.cols[3];
+ LongColumnVector lcv4 = (LongColumnVector) vrg.cols[4];
+ LongColumnVector lcv5 = (LongColumnVector) vrg.cols[5];
+ LongColAddLongColumn expr = new LongColAddLongColumn(0, 1, 2);
+ expr.evaluate(vrg);
+ for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
+ assertEquals((i+1) * seed * 3, lcv2.vector[i]);
+ }
+ assertTrue(lcv2.noNulls);
+
+ //Now set one column nullable
+ lcv1.noNulls = false;
+ lcv1.isNull[1] = true;
+ expr.evaluate(vrg);
+ assertTrue(lcv2.isNull[1]);
+ assertFalse(lcv2.noNulls);
+
+ //Now set other column nullable too
+ lcv0.noNulls = false;
+ lcv0.isNull[1] = true;
+ lcv0.isNull[3] = true;
+ expr.evaluate(vrg);
+ assertTrue(lcv2.isNull[1]);
+ assertTrue(lcv2.isNull[3]);
+ assertFalse(lcv2.noNulls);
+
+ //Now test with repeating flag
+ lcv3.isRepeating = true;
+ LongColAddLongColumn expr2 = new LongColAddLongColumn(3, 4, 5);
+ expr2.evaluate(vrg);
+ for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
+ assertEquals(seed * ( 4 + 5*(i+1)), lcv5.vector[i]);
+ }
+
+ //Repeating with other as nullable
+ lcv4.noNulls = false;
+ lcv4.isNull[0] = true;
+ expr2.evaluate(vrg);
+ assertTrue(lcv5.isNull[0]);
+ assertFalse(lcv5.noNulls);
+
+ //Repeating null value
+ lcv3.isRepeating = true;
+ lcv3.noNulls = false;
+ lcv3.isNull[0] = true;
+ expr2.evaluate(vrg);
+ assertFalse(lcv5.noNulls);
+ assertTrue(lcv5.isRepeating);
+ assertTrue(lcv5.isNull[0]);
+ }
}
Modified: hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorFilterExpressions.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorFilterExpressions.java?rev=1471159&r1=1471158&r2=1471159&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorFilterExpressions.java (original)
+++ hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorFilterExpressions.java Tue Apr 23 21:41:05 2013
@@ -1,9 +1,29 @@
+/**
+ * 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;
import static org.junit.Assert.assertEquals;
+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.gen.FilterLongColEqualLongScalar;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColGreaterLongColumn;
import org.junit.Test;
public class TestVectorFilterExpressions {
@@ -11,11 +31,38 @@ public class TestVectorFilterExpressions
@Test
public void testFilterLongColEqualLongScalar() {
VectorizedRowBatch vrg =
- VectorizedRowGroupGenUtil.getVectorizedRowBatch(1024, 2, 23);
- FilterLongColEqualLongScalar expr = new FilterLongColEqualLongScalar(1, 46);
+ VectorizedRowGroupGenUtil.getVectorizedRowBatch(1024, 1, 23);
+ FilterLongColEqualLongScalar expr = new FilterLongColEqualLongScalar(0, 46);
expr.evaluate(vrg);
assertEquals(1, vrg.size);
- assertEquals(2, vrg.selected[0]);
+ assertEquals(1, vrg.selected[0]);
}
+ @Test
+ public void testFilterLongColEqualLongColumn() {
+ int seed = 17;
+ VectorizedRowBatch vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(
+ VectorizedRowBatch.DEFAULT_SIZE,
+ 2, seed);
+ LongColumnVector lcv0 = (LongColumnVector) vrg.cols[0];
+ LongColumnVector lcv1 = (LongColumnVector) vrg.cols[1];
+ FilterLongColGreaterLongColumn expr = new FilterLongColGreaterLongColumn(0, 1);
+
+ //Basic case
+ lcv0.vector[1] = 23;
+ lcv1.vector[1] = 19;
+ lcv0.vector[5] = 23;
+ lcv1.vector[5] = 19;
+ expr.evaluate(vrg);
+ assertEquals(2, vrg.size);
+ assertEquals(1, vrg.selected[0]);
+ assertEquals(5, vrg.selected[1]);
+
+ //handle null
+ lcv0.noNulls = false;
+ lcv0.isNull[1] = true;
+ expr.evaluate(vrg);
+ assertEquals(1, vrg.size);
+ assertEquals(5, vrg.selected[0]);
+ }
}
Modified: hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorizedRowGroupGenUtil.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorizedRowGroupGenUtil.java?rev=1471159&r1=1471158&r2=1471159&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorizedRowGroupGenUtil.java (original)
+++ hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorizedRowGroupGenUtil.java Tue Apr 23 21:41:05 2013
@@ -1,3 +1,21 @@
+/**
+ * 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;
import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
@@ -10,7 +28,7 @@ public class VectorizedRowGroupGenUtil {
for (int j = 0; j < numCol; j++) {
LongColumnVector lcv = new LongColumnVector(size);
for (int i = 0; i < size; i++) {
- lcv.vector[i] = i * seed * j;
+ lcv.vector[i] = (i+1) * seed * (j+1);
}
vrg.cols[j] = lcv;
}