diff --git .gitignore .gitignore
index c0e9b3c..330d071 100644
--- .gitignore
+++ .gitignore
@@ -17,3 +17,4 @@ ql/derby.log
derby.log
.arc
ql/TempStatsStore
+data/files/*alltypesorc*
diff --git build-common.xml build-common.xml
index ee219a9..bd9f044 100644
--- build-common.xml
+++ build-common.xml
@@ -478,7 +478,7 @@
+ excludes="**/ql/exec/vector/util/*.class,**/TestSerDe.class,**/TestHiveMetaStore.class,**/TestBeeLineDriver.class,**/TestHiveServer2Concurrency.class,**/*$*.class,${test.junit.exclude}" />
diff --git common/src/java/org/apache/hadoop/hive/conf/HiveConf.java common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
index c5a8ff3..ff5d16d 100644
--- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
+++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
@@ -800,6 +800,9 @@
// Whether to show the unquoted partition names in query results.
HIVE_DECODE_PARTITION_NAME("hive.decode.partition.name", false),
+
+ //Vectorization enabled
+ HIVE_VECTORIZATION_ENABLED("hive.vectorized.execution.enabled", false),
;
public final String varname;
diff --git metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
index 15a2a81..9ffd399 100644
--- metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
+++ metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
@@ -52,6 +52,7 @@
import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
+import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
import org.apache.hadoop.hive.serde.serdeConstants;
import org.apache.hadoop.hive.serde2.Deserializer;
import org.apache.hadoop.hive.serde2.SerDeException;
diff --git ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticColumn.txt ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticColumn.txt
new file mode 100644
index 0000000..2ab4aec
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticColumn.txt
@@ -0,0 +1,157 @@
+/**
+ * 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;
+
+/**
+ * Generated from template ColumnArithmeticColumn.txt, which covers binary arithmetic
+ * expressions between columns.
+ */
+public class extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum1;
+ private int colNum2;
+ private int outputColumn;
+
+ public (int colNum1, int colNum2, int outputColumn) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ this.outputColumn = outputColumn;
+ }
+
+ public () {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ inputColVector1 = () batch.cols[colNum1];
+ inputColVector2 = () batch.cols[colNum2];
+ outputColVector = () batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ [] vector1 = inputColVector1.vector;
+ [] vector2 = inputColVector2.vector;
+ [] outputVector = outputColVector.vector;
+
+ // 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] = vector1[0] vector2[0];
+ } 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];
+ }
+ }
+ }
+
+ /* 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(outputColVector, batch.selectedInUse, sel, n);
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "";
+ }
+
+ 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;
+ }
+}
diff --git ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticScalar.txt ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticScalar.txt
new file mode 100644
index 0000000..35890f8
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticScalar.txt
@@ -0,0 +1,134 @@
+/**
+ * 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.;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.ql.exec.vector.expressions.NullUtil;
+
+/**
+ * Generated from template ColumnArithmeticScalar.txt, which covers binary arithmetic
+ * expressions between a column and a scalar.
+ */
+public class extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private value;
+ private int outputColumn;
+
+ public (int colNum, value, int outputColumn) {
+ this.colNum = colNum;
+ this.value = value;
+ this.outputColumn = outputColumn;
+ }
+
+ public () {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ inputColVector = () batch.cols[colNum];
+ outputColVector = () 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;
+ [] vector = inputColVector.vector;
+ [] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ if (inputColVector.isRepeating) {
+ outputVector[0] = vector[0] 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] = vector[i] value;
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector[i] value;
+ }
+ }
+ } else /* there are nulls */ {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector[i] value;
+ outputIsNull[i] = inputIsNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector[i] 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 "";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public getValue() {
+ return value;
+ }
+
+ public void setValue( value) {
+ this.value = value;
+ }
+
+ public void setOutputColumn(int outputColumn) {
+ this.outputColumn = outputColumn;
+ }
+}
diff --git ql/src/gen/vectorization/ExpressionTemplates/ColumnCompareScalar.txt ql/src/gen/vectorization/ExpressionTemplates/ColumnCompareScalar.txt
new file mode 100644
index 0000000..e333224
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/ColumnCompareScalar.txt
@@ -0,0 +1,149 @@
+/**
+ * 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.;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+/**
+ * Generated from template ColumnCompareScalar.txt, which covers binary comparison
+ * expressions between a column and a scalar. The boolean output is stored in a
+ * separate boolean column.
+ */
+public class extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private value;
+ private int outputColumn;
+
+ public (int colNum, value, int outputColumn) {
+ this.colNum = colNum;
+ this.value = value;
+ this.outputColumn = outputColumn;
+ }
+
+ public () {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ inputColVector = () batch.cols[colNum];
+ outputColVector = () batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ boolean[] nullPos = inputColVector.isNull;
+ boolean[] outNulls = outputColVector.isNull;
+ int n = batch.size;
+ [] vector = inputColVector.vector;
+ [] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ outputColVector.isRepeating = false;
+ outputColVector.noNulls = inputColVector.noNulls;
+ if (inputColVector.noNulls) {
+ if (inputColVector.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ outputVector[0] = vector[0] value ? 1 : 0;
+ outputColVector.isRepeating = true;
+ } else if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = vector[i] value ? 1 : 0;
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = vector[i] value ? 1 : 0;
+ }
+ }
+ } else {
+ if (inputColVector.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ if (!nullPos[0]) {
+ outputVector[0] = vector[0] value ? 1 : 0;
+ outNulls[0] = false;
+ } else {
+ outNulls[0] = true;
+ }
+ outputColVector.isRepeating = true;
+ } else if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos[i]) {
+ outputVector[i] = vector[i] value ? 1 : 0;
+ outNulls[i] = false;
+ } else {
+ //comparison with null is null
+ outNulls[i] = true;
+ }
+ }
+ } else {
+ System.arraycopy(nullPos, 0, outNulls, 0, n);
+ for(int i = 0; i != n; i++) {
+ if (!nullPos[i]) {
+ outputVector[i] = vector[i] value ? 1 : 0;
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public getValue() {
+ return value;
+ }
+
+ public void setValue( value) {
+ this.value = value;
+ }
+
+ public void setOutputColumn(int outputColumn) {
+ this.outputColumn = outputColumn;
+ }
+}
diff --git ql/src/gen/vectorization/ExpressionTemplates/ColumnUnaryMinus.txt ql/src/gen/vectorization/ExpressionTemplates/ColumnUnaryMinus.txt
new file mode 100644
index 0000000..085145a
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/ColumnUnaryMinus.txt
@@ -0,0 +1,122 @@
+/**
+ * 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;
+
+/**
+ * Generated from template ColumnUnaryMinus.txt, which covers unary negation operator.
+ */
+public class extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private int outputColumn;
+
+ public (int colNum, int outputColumn) {
+ this.colNum = colNum;
+ this.outputColumn = outputColumn;
+ }
+
+ public () {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ this.evaluateChildren(batch);
+ }
+
+ inputColVector = () batch.cols[colNum];
+ outputColVector = () batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ boolean[] inputIsNull = inputColVector.isNull;
+ boolean[] outputIsNull = outputColVector.isNull;
+ outputColVector.noNulls = inputColVector.noNulls;
+ int n = batch.size;
+ [] vector = inputColVector.vector;
+ [] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ if (inputColVector.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ outputVector[0] = - vector[0];
+ // Even if there are no nulls, we always copy over entry 0. Simplifies code.
+ outputIsNull[0] = inputIsNull[0];
+ outputColVector.isRepeating = true;
+ } else if (inputColVector.noNulls) {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = -vector[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = -vector[i];
+ }
+ }
+ outputColVector.isRepeating = false;
+ } else /* there are nulls */ {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = -vector[i];
+ outputIsNull[i] = inputIsNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = -vector[i];
+ }
+ System.arraycopy(inputIsNull, 0, outputIsNull, 0, n);
+ }
+ outputColVector.isRepeating = false;
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public void setOutputColumn(int outputColumn) {
+ this.outputColumn = outputColumn;
+ }
+}
diff --git ql/src/gen/vectorization/ExpressionTemplates/FilterColumnCompareColumn.txt ql/src/gen/vectorization/ExpressionTemplates/FilterColumnCompareColumn.txt
new file mode 100644
index 0000000..1c16816
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/FilterColumnCompareColumn.txt
@@ -0,0 +1,254 @@
+/**
+ * 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;
+
+/**
+ * Generated from template FilterColumnCompareColumn.txt, which covers binary comparison
+ * expressions between two columns, however output is not produced in a separate column.
+ * The selected vector of the input {@link VectorizedRowBatch} is updated for in-place filtering.
+ */
+public class extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum1;
+ private int colNum2;
+
+ public (int colNum1, int colNum2) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ }
+
+ public () {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ inputColVector1 = () batch.cols[colNum1];
+ inputColVector2 = () batch.cols[colNum2];
+ int[] sel = batch.selected;
+ boolean[] nullPos1 = inputColVector1.isNull;
+ boolean[] nullPos2 = inputColVector2.isNull;
+ int n = batch.size;
+ [] vector1 = inputColVector1.vector;
+ [] 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] 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] vector2[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (vector1[0] 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] vector2[0]) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (vector1[i] 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] vector2[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (vector1[i] 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] 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] 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] 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] 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] 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] 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;
+ }
+
+ 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;
+ }
+}
diff --git ql/src/gen/vectorization/ExpressionTemplates/FilterColumnCompareScalar.txt ql/src/gen/vectorization/ExpressionTemplates/FilterColumnCompareScalar.txt
new file mode 100644
index 0000000..bf02419
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/FilterColumnCompareScalar.txt
@@ -0,0 +1,158 @@
+/**
+ * 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;
+
+/**
+ * Generated from template FilterColumnCompareScalar.txt, which covers binary comparison
+ * expressions between a column and a scalar, however output is not produced in a separate column.
+ * The selected vector of the input {@link VectorizedRowBatch} is updated for in-place filtering.
+ */
+public class extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private value;
+
+ public (int colNum, value) {
+ this.colNum = colNum;
+ this.value = value;
+ }
+
+ public () {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ inputColVector = () batch.cols[colNum];
+ int[] sel = batch.selected;
+ boolean[] nullPos = inputColVector.isNull;
+ int n = batch.size;
+ [] vector = inputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ if (inputColVector.noNulls) {
+ if (inputColVector.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ if (!(vector[0] value)) {
+ //Entire batch is filtered out.
+ batch.size = 0;
+ }
+ } else if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (vector[i] value) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (vector[i] value) {
+ sel[newSize++] = i;
+ }
+ }
+ if (newSize < n) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else {
+ if (inputColVector.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ if (!nullPos[0]) {
+ if (!(vector[0] value)) {
+ //Entire batch is filtered out.
+ batch.size = 0;
+ }
+ } else {
+ batch.size = 0;
+ }
+ } else if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos[i]) {
+ if (vector[i] value) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ //Change the selected vector
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos[i]) {
+ if (vector[i] value) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < n) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return -1;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "boolean";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public getValue() {
+ return value;
+ }
+
+ public void setValue( value) {
+ this.value = value;
+ }
+}
diff --git ql/src/gen/vectorization/ExpressionTemplates/FilterScalarCompareColumn.txt ql/src/gen/vectorization/ExpressionTemplates/FilterScalarCompareColumn.txt
new file mode 100644
index 0000000..9a1d741
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/FilterScalarCompareColumn.txt
@@ -0,0 +1,158 @@
+/**
+ * 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;
+
+/**
+ * Generated from template FilterScalarCompareColumn.txt, which covers binary comparison
+ * expressions between a scalar and a column, however output is not produced in a separate column.
+ * The selected vector of the input {@link VectorizedRowBatch} is updated for in-place filtering.
+ */
+public class extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private value;
+
+ public (int colNum, value) {
+ this.colNum = colNum;
+ this.value = value;
+ }
+
+ public () {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ inputColVector = () batch.cols[colNum];
+ int[] sel = batch.selected;
+ boolean[] nullPos = inputColVector.isNull;
+ int n = batch.size;
+ [] vector = inputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ if (inputColVector.noNulls) {
+ if (inputColVector.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ if (!(value vector[0])) {
+ //Entire batch is filtered out.
+ batch.size = 0;
+ }
+ } else if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (value vector[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (value vector[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ if (newSize < n) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else {
+ if (inputColVector.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ if (!nullPos[0]) {
+ if (!(value vector[0])) {
+ //Entire batch is filtered out.
+ batch.size = 0;
+ }
+ } else {
+ batch.size = 0;
+ }
+ } else if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos[i]) {
+ if (value vector[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ //Change the selected vector
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos[i]) {
+ if (value vector[i]) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < n) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return -1;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "boolean";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public getValue() {
+ return value;
+ }
+
+ public void setValue( value) {
+ this.value = value;
+ }
+}
diff --git ql/src/gen/vectorization/ExpressionTemplates/FilterStringColumnCompareColumn.txt ql/src/gen/vectorization/ExpressionTemplates/FilterStringColumnCompareColumn.txt
new file mode 100644
index 0000000..449c010
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/FilterStringColumnCompareColumn.txt
@@ -0,0 +1,477 @@
+/**
+ * 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.StringExpr;
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+/**
+ * Filter the rows in a batch by comparing one string column to another.
+ * This code is generated from a template.
+ */
+public class extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum1;
+ private int colNum2;
+
+ public (int colNum1, int colNum2) {
+ this.colNum1 = colNum1;
+ this.colNum2 = colNum2;
+ }
+
+ public () {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+
+ BytesColumnVector inputColVector1 = (BytesColumnVector) batch.cols[colNum1];
+ BytesColumnVector inputColVector2 = (BytesColumnVector) batch.cols[colNum2];
+ int[] sel = batch.selected;
+ boolean[] nullPos1 = inputColVector1.isNull;
+ boolean[] nullPos2 = inputColVector2.isNull;
+ int n = batch.size;
+ byte[][] vector1 = inputColVector1.vector;
+ byte[][] vector2 = inputColVector2.vector;
+ int[] start1 = inputColVector1.start;
+ int[] start2 = inputColVector2.start;
+ int[] length1 = inputColVector1.length;
+ int[] length2 = inputColVector2.length;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ // handle case where neither input has nulls
+ if (inputColVector1.noNulls && inputColVector2.noNulls) {
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+
+ /* Either all must remain selected or all will be eliminated.
+ * Repeating property will not change.
+ */
+ if (!(StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[0], start2[0], length2[0]) 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 (StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[i], start2[i], length2[i]) 0) {
+ 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 (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[0], start2[0], length2[0]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[0], start2[0], length2[0]) 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 (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+
+ // handle case where only input 2 has nulls
+ } else if (inputColVector1.noNulls) {
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ if (nullPos2[0] ||
+ !(StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[0], start2[0], length2[0]) 0)) {
+ batch.size = 0;
+ }
+ } else if (inputColVector1.isRepeating) {
+
+ // no need to check for nulls in input 1
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos2[i]) {
+ if (StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos2[i]) {
+ if (StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (nullPos2[0]) {
+
+ // no values will qualify because every comparison will be with NULL
+ batch.size = 0;
+ return;
+ }
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[0], start2[0], length2[0]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[0], start2[0], length2[0]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else { // neither input is repeating
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos2[i]) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos2[i]) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ }
+
+ // handle case where only input 1 has nulls
+ } else if (inputColVector2.noNulls) {
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ if (nullPos1[0] ||
+ !(StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[0], start2[0], length2[0]) 0)) {
+ batch.size = 0;
+ return;
+ }
+ } else if (inputColVector1.isRepeating) {
+ if (nullPos1[0]) {
+
+ // if repeating value is null then every comparison will fail so nothing qualifies
+ batch.size = 0;
+ return;
+ }
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[i], start2[i], length2[i]) 0) {
+ 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 (!nullPos1[i]) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[0], start2[0], length2[0]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos2[i]) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[0], start2[0], length2[0]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else { // neither input is repeating
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos1[i]) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos1[i]) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ }
+
+ // handle case where both inputs have nulls
+ } else {
+ if (inputColVector1.isRepeating && inputColVector2.isRepeating) {
+ if (nullPos1[0] || nullPos2[0] ||
+ !(StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[0], start2[0], length2[0]) 0)) {
+ batch.size = 0;
+ }
+ } else if (inputColVector1.isRepeating) {
+ if (nullPos1[0]) {
+ batch.size = 0;
+ return;
+ }
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos2[i]) {
+ if (StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos2[i]) {
+ if (StringExpr.compare(vector1[0], start1[0], length1[0],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else if (inputColVector2.isRepeating) {
+ if (nullPos2[0]) {
+ batch.size = 0;
+ return;
+ }
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos1[i]) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[0], start2[0], length2[0]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos1[i]) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[0], start2[0], length2[0]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < batch.size) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else { // neither input is repeating
+ if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos1[i] && !nullPos2[i]) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[i], start2[i], length2[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos1[i] && !nullPos2[i]) {
+ if (StringExpr.compare(vector1[i], start1[i], length1[i],
+ vector2[i], start2[i], length2[i]) 0) {
+ 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;
+ }
+
+ 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;
+ }
+}
diff --git ql/src/gen/vectorization/ExpressionTemplates/FilterStringColumnCompareScalar.txt ql/src/gen/vectorization/ExpressionTemplates/FilterStringColumnCompareScalar.txt
new file mode 100644
index 0000000..690dd3c
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/FilterStringColumnCompareScalar.txt
@@ -0,0 +1,161 @@
+/**
+ * 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.StringExpr;
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+/**
+ * This is a generated class to evaluate a comparison on a vector of strings.
+ */
+public class extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private byte[] value;
+
+ public (int colNum, byte[] value) {
+ this.colNum = colNum;
+ this.value = value;
+ }
+
+ public () {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+ BytesColumnVector inputColVector = (BytesColumnVector) batch.cols[colNum];
+ int[] sel = batch.selected;
+ boolean[] nullPos = inputColVector.isNull;
+ int n = batch.size;
+ byte[][] vector = inputColVector.vector;
+ int[] length = inputColVector.length;
+ int[] start = inputColVector.start;
+
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ if (inputColVector.noNulls) {
+ if (inputColVector.isRepeating) {
+
+ // All must be selected otherwise size would be zero. Repeating property will not change.
+ if (!(StringExpr.compare(vector[0], start[0], length[0], value, 0, value.length) 0)) {
+
+ //Entire batch is filtered out.
+ batch.size = 0;
+ }
+ } else if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (StringExpr.compare(vector[i], start[i], length[i], value, 0, value.length) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (StringExpr.compare(vector[i], start[i], length[i], value, 0, value.length) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ if (newSize < n) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else {
+ if (inputColVector.isRepeating) {
+
+ // All must be selected otherwise size would be zero. Repeating property will not change.
+ if (!nullPos[0]) {
+ if (!(StringExpr.compare(vector[0], start[0], length[0], value, 0, value.length) 0)) {
+
+ //Entire batch is filtered out.
+ batch.size = 0;
+ }
+ } else {
+ batch.size = 0;
+ }
+ } else if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos[i]) {
+ if (StringExpr.compare(vector[i], start[i], length[i], value, 0, value.length) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+
+ //Change the selected vector
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos[i]) {
+ if (StringExpr.compare(vector[i], start[i], length[i], value, 0, value.length) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < n) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return -1;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "boolean";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public byte[] getValue() {
+ return value;
+ }
+
+ public void setValue(byte[] value) {
+ this.value = value;
+ }
+}
diff --git ql/src/gen/vectorization/ExpressionTemplates/FilterStringScalarCompareColumn.txt ql/src/gen/vectorization/ExpressionTemplates/FilterStringScalarCompareColumn.txt
new file mode 100644
index 0000000..5ba7703
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/FilterStringScalarCompareColumn.txt
@@ -0,0 +1,162 @@
+/**
+ * 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.StringExpr;
+import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+/**
+ * This is a generated class to evaluate a comparison on a vector of strings.
+ * Do not edit the generated code directly.
+ */
+public class extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private byte[] value;
+
+ public (int colNum, byte[] value) {
+ this.colNum = colNum;
+ this.value = value;
+ }
+
+ public () {
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+ if (childExpressions != null) {
+ super.evaluateChildren(batch);
+ }
+ BytesColumnVector inputColVector = (BytesColumnVector) batch.cols[colNum];
+ int[] sel = batch.selected;
+ boolean[] nullPos = inputColVector.isNull;
+ int n = batch.size;
+ byte[][] vector = inputColVector.vector;
+ int[] length = inputColVector.length;
+ int[] start = inputColVector.start;
+
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ if (inputColVector.noNulls) {
+ if (inputColVector.isRepeating) {
+
+ // All must be selected otherwise size would be zero. Repeating property will not change.
+ if (!(StringExpr.compare(value, 0, value.length, vector[0], start[0], length[0]) 0)) {
+
+ //Entire batch is filtered out.
+ batch.size = 0;
+ }
+ } else if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (StringExpr.compare(value, 0, value.length, vector[i], start[i], length[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (StringExpr.compare(value, 0, value.length, vector[i], start[i], length[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ if (newSize < n) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ } else {
+ if (inputColVector.isRepeating) {
+
+ // All must be selected otherwise size would be zero. Repeating property will not change.
+ if (!nullPos[0]) {
+ if (!(StringExpr.compare(value, 0, value.length, vector[0], start[0], length[0]) 0)) {
+
+ //Entire batch is filtered out.
+ batch.size = 0;
+ }
+ } else {
+ batch.size = 0;
+ }
+ } else if (batch.selectedInUse) {
+ int newSize = 0;
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!nullPos[i]) {
+ if (StringExpr.compare(value, 0, value.length, vector[i], start[i], length[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+
+ //Change the selected vector
+ batch.size = newSize;
+ } else {
+ int newSize = 0;
+ for(int i = 0; i != n; i++) {
+ if (!nullPos[i]) {
+ if (StringExpr.compare(value, 0, value.length, vector[i], start[i], length[i]) 0) {
+ sel[newSize++] = i;
+ }
+ }
+ }
+ if (newSize < n) {
+ batch.size = newSize;
+ batch.selectedInUse = true;
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return -1;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "boolean";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public byte[] getValue() {
+ return value;
+ }
+
+ public void setValue(byte[] value) {
+ this.value = value;
+ }
+}
diff --git ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumn.txt ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumn.txt
new file mode 100644
index 0000000..d9efbe7
--- /dev/null
+++ ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumn.txt
@@ -0,0 +1,147 @@
+/**
+ * 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;
+
+/*
+ * 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 ScalarArithmeticColumn.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 extends VectorExpression {
+
+ private static final long serialVersionUID = 1L;
+
+ private int colNum;
+ private value;
+ private int outputColumn;
+
+ public ( value, int colNum, int outputColumn) {
+ this.colNum = colNum;
+ this.value = value;
+ this.outputColumn = outputColumn;
+ }
+
+ public () {
+ }
+
+ @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);
+ }
+
+ inputColVector = () batch.cols[colNum];
+ outputColVector = () 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;
+ [] vector = inputColVector.vector;
+ [] outputVector = outputColVector.vector;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ if (inputColVector.isRepeating) {
+ outputVector[0] = value 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 vector[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = value vector[i];
+ }
+ }
+ } else { /* there are nulls */
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outputVector[i] = value vector[i];
+ outputIsNull[i] = inputIsNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outputVector[i] = value 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 "";
+ }
+
+ public int getColNum() {
+ return colNum;
+ }
+
+ public void setColNum(int colNum) {
+ this.colNum = colNum;
+ }
+
+ public getValue() {
+ return value;
+ }
+
+ public void setValue( value) {
+ this.value = value;
+ }
+
+ public void setOutputColumn(int outputColumn) {
+ this.outputColumn = outputColumn;
+ }
+
+}
diff --git ql/src/gen/vectorization/TestTemplates/TestClass.txt ql/src/gen/vectorization/TestTemplates/TestClass.txt
new file mode 100644
index 0000000..c8de5de
--- /dev/null
+++ ql/src/gen/vectorization/TestTemplates/TestClass.txt
@@ -0,0 +1,44 @@
+/**
+ * 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 static org.junit.Assert.assertEquals;
+import java.util.Random;
+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.util.VectorizedRowGroupGenUtil;
+import org.junit.Test;
+
+
+/**
+ *
+ * .
+ *
+ */
+public class {
+
+ private static final int BATCH_SIZE = 100;
+ private static final long SEED = 0xfa57;
+
+
+
+}
+
+
diff --git ql/src/gen/vectorization/TestTemplates/TestColumnColumnFilterVectorExpressionEvaluation.txt ql/src/gen/vectorization/TestTemplates/TestColumnColumnFilterVectorExpressionEvaluation.txt
new file mode 100644
index 0000000..2bb1aa3
--- /dev/null
+++ ql/src/gen/vectorization/TestTemplates/TestColumnColumnFilterVectorExpressionEvaluation.txt
@@ -0,0 +1,69 @@
+
+ @Test
+ public void () {
+
+ Random rand = new Random(SEED);
+
+ inputColumnVector1 =
+ VectorizedRowGroupGenUtil.generate(,
+ , BATCH_SIZE, rand);
+
+ inputColumnVector2 =
+ VectorizedRowGroupGenUtil.generate(,
+ , BATCH_SIZE, rand);
+
+ VectorizedRowBatch rowBatch = new VectorizedRowBatch(2, BATCH_SIZE);
+ rowBatch.cols[0] = inputColumnVector1;
+ rowBatch.cols[1] = inputColumnVector2;
+
+ vectorExpression =
+ new (0, 1);
+
+ vectorExpression.evaluate(rowBatch);
+
+ int selectedIndex = 0;
+ for(int i = 0; i < BATCH_SIZE; i++) {
+ //null vector is safe to check, as it is always initialized to match the data vector
+ if(!inputColumnVector1.isNull[i] && !inputColumnVector2.isNull[i]) {
+ if(inputColumnVector1.vector[i] inputColumnVector2.vector[i]) {
+ assertEquals(
+ "Vector index that passes filter "
+ + inputColumnVector1.vector[i] + ""
+ + inputColumnVector2.vector[i] + " is not in rowBatch selected index",
+ i,
+ rowBatch.selected[selectedIndex]);
+ selectedIndex++;
+ }
+ }
+ }
+
+ assertEquals("Row batch size not set to number of selected rows: " + selectedIndex,
+ selectedIndex, rowBatch.size);
+
+ if(selectedIndex > 0 && selectedIndex < BATCH_SIZE) {
+ assertEquals(
+ "selectedInUse should be set when > 0 and < entire batch(" + BATCH_SIZE + ") is selected: "
+ + selectedIndex,
+ true, rowBatch.selectedInUse);
+ } else if(selectedIndex == BATCH_SIZE) {
+ assertEquals(
+ "selectedInUse should not be set when entire batch(" + BATCH_SIZE + ") is selected: "
+ + selectedIndex,
+ false, rowBatch.selectedInUse);
+ }
+ }
\ No newline at end of file
diff --git ql/src/gen/vectorization/TestTemplates/TestColumnColumnOperationVectorExpressionEvaluation.txt ql/src/gen/vectorization/TestTemplates/TestColumnColumnOperationVectorExpressionEvaluation.txt
new file mode 100644
index 0000000..4ab3e76
--- /dev/null
+++ ql/src/gen/vectorization/TestTemplates/TestColumnColumnOperationVectorExpressionEvaluation.txt
@@ -0,0 +1,64 @@
+
+ @Test
+ public void () {
+
+ Random rand = new Random(SEED);
+
+ outputColumnVector =
+ VectorizedRowGroupGenUtil.generate(,
+ , BATCH_SIZE, rand);
+
+ inputColumnVector1 =
+ VectorizedRowGroupGenUtil.generate(,
+ , BATCH_SIZE, rand);
+
+ inputColumnVector2 =
+ VectorizedRowGroupGenUtil.generate(,
+ , BATCH_SIZE, rand);
+
+ VectorizedRowBatch rowBatch = new VectorizedRowBatch(3, BATCH_SIZE);
+ rowBatch.cols[0] = inputColumnVector1;
+ rowBatch.cols[1] = inputColumnVector2;
+ rowBatch.cols[2] = outputColumnVector;
+
+ vectorExpression =
+ new (0, 1, 2);
+
+ vectorExpression.evaluate(rowBatch);
+
+ assertEquals(
+ "Output column vector repeating state does not match operand columns",
+ (!inputColumnVector1.noNulls && inputColumnVector1.isRepeating)
+ || (!inputColumnVector2.noNulls && inputColumnVector2.isRepeating)
+ || inputColumnVector1.isRepeating && inputColumnVector2.isRepeating,
+ outputColumnVector.isRepeating);
+
+ assertEquals(
+ "Output column vector no nulls state does not match operand columns",
+ inputColumnVector1.noNulls && inputColumnVector2.noNulls, outputColumnVector.noNulls);
+
+ //if repeating, only the first value matters
+ if(!outputColumnVector.noNulls && !outputColumnVector.isRepeating) {
+ for(int i = 0; i < BATCH_SIZE; i++) {
+ //null vectors are safe to check, as they are always initialized to match the data vector
+ assertEquals("Output vector doesn't match input vectors' is null state for index",
+ inputColumnVector1.isNull[i] || inputColumnVector2.isNull[i],
+ outputColumnVector.isNull[i]);
+ }
+ }
+ }
\ No newline at end of file
diff --git ql/src/gen/vectorization/TestTemplates/TestColumnScalarFilterVectorExpressionEvaluation.txt ql/src/gen/vectorization/TestTemplates/TestColumnScalarFilterVectorExpressionEvaluation.txt
new file mode 100644
index 0000000..af30490
--- /dev/null
+++ ql/src/gen/vectorization/TestTemplates/TestColumnScalarFilterVectorExpressionEvaluation.txt
@@ -0,0 +1,78 @@
+
+ @Test
+ public void () {
+
+ Random rand = new Random(SEED);
+
+ inputColumnVector =
+ VectorizedRowGroupGenUtil.generate(,
+ , BATCH_SIZE, rand);
+
+ VectorizedRowBatch rowBatch = new VectorizedRowBatch(1, BATCH_SIZE);
+ rowBatch.cols[0] = inputColumnVector;
+
+ scalarValue = 0;
+ do {
+ scalarValue = rand.next();
+ } while(scalarValue == 0);
+
+ vectorExpression =
+ new (0, scalarValue);
+
+ vectorExpression.evaluate(rowBatch);
+
+
+ int selectedIndex = 0;
+ int i=0;
+ //check for isRepeating optimization
+ if(inputColumnVector.isRepeating) {
+ //null vector is safe to check, as it is always initialized to match the data vector
+ selectedIndex =
+ !inputColumnVector.isNull[i] &&
+ ? BATCH_SIZE : 0;
+ } else {
+ for(i = 0; i < BATCH_SIZE; i++) {
+ if(!inputColumnVector.isNull[i]) {
+ if( ) {
+ assertEquals(
+ "Vector index that passes filter "
+ + + ""
+ + + " is not in rowBatch selected index",
+ i,
+ rowBatch.selected[selectedIndex]);
+ selectedIndex++;
+ }
+ }
+ }
+ }
+
+ assertEquals("Row batch size not set to number of selected rows: " + selectedIndex,
+ selectedIndex, rowBatch.size);
+
+ if(selectedIndex > 0 && selectedIndex < BATCH_SIZE) {
+ assertEquals(
+ "selectedInUse should be set when > 0 and < entire batch(" + BATCH_SIZE + ") is selected: "
+ + selectedIndex,
+ true, rowBatch.selectedInUse);
+ } else if(selectedIndex == BATCH_SIZE) {
+ assertEquals(
+ "selectedInUse should not be set when entire batch(" + BATCH_SIZE + ") is selected: "
+ + selectedIndex,
+ false, rowBatch.selectedInUse);
+ }
+ }
\ No newline at end of file
diff --git ql/src/gen/vectorization/TestTemplates/TestColumnScalarOperationVectorExpressionEvaluation.txt ql/src/gen/vectorization/TestTemplates/TestColumnScalarOperationVectorExpressionEvaluation.txt
new file mode 100644
index 0000000..e5f3f18
--- /dev/null
+++ ql/src/gen/vectorization/TestTemplates/TestColumnScalarOperationVectorExpressionEvaluation.txt
@@ -0,0 +1,59 @@
+
+ @Test
+ public void () {
+
+ Random rand = new Random(SEED);
+
+ outputColumnVector =
+ VectorizedRowGroupGenUtil.generate(,
+