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/05/02 04:08:03 UTC
svn commit: r1478253 - in /hive/branches/vectorization/ql/src:
java/org/apache/hadoop/hive/ql/exec/vector/
java/org/apache/hadoop/hive/ql/exec/vector/expressions/
java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/
java/org/apache/hadoop/hive/q...
Author: hashutosh
Date: Thu May 2 02:08:03 2013
New Revision: 1478253
URL: http://svn.apache.org/r1478253
Log:
HIVE-4431 : Implement vectorized string concatenation (Eric Hanson via Ashutosh Chauhan)
Added:
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatColCol.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatColScalar.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatScalarCol.java
Modified:
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/BytesColumnVector.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColAddDoubleColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColAddLongColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColDivideDoubleColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColDivideLongColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColMultiplyDoubleColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColMultiplyLongColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColSubtractDoubleColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColSubtractLongColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColAddDoubleColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColAddLongColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColDivideDoubleColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColDivideLongColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java
hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt
hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorArithmeticExpressions.java
hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/BytesColumnVector.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/BytesColumnVector.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/BytesColumnVector.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/BytesColumnVector.java Thu May 2 02:08:03 2013
@@ -150,6 +150,34 @@ public class BytesColumnVector extends C
}
/**
+ * Set a field to the concatenation of two string values. Result data is copied
+ * into the internal buffer.
+ *
+ * @param elementNum index within column vector to set
+ * @param leftSourceBuf container of left argument
+ * @param leftStart start of left argument
+ * @param leftLen length of left argument
+ * @param rightSourceBuf container of right argument
+ * @param rightStart start of right argument
+ * @param rightLen length of right arugment
+ */
+ public void setConcat(int elementNum, byte[] leftSourceBuf, int leftStart, int leftLen,
+ byte[] rightSourceBuf, int rightStart, int rightLen) {
+ int newLen = leftLen + rightLen;
+ if ((nextFree + newLen) > buffer.length) {
+ increaseBufferSpace(newLen);
+ }
+ vector[elementNum] = buffer;
+ this.start[elementNum] = nextFree;
+ this.length[elementNum] = newLen;
+
+ System.arraycopy(leftSourceBuf, leftStart, buffer, nextFree, leftLen);
+ nextFree += leftLen;
+ System.arraycopy(rightSourceBuf, rightStart, buffer, nextFree, rightLen);
+ nextFree += rightLen;
+ }
+
+ /**
* Increase buffer space enough to accommodate next element.
* This uses an exponential increase mechanism to rapidly
* increase buffer size to enough to hold all data.
Added: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatColCol.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatColCol.java?rev=1478253&view=auto
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatColCol.java (added)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatColCol.java Thu May 2 02:08:03 2013
@@ -0,0 +1,414 @@
+/**
+ * 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.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.ColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+/**
+ * Vectorized instruction to concatenate two string columns and put
+ * the output in a third column.
+ */
+public class StringConcatColCol extends VectorExpression {
+ private int colNum1;
+ private int colNum2;
+ private int outputColumn;
+
+ public StringConcatColCol(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);
+ }
+
+ BytesColumnVector inV1 = (BytesColumnVector) batch.cols[colNum1];
+ BytesColumnVector inV2 = (BytesColumnVector) batch.cols[colNum2];
+ BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ byte[][] vector1 = inV1.vector;
+ byte[][] vector2 = inV2.vector;
+ int[] len1 = inV1.length;
+ int[] len2 = inV2.length;
+ int[] start1 = inV1.start;
+ int[] start2 = inV2.start;
+
+ // return immediately if batch is empty
+ if (n == 0) {
+ return;
+ }
+
+ // prepare output buffer to accept results
+ outV.initBuffer();
+
+ /* Handle default case for isRepeating setting for output. This will be set to true
+ * later in the special cases where that is necessary.
+ */
+ outV.isRepeating = false;
+
+ if (inV1.noNulls && !inV2.noNulls) {
+
+ // propagate nulls
+
+ /* We'll assume that there *may* be nulls in the input if !noNulls is true
+ * for an input vector. This is to be more forgiving of errors in loading
+ * the vectors. A properly-written vectorized iterator will make sure that
+ * isNull[0] is set if !noNulls and isRepeating are true for the vector.
+ */
+ outV.noNulls = false;
+ if (inV2.isRepeating) {
+ if (inV2.isNull[0]) {
+
+ // Output will also be repeating and null
+ outV.isNull[0] = true;
+ outV.isRepeating = true;
+
+ //return as no further processing is needed
+ return;
+ }
+ } else {
+ propagateNulls(batch.selectedInUse, n, sel, inV2, outV);
+ }
+
+ // perform data operation
+ if (inV1.isRepeating && inV2.isRepeating) {
+
+ /* All must be selected otherwise size would be zero.
+ * Repeating property will not change.
+ */
+ if (!inV2.isNull[0]) {
+ outV.setConcat(0, vector1[0], start1[0], len1[0], vector2[0], start2[0], len2[0]);
+ }
+ outV.isRepeating = true;
+ } else if (inV1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!inV2.isNull[i]) {
+ outV.setConcat(i, vector1[0], start1[0], len1[0], vector2[i], start2[i], len2[i]);
+ }
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inV2.isNull[0]) {
+ outV.setConcat(i, vector1[0], start1[0], len1[0], vector2[i], start2[i], len2[i]);
+ }
+ }
+ }
+ } else if (inV2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!inV2.isNull[i]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[0], start2[0], len2[0]);
+ }
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inV2.isNull[i]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[0], start2[0], len2[0]);
+ }
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!inV2.isNull[i]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[i], start2[i], len2[i]);
+ }
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inV2.isNull[i]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[i], start2[i], len2[i]);
+ }
+ }
+ }
+ }
+ } else if (!inV1.noNulls && inV2.noNulls) {
+
+ // propagate nulls
+ outV.noNulls = false;
+ if (inV1.isRepeating) {
+
+ //Output will also be repeating and null
+ outV.isRepeating = true;
+ outV.isNull[0] = true;
+
+ //return as no further processing is needed
+ return;
+ } else {
+ propagateNulls(batch.selectedInUse, n, sel, inV1, outV);
+ }
+
+ // perform data operation
+ if (inV1.isRepeating && inV2.isRepeating) {
+ //All must be selected otherwise size would be zero
+ //Repeating property will not change.
+ if (!inV1.isNull[0]) {
+ outV.setConcat(0, vector1[0], start1[0], len1[0], vector2[0], start2[0], len2[0]);
+ }
+ outV.isRepeating = true;
+ } else if (inV1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!inV1.isNull[0]) {
+ outV.setConcat(i, vector1[0], start1[0], len1[0], vector2[i], start2[i], len2[i]);
+ }
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inV1.isNull[0]) {
+ outV.setConcat(i, vector1[0], start1[0], len1[0], vector2[i], start2[i], len2[i]);
+ }
+ }
+ }
+ } else if (inV2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!inV1.isNull[i]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[0], start2[0], len2[0]);
+ }
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inV1.isNull[i]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[0], start2[0], len2[0]);
+ }
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!inV1.isNull[i]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[i], start2[i], len2[i]);
+ }
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inV1.isNull[i]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[i], start2[i], len2[i]);
+ }
+ }
+ }
+ }
+ } else if (!inV1.noNulls && !inV2.noNulls) {
+
+ // propagate nulls
+ outV.noNulls = false;
+ if (inV1.isRepeating && inV2.isRepeating) {
+ outV.isNull[0] = inV1.isNull[0] || inV2.isNull[0];
+
+ //Output will also be repeating
+ outV.isRepeating = true;
+
+ // return if output is null because no additional work is needed
+ if (outV.isNull[0]) {
+ return;
+ }
+ } else if (inV1.isRepeating) {
+ if (inV1.isNull[0]) { // then all output will be null
+ outV.isRepeating = true;
+ outV.isNull[0] = true;
+ return;
+ } else {
+ outV.isRepeating = false;
+ propagateNulls(batch.selectedInUse, n, sel, inV2, outV);
+ }
+ } else if (inV2.isRepeating) {
+ if (inV2.isNull[0]) {
+ outV.isRepeating = true;
+ outV.isNull[0] = true;
+ return;
+ } else {
+ outV.isRepeating = false;
+ propagateNulls(batch.selectedInUse, n, sel, inV1, outV);
+ }
+ } else {
+ propagateNullsCombine(batch.selectedInUse, n, sel, inV1, inV2, outV);
+ }
+
+ // perform data operation
+ if (inV1.isRepeating && inV2.isRepeating) {
+
+ // All must be selected otherwise size would be zero. Repeating property will not change.
+ if (!inV1.isNull[0] && !inV2.isNull[0]) {
+ outV.setConcat(0, vector1[0], start1[0], len1[0], vector2[0], start2[0], len2[0]);
+ }
+ outV.isRepeating = true;
+ } else if (inV1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!inV1.isNull[0] && !inV2.isNull[i]) {
+ outV.setConcat(i, vector1[0], start1[0], len1[0], vector2[i], start2[i], len2[i]);
+ }
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inV1.isNull[0] && !inV2.isNull[i]) {
+ outV.setConcat(i, vector1[0], start1[0], len1[0], vector2[i], start2[i], len2[i]);
+ }
+ }
+ }
+ } else if (inV2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!inV1.isNull[i] && !inV2.isNull[0]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[0], start2[0], len2[0]);
+ }
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inV1.isNull[i] && !inV2.isNull[0]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[0], start2[0], len2[0]);
+ }
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ if (!inV1.isNull[i] && !inV2.isNull[i]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[i], start2[i], len2[i]);
+ }
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inV1.isNull[i] && !inV2.isNull[i]) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[i], start2[i], len2[i]);
+ }
+ }
+ }
+ }
+ } else { // there are no nulls in either input vector
+
+ // propagate null information
+ outV.noNulls = true;
+
+ // perform data operation
+ if (inV1.isRepeating && inV2.isRepeating) {
+
+ // All must be selected otherwise size would be zero. Repeating property will not change.
+ outV.setConcat(0, vector1[0], start1[0], len1[0], vector2[0], start2[0], len2[0]);
+ outV.isRepeating = true;
+ } else if (inV1.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outV.setConcat(i, vector1[0], start1[0], len1[0], vector2[i], start2[i], len2[i]);
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outV.setConcat(i, vector1[0], start1[0], len1[0], vector2[i], start2[i], len2[i]);
+ }
+ }
+ } else if (inV2.isRepeating) {
+ if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[0], start2[0], len2[0]);
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[0], start2[0], len2[0]);
+ }
+ }
+ } else {
+ if (batch.selectedInUse) {
+ for(int j=0; j != n; j++) {
+ int i = sel[j];
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[i], start2[i], len2[i]);
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outV.setConcat(i, vector1[i], start1[i], len1[i], vector2[i], start2[i], len2[i]);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Propagate the logic OR of null vectors from two inputs to output.
+ *
+ * @param selectedInUse true/false flag to tell if sel[] is in use
+ * @param n number of qualifying rows
+ * @param sel selected value position array
+ * @param inV1 input vector 1
+ * @param inV2 input vector 2
+ * @param outV output vector
+ */
+ private static void propagateNullsCombine(boolean selectedInUse, int n, int[] sel,
+ ColumnVector inV1, ColumnVector inV2, BytesColumnVector outV) {
+ if (selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outV.isNull[i] = inV1.isNull[i] || inV2.isNull[i];
+ }
+ } else {
+ for(int i = 0; i != n; i++) {
+ outV.isNull[i] = inV1.isNull[i] || inV2.isNull[i];
+ }
+ }
+ }
+
+ /**
+ * Propagate nulls from input vector inV to output vector outV.
+ *
+ * @param selectedInUse true/false flag to tell if sel[] is in use
+ * @param sel selected value position array
+ * @param n number of qualifying rows
+ * @param inV input vector
+ * @param outV ouput vector
+ */
+ private static void propagateNulls(boolean selectedInUse, int n, int[] sel, ColumnVector inV,
+ ColumnVector outV) {
+ if (selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outV.isNull[i] = inV.isNull[i];
+ }
+ } else {
+ System.arraycopy(inV.isNull, 0, outV.isNull, 0, n);
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "String";
+ }
+}
Added: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatColScalar.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatColScalar.java?rev=1478253&view=auto
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatColScalar.java (added)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatColScalar.java Thu May 2 02:08:03 2013
@@ -0,0 +1,118 @@
+/**
+ * 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.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+/**
+ * Vectorized instruction to concatenate a string column to a scalar and put
+ * the result in an output column.
+ */
+public class StringConcatColScalar extends VectorExpression {
+ private int colNum;
+ private int outputColumn;
+ private byte[] value;
+
+ StringConcatColScalar(int colNum, int outputColumn, byte[] value) {
+ this.colNum = colNum;
+ this.outputColumn = outputColumn;
+ this.value = value;
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+ BytesColumnVector inputColVector = (BytesColumnVector) batch.cols[colNum];
+ BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ byte[][] vector = inputColVector.vector;
+ int[] start = inputColVector.start;
+ int[] length = inputColVector.length;
+
+ if (n == 0) {
+
+ // Nothing to do
+ return;
+ }
+
+ // initialize output vector buffer to receive data
+ outV.initBuffer();
+
+ if (inputColVector.noNulls) {
+ outV.noNulls = true;
+ if (inputColVector.isRepeating) {
+ outV.isRepeating = true;
+ outV.setConcat(0, vector[0], start[0], length[0], value, 0, value.length);
+ } else if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outV.setConcat(i, vector[i], start[i], length[i], value, 0, value.length);
+ }
+ outV.isRepeating = false;
+ } else {
+ for(int i = 0; i != n; i++) {
+ outV.setConcat(i, vector[i], start[i], length[i], value, 0, value.length);
+ }
+ outV.isRepeating = false;
+ }
+ } else {
+
+ /*
+ * Handle case with nulls. Don't do function if the value is null, to save time,
+ * because calling the function can be expensive.
+ */
+ outV.noNulls = false;
+ if (inputColVector.isRepeating) {
+ outV.isRepeating = true;
+ outV.isNull[0] = inputColVector.isNull[0];
+ if (!inputColVector.isNull[0]) {
+ outV.setConcat(0, vector[0], start[0], length[0], value, 0, value.length);
+ }
+ } else if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!inputColVector.isNull[i]) {
+ outV.setConcat(i, vector[i], start[i], length[i], value, 0, value.length);
+ }
+ outV.isNull[i] = inputColVector.isNull[i];
+ }
+ outV.isRepeating = false;
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inputColVector.isNull[i]) {
+ outV.setConcat(i, vector[i], start[i], length[i], value, 0, value.length);
+ }
+ outV.isNull[i] = inputColVector.isNull[i];
+ }
+ outV.isRepeating = false;
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "String";
+ }
+}
Added: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatScalarCol.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatScalarCol.java?rev=1478253&view=auto
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatScalarCol.java (added)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringConcatScalarCol.java Thu May 2 02:08:03 2013
@@ -0,0 +1,118 @@
+/**
+ * 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.BytesColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+
+/**
+ * Vectorized instruction to concatenate a scalar to a string column and put
+ * the result in an output column.
+ */
+public class StringConcatScalarCol extends VectorExpression {
+ private int colNum;
+ private int outputColumn;
+ private byte[] value;
+
+ StringConcatScalarCol(byte[] value, int colNum, int outputColumn) {
+ this.colNum = colNum;
+ this.outputColumn = outputColumn;
+ this.value = value;
+ }
+
+ @Override
+ public void evaluate(VectorizedRowBatch batch) {
+ BytesColumnVector inputColVector = (BytesColumnVector) batch.cols[colNum];
+ BytesColumnVector outV = (BytesColumnVector) batch.cols[outputColumn];
+ int[] sel = batch.selected;
+ int n = batch.size;
+ byte[][] vector = inputColVector.vector;
+ int[] start = inputColVector.start;
+ int[] length = inputColVector.length;
+
+ if (n == 0) {
+
+ // Nothing to do
+ return;
+ }
+
+ // initialize output vector buffer to receive data
+ outV.initBuffer();
+
+ if (inputColVector.noNulls) {
+ outV.noNulls = true;
+ if (inputColVector.isRepeating) {
+ outV.isRepeating = true;
+ outV.setConcat(0, value, 0, value.length, vector[0], start[0], length[0]);
+ } else if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ outV.setConcat(i, value, 0, value.length, vector[i], start[i], length[i]);
+ }
+ outV.isRepeating = false;
+ } else {
+ for(int i = 0; i != n; i++) {
+ outV.setConcat(i, value, 0, value.length, vector[i], start[i], length[i]);
+ }
+ outV.isRepeating = false;
+ }
+ } else {
+
+ /*
+ * Handle case with nulls. Don't do function if the value is null, to save time,
+ * because calling the function can be expensive.
+ */
+ outV.noNulls = false;
+ if (inputColVector.isRepeating) {
+ outV.isRepeating = true;
+ outV.isNull[0] = inputColVector.isNull[0];
+ if (!inputColVector.isNull[0]) {
+ outV.setConcat(0, value, 0, value.length, vector[0], start[0], length[0]);
+ }
+ } else if (batch.selectedInUse) {
+ for(int j = 0; j != n; j++) {
+ int i = sel[j];
+ if (!inputColVector.isNull[i]) {
+ outV.setConcat(i, value, 0, value.length, vector[i], start[i], length[i]);
+ }
+ outV.isNull[i] = inputColVector.isNull[i];
+ }
+ outV.isRepeating = false;
+ } else {
+ for(int i = 0; i != n; i++) {
+ if (!inputColVector.isNull[i]) {
+ outV.setConcat(i, value, 0, value.length, vector[i], start[i], length[i]);
+ }
+ outV.isNull[i] = inputColVector.isNull[i];
+ }
+ outV.isRepeating = false;
+ }
+ }
+ }
+
+ @Override
+ public int getOutputColumn() {
+ return outputColumn;
+ }
+
+ @Override
+ public String getOutputType() {
+ return "String";
+ }
+}
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColAddDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColAddDoubleColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColAddDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColAddDoubleColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class DoubleColAddDoubleColumn ex
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColAddLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColAddLongColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColAddLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColAddLongColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class DoubleColAddLongColumn exte
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColDivideDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColDivideDoubleColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColDivideDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColDivideDoubleColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class DoubleColDivideDoubleColumn
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColDivideLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColDivideLongColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColDivideLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColDivideLongColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class DoubleColDivideLongColumn e
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColMultiplyDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColMultiplyDoubleColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColMultiplyDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColMultiplyDoubleColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class DoubleColMultiplyDoubleColu
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColMultiplyLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColMultiplyLongColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColMultiplyLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColMultiplyLongColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class DoubleColMultiplyLongColumn
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColSubtractDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColSubtractDoubleColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColSubtractDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColSubtractDoubleColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class DoubleColSubtractDoubleColu
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColSubtractLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColSubtractLongColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColSubtractLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/DoubleColSubtractLongColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class DoubleColSubtractLongColumn
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColAddDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColAddDoubleColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColAddDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColAddDoubleColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class LongColAddDoubleColumn exte
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColAddLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColAddLongColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColAddLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColAddLongColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class LongColAddLongColumn extend
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColDivideDoubleColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColDivideDoubleColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColDivideDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColDivideDoubleColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class LongColDivideDoubleColumn e
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColDivideLongColumn.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColDivideLongColumn.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColDivideLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColDivideLongColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class LongColDivideLongColumn ext
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: 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=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColModuloLongColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class LongColModuloLongColumn ext
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: 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=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyDoubleColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class LongColMultiplyDoubleColumn
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: 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=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColMultiplyLongColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class LongColMultiplyLongColumn e
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: 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=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractDoubleColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class LongColSubtractDoubleColumn
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: 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=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/LongColSubtractLongColumn.java Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class LongColSubtractLongColumn e
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
Modified: 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=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt (original)
+++ hive/branches/vectorization/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/templates/ColumnArithmeticColumn.txt Thu May 2 02:08:03 2013
@@ -54,6 +54,11 @@ public class <ClassName> extends VectorE
if (n == 0) {
return;
}
+
+ /* Set repeating property to false (the default).
+ * It will be set to true later if needed later.
+ */
+ outputColVector.isRepeating = false;
//Handle nulls first
if (inputColVector1.noNulls && !inputColVector2.noNulls) {
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=1478253&r1=1478252&r2=1478253&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 Thu May 2 02:08:03 2013
@@ -140,9 +140,12 @@ public class TestVectorArithmeticExpress
//Now set one column nullable
lcv1.noNulls = false;
lcv1.isNull[1] = true;
+ lcv2.isRepeating = true; // set output isRepeating to true to make sure it gets over-written
+ lcv2.noNulls = true; // similarly with noNulls
expr.evaluate(vrg);
assertTrue(lcv2.isNull[1]);
assertFalse(lcv2.noNulls);
+ assertFalse(lcv2.isRepeating);
//Now set other column nullable too
lcv0.noNulls = false;
Modified: hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java?rev=1478253&r1=1478252&r2=1478253&view=diff
==============================================================================
--- hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java (original)
+++ hive/branches/vectorization/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java Thu May 2 02:08:03 2013
@@ -37,21 +37,29 @@ import org.apache.hadoop.io.Text;
* Test vectorized expression and filter evaluation for strings.
*/
public class TestVectorStringExpressions {
-
- private static byte[] red;
+
+ private static byte[] red;
+ private static byte[] redred;
private static byte[] red2; // second copy of red, different object
private static byte[] green;
+ private static byte[] greenred;
+ private static byte[] redgreen;
+ private static byte[] greengreen;
private static byte[] emptyString;
private static byte[] mixedUp;
private static byte[] mixedUpLower;
private static byte[] mixedUpUpper;
private static byte[] multiByte;
private static byte[] mixPercentPattern;
-
+
static {
try {
red = "red".getBytes("UTF-8");
+ redred = "redred".getBytes("UTF-8");
green = "green".getBytes("UTF-8");
+ greenred = "greenred".getBytes("UTF-8");
+ redgreen = "redgreen".getBytes("UTF-8");
+ greengreen = "greengreen".getBytes("UTF-8");
emptyString = "".getBytes("UTF-8");
mixedUp = "mixedUp".getBytes("UTF-8");
mixedUpLower = "mixedup".getBytes("UTF-8");
@@ -134,37 +142,38 @@ public class TestVectorStringExpressions
VectorExpression expr;
expr = new FilterStringColEqualStringScalar(0, red2);
expr.evaluate(batch);
-
+
// only red qualifies, and it's in entry 0
Assert.assertTrue(batch.size == 1);
Assert.assertTrue(batch.selected[0] == 0);
-
+
batch = makeStringBatch();
expr = new FilterStringColLessStringScalar(0, red2);
expr.evaluate(batch);
-
+
// only green qualifies, and it's in entry 1
- Assert.assertTrue(batch.size == 1);
- Assert.assertTrue(batch.selected[0] == 1);
-
+ Assert.assertTrue(batch.size == 1);
+ Assert.assertTrue(batch.selected[0] == 1);
+
batch = makeStringBatch();
expr = new FilterStringColGreaterEqualStringScalar(0, green);
expr.evaluate(batch);
-
+
// green and red qualify
- Assert.assertTrue(batch.size == 2);
- Assert.assertTrue(batch.selected[0] == 0);
- Assert.assertTrue(batch.selected[1] == 1);
+ Assert.assertTrue(batch.size == 2);
+ Assert.assertTrue(batch.selected[0] == 0);
+ Assert.assertTrue(batch.selected[1] == 1);
}
-
+
VectorizedRowBatch makeStringBatch() {
// create a batch with one string ("Bytes") column
- VectorizedRowBatch batch = new VectorizedRowBatch(1, VectorizedRowBatch.DEFAULT_SIZE);
- BytesColumnVector v = new BytesColumnVector(VectorizedRowBatch.DEFAULT_SIZE);
+ VectorizedRowBatch batch = new VectorizedRowBatch(2);
+ BytesColumnVector v = new BytesColumnVector();
batch.cols[0] = v;
+ batch.cols[1] = new BytesColumnVector(); // to hold output if needed
/*
* Add these 3 values:
- *
+ *
* red
* green
* NULL
@@ -175,13 +184,13 @@ public class TestVectorStringExpressions
v.isNull[1] = false;
v.setRef(2, emptyString, 0, emptyString.length);
v.isNull[2] = true;
-
+
v.noNulls = false;
-
+
batch.size = 3;
return batch;
}
-
+
VectorizedRowBatch makeStringBatchMixedCase() {
// create a batch with two string ("Bytes") columns
VectorizedRowBatch batch = new VectorizedRowBatch(2, VectorizedRowBatch.DEFAULT_SIZE);
@@ -191,7 +200,7 @@ public class TestVectorStringExpressions
batch.cols[1] = outV;
/*
* Add these 3 values:
- *
+ *
* mixedUp
* green
* NULL
@@ -203,23 +212,23 @@ public class TestVectorStringExpressions
v.setRef(2, emptyString, 0, emptyString.length);
v.isNull[2] = true;
v.noNulls = false;
-
+
batch.size = 3;
return batch;
}
-
+
VectorizedRowBatch makeStringBatchMixedCharSize() {
- // create a new batch with one char column (for input) and one long column (for output)
+ // create a new batch with one char column (for input) and one long column (for output)
VectorizedRowBatch batch = new VectorizedRowBatch(2, VectorizedRowBatch.DEFAULT_SIZE);
BytesColumnVector v = new BytesColumnVector(VectorizedRowBatch.DEFAULT_SIZE);
batch.cols[0] = v;
LongColumnVector outV = new LongColumnVector(VectorizedRowBatch.DEFAULT_SIZE);
batch.cols[1] = outV;
-
+
/*
* Add these 3 values:
- *
+ *
* mixedUp
* green
* NULL
@@ -234,11 +243,11 @@ public class TestVectorStringExpressions
v.noNulls = false;
v.setRef(3, multiByte, 0, 10);
v.isNull[3] = false;
-
+
batch.size = 4;
return batch;
}
-
+
@Test
public void testColLower() {
// has nulls, not repeating
@@ -246,53 +255,53 @@ public class TestVectorStringExpressions
StringLower expr = new StringLower(0, 1);
expr.evaluate(batch);
BytesColumnVector outCol = (BytesColumnVector) batch.cols[1];
- int cmp = StringExpr.compare(mixedUpLower, 0, mixedUpLower.length, outCol.vector[0],
+ int cmp = StringExpr.compare(mixedUpLower, 0, mixedUpLower.length, outCol.vector[0],
outCol.start[0], outCol.length[0]);
Assert.assertEquals(0, cmp);
Assert.assertTrue(outCol.isNull[2]);
- int cmp2 = StringExpr.compare(green, 0, green.length, outCol.vector[1],
+ int cmp2 = StringExpr.compare(green, 0, green.length, outCol.vector[1],
outCol.start[1], outCol.length[1]);
Assert.assertEquals(0, cmp2);
-
+
// no nulls, not repeating
batch = makeStringBatchMixedCase();
batch.cols[0].noNulls = true;
expr.evaluate(batch);
outCol = (BytesColumnVector) batch.cols[1];
- cmp = StringExpr.compare(mixedUpLower, 0, mixedUpLower.length, outCol.vector[0],
+ cmp = StringExpr.compare(mixedUpLower, 0, mixedUpLower.length, outCol.vector[0],
outCol.start[0], outCol.length[0]);
Assert.assertEquals(0, cmp);
Assert.assertTrue(outCol.noNulls);
-
+
// has nulls, is repeating
batch = makeStringBatchMixedCase();
batch.cols[0].isRepeating = true;
expr.evaluate(batch);
outCol = (BytesColumnVector) batch.cols[1];
- cmp = StringExpr.compare(mixedUpLower, 0, mixedUpLower.length, outCol.vector[0],
+ cmp = StringExpr.compare(mixedUpLower, 0, mixedUpLower.length, outCol.vector[0],
outCol.start[0], outCol.length[0]);
Assert.assertEquals(0, cmp);
Assert.assertTrue(outCol.isRepeating);
Assert.assertFalse(outCol.noNulls);
-
+
// no nulls, is repeating
batch = makeStringBatchMixedCase();
batch.cols[0].isRepeating = true;
batch.cols[0].noNulls = true;
expr.evaluate(batch);
outCol = (BytesColumnVector) batch.cols[1];
- cmp = StringExpr.compare(mixedUpLower, 0, mixedUpLower.length, outCol.vector[0],
+ cmp = StringExpr.compare(mixedUpLower, 0, mixedUpLower.length, outCol.vector[0],
outCol.start[0], outCol.length[0]);
Assert.assertEquals(0, cmp);
Assert.assertTrue(outCol.isRepeating);
- Assert.assertTrue(outCol.noNulls);
+ Assert.assertTrue(outCol.noNulls);
}
-
+
@Test
public void testColUpper() {
// no nulls, not repeating
-
+
/* We don't test all the combinations because (at least currently)
* the logic is inherited to be the same as testColLower, which checks all the cases).
*/
@@ -301,15 +310,15 @@ public class TestVectorStringExpressions
batch.cols[0].noNulls = true;
expr.evaluate(batch);
BytesColumnVector outCol = (BytesColumnVector) batch.cols[1];
- int cmp = StringExpr.compare(mixedUpUpper, 0, mixedUpUpper.length, outCol.vector[0],
+ int cmp = StringExpr.compare(mixedUpUpper, 0, mixedUpUpper.length, outCol.vector[0],
outCol.start[0], outCol.length[0]);
Assert.assertEquals(0, cmp);
Assert.assertTrue(outCol.noNulls);
}
-
+
@Test
public void testStringLength() {
-
+
// has nulls, not repeating
VectorizedRowBatch batch = makeStringBatchMixedCharSize();
StringLength expr = new StringLength(0, 1);
@@ -326,7 +335,7 @@ public class TestVectorStringExpressions
outCol = (LongColumnVector) batch.cols[1];
Assert.assertTrue(outCol.noNulls);
Assert.assertEquals(4, outCol.vector[3]); // this one has the mixed-size chars
-
+
// has nulls, is repeating
batch = makeStringBatchMixedCharSize();
batch.cols[0].isRepeating = true;
@@ -347,6 +356,34 @@ public class TestVectorStringExpressions
Assert.assertTrue(outCol.noNulls);
}
+ private VectorizedRowBatch makeStringBatch2In1Out() {
+ VectorizedRowBatch batch = new VectorizedRowBatch(3);
+ BytesColumnVector v = new BytesColumnVector();
+ batch.cols[0] = v;
+ BytesColumnVector v2 = new BytesColumnVector();
+ batch.cols[1] = v2;
+ batch.cols[2] = new BytesColumnVector();
+
+ v.setRef(0, red, 0, red.length);
+ v.isNull[0] = false;
+ v.setRef(1, green, 0, green.length);
+ v.isNull[1] = false;
+ v.setRef(2, emptyString, 0, emptyString.length);
+ v.isNull[2] = true;
+ v.noNulls = false;
+
+ v2.setRef(0, red, 0, red.length);
+ v2.isNull[0] = false;
+ v2.setRef(1, green, 0, green.length);
+ v2.isNull[1] = false;
+ v2.setRef(2, emptyString, 0, emptyString.length);
+ v2.isNull[2] = true;
+ v2.noNulls = false;
+
+ batch.size = 3;
+ return batch;
+ }
+
@Test
public void testStringLike() {
@@ -400,4 +437,273 @@ public class TestVectorStringExpressions
// all rows qualify
Assert.assertEquals(initialBatchSize, batch.size);
}
+
+ @Test
+ public void testColConcatScalar() {
+
+ // has nulls, not repeating
+ VectorizedRowBatch batch = makeStringBatch();
+ StringConcatColScalar expr = new StringConcatColScalar(0, 1, red);
+ expr.evaluate(batch);
+ BytesColumnVector outCol = (BytesColumnVector) batch.cols[1];
+
+ int cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+ Assert.assertTrue(outCol.isNull[2]);
+ int cmp2 = StringExpr.compare(greenred, 0, greenred.length, outCol.vector[1],
+ outCol.start[1], outCol.length[1]);
+ Assert.assertEquals(0, cmp2);
+ Assert.assertFalse(outCol.noNulls);
+ Assert.assertFalse(outCol.isRepeating);
+
+ // no nulls, not repeating
+ batch = makeStringBatch();
+ batch.cols[0].noNulls = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[1];
+ cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+
+ cmp2 = StringExpr.compare(greenred, 0, greenred.length, outCol.vector[1],
+ outCol.start[1], outCol.length[1]);
+ Assert.assertEquals(0, cmp2);
+
+ int cmp3 = StringExpr.compare(red, 0, red.length, outCol.vector[2],
+ outCol.start[2], outCol.length[2]);
+ Assert.assertEquals(0, cmp3);
+
+ Assert.assertTrue(outCol.noNulls);
+ Assert.assertFalse(outCol.isRepeating);
+
+ // has nulls, is repeating
+ batch = makeStringBatch();
+ batch.cols[0].isRepeating = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[1];
+ cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+ Assert.assertTrue(outCol.isRepeating);
+ Assert.assertFalse(outCol.noNulls);
+
+ // no nulls, is repeating
+ batch = makeStringBatch();
+ batch.cols[0].isRepeating = true;
+ batch.cols[0].noNulls = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[1];
+ cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+ Assert.assertTrue(outCol.isRepeating);
+ Assert.assertTrue(outCol.noNulls);
+ }
+
+ @Test
+ public void testScalarConcatCol() {
+
+ // has nulls, not repeating
+ VectorizedRowBatch batch = makeStringBatch();
+ StringConcatScalarCol expr = new StringConcatScalarCol(red, 0, 1);
+ expr.evaluate(batch);
+ BytesColumnVector outCol = (BytesColumnVector) batch.cols[1];
+
+ int cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+ Assert.assertTrue(outCol.isNull[2]);
+ int cmp2 = StringExpr.compare(redgreen, 0, redgreen.length, outCol.vector[1],
+ outCol.start[1], outCol.length[1]);
+ Assert.assertEquals(0, cmp2);
+ Assert.assertFalse(outCol.noNulls);
+ Assert.assertFalse(outCol.isRepeating);
+
+ // no nulls, not repeating
+ batch = makeStringBatch();
+ batch.cols[0].noNulls = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[1];
+ cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+
+ cmp2 = StringExpr.compare(redgreen, 0, redgreen.length, outCol.vector[1],
+ outCol.start[1], outCol.length[1]);
+ Assert.assertEquals(0, cmp2);
+
+ int cmp3 = StringExpr.compare(red, 0, red.length, outCol.vector[2],
+ outCol.start[2], outCol.length[2]);
+ Assert.assertEquals(0, cmp3);
+
+ Assert.assertTrue(outCol.noNulls);
+ Assert.assertFalse(outCol.isRepeating);
+
+ // has nulls, is repeating
+ batch = makeStringBatch();
+ batch.cols[0].isRepeating = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[1];
+ cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+ Assert.assertTrue(outCol.isRepeating);
+ Assert.assertFalse(outCol.noNulls);
+
+ // no nulls, is repeating
+ batch = makeStringBatch();
+ batch.cols[0].isRepeating = true;
+ batch.cols[0].noNulls = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[1];
+ cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+ Assert.assertTrue(outCol.isRepeating);
+ Assert.assertTrue(outCol.noNulls);
+ }
+
+ @Test
+ public void testColConcatCol() {
+
+ // has nulls, not repeating
+ VectorizedRowBatch batch = makeStringBatch2In1Out();
+ StringConcatColCol expr = new StringConcatColCol(0, 1, 2);
+ expr.evaluate(batch);
+ BytesColumnVector outCol = (BytesColumnVector) batch.cols[2];
+
+ int cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+ Assert.assertTrue(outCol.isNull[2]);
+ int cmp2 = StringExpr.compare(greengreen, 0, greengreen.length, outCol.vector[1],
+ outCol.start[1], outCol.length[1]);
+ Assert.assertEquals(0, cmp2);
+ Assert.assertFalse(outCol.noNulls);
+ Assert.assertFalse(outCol.isRepeating);
+
+ // no nulls, not repeating
+ batch = makeStringBatch2In1Out();
+ batch.cols[0].noNulls = true;
+ batch.cols[1].noNulls = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[2];
+
+ cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+
+ cmp2 = StringExpr.compare(greengreen, 0, greengreen.length, outCol.vector[1],
+ outCol.start[1], outCol.length[1]);
+ Assert.assertEquals(0, cmp2);
+
+ int cmp3 = StringExpr.compare(emptyString, 0, emptyString.length,
+ outCol.vector[2], outCol.start[2], outCol.length[2]);
+ Assert.assertEquals(0, cmp3);
+
+ Assert.assertTrue(outCol.noNulls);
+ Assert.assertFalse(outCol.isRepeating);
+
+ // has nulls, is repeating
+
+ batch = makeStringBatch2In1Out();
+ batch.cols[0].isRepeating = true; // only left input repeating
+ batch.cols[0].isNull[0] = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[2];
+
+ Assert.assertEquals(3, batch.size);
+ Assert.assertEquals(true, outCol.isRepeating);
+ Assert.assertEquals(true, outCol.isNull[0]);
+
+ // same, but repeating input is not null
+
+ batch = makeStringBatch2In1Out();
+ batch.cols[0].isRepeating = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[2];
+ Assert.assertEquals(false, outCol.isRepeating); //TEST FAILED
+ cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+ Assert.assertEquals(true, outCol.isNull[2]);
+
+ batch = makeStringBatch2In1Out();
+ batch.cols[1].isRepeating = true; // only right input repeating
+ batch.cols[1].isNull[0] = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[2];
+
+ Assert.assertEquals(3, batch.size);
+ Assert.assertEquals(true, outCol.isRepeating);
+ Assert.assertEquals(true, outCol.isNull[0]);
+
+ batch = makeStringBatch2In1Out();
+ batch.cols[0].isRepeating = true; // both inputs repeat
+ batch.cols[0].isNull[0] = true;
+ batch.cols[1].isRepeating = true;
+ batch.cols[1].isNull[0] = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[2];
+
+ Assert.assertEquals(3, batch.size);
+ Assert.assertEquals(true, outCol.isRepeating);
+ Assert.assertEquals(true, outCol.isNull[0]);
+
+ // no nulls, is repeating
+ batch = makeStringBatch2In1Out();
+ batch.cols[1].isRepeating = true; // only right input repeating and has no nulls
+ batch.cols[1].noNulls = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[2];
+
+ Assert.assertEquals(3, batch.size);
+ Assert.assertEquals(false, outCol.isRepeating);
+ Assert.assertEquals(false, outCol.isNull[0]);
+ Assert.assertEquals(false, outCol.noNulls);
+ Assert.assertEquals(true, outCol.isNull[2]);
+ cmp = StringExpr.compare(greenred, 0, greenred.length, outCol.vector[1],
+ outCol.start[1], outCol.length[1]);
+ Assert.assertEquals(0, cmp);
+
+ // try again with left input also having no nulls
+ batch.cols[0].noNulls = true;
+ expr.evaluate(batch);
+ Assert.assertEquals(false, outCol.isRepeating);
+ Assert.assertEquals(true, outCol.noNulls);
+ cmp = StringExpr.compare(red, 0, red.length, outCol.vector[2],
+ outCol.start[2], outCol.length[2]);
+ Assert.assertEquals(0, cmp);
+
+ batch = makeStringBatch2In1Out();
+ batch.cols[0].isRepeating = true; // only left input repeating and has no nulls
+ batch.cols[0].noNulls = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[2];
+
+ Assert.assertEquals(3, batch.size);
+ Assert.assertEquals(false, outCol.isRepeating);
+ Assert.assertEquals(false, outCol.isNull[0]);
+ Assert.assertEquals(false, outCol.noNulls);
+ Assert.assertEquals(true, outCol.isNull[2]);
+ cmp = StringExpr.compare(redgreen, 0, redgreen.length, outCol.vector[1],
+ outCol.start[1], outCol.length[1]);
+ Assert.assertEquals(0, cmp);
+
+ batch = makeStringBatch2In1Out();
+ batch.cols[0].isRepeating = true; // both inputs repeat
+ batch.cols[0].noNulls = true;
+ batch.cols[1].isRepeating = true;
+ batch.cols[1].noNulls = true;
+ expr.evaluate(batch);
+ outCol = (BytesColumnVector) batch.cols[2];
+
+ Assert.assertEquals(3, batch.size);
+ Assert.assertEquals(true, outCol.isRepeating);
+ Assert.assertEquals(false, outCol.isNull[0]);
+ cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
+ outCol.start[0], outCol.length[0]);
+ Assert.assertEquals(0, cmp);
+ }
}