2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;
21 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
22 import org.apache.hadoop.hive.ql.exec.vector.<InputColumnVectorType>;
23 import org.apache.hadoop.hive.ql.exec.vector.<OutputColumnVectorType>;
24 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
25 import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
28 * Generated from template ColumnCompareScalar.txt, which covers binary comparison
29 * expressions between a column and a scalar. The boolean output is stored in a
30 * separate boolean column.
32 public class <ClassName> extends VectorExpression {
34 private static final long serialVersionUID = 1L;
37 private <OperandType2> value;
38 private int outputColumn;
40 public <ClassName>(int colNum, <OperandType2> value, int outputColumn) {
43 this.outputColumn = outputColumn;
46 public <ClassName>() {
50 public void evaluate(VectorizedRowBatch batch) {
52 if (childExpressions != null) {
53 super.evaluateChildren(batch);
56 <InputColumnVectorType> inputColVector = (<InputColumnVectorType>) batch.cols[colNum];
57 <OutputColumnVectorType> outputColVector = (<OutputColumnVectorType>) batch.cols[outputColumn];
58 int[] sel = batch.selected;
59 boolean[] nullPos = inputColVector.isNull;
60 boolean[] outNulls = outputColVector.isNull;
62 <OperandType1>[] vector = inputColVector.vector;
63 <ReturnType>[] outputVector = outputColVector.vector;
65 // return immediately if batch is empty
70 outputColVector.isRepeating = false;
71 outputColVector.noNulls = inputColVector.noNulls;
72 if (inputColVector.noNulls) {
73 if (inputColVector.isRepeating) {
74 //All must be selected otherwise size would be zero
75 //Repeating property will not change.
76 outputVector[0] = vector[0] <OperatorSymbol> value ? 1 : 0;
77 outputColVector.isRepeating = true;
78 } else if (batch.selectedInUse) {
79 for(int j=0; j != n; j++) {
81 outputVector[i] = vector[i] <OperatorSymbol> value ? 1 : 0;
84 for(int i = 0; i != n; i++) {
85 outputVector[i] = vector[i] <OperatorSymbol> value ? 1 : 0;
89 if (inputColVector.isRepeating) {
90 //All must be selected otherwise size would be zero
91 //Repeating property will not change.
93 outputVector[0] = vector[0] <OperatorSymbol> value ? 1 : 0;
98 outputColVector.isRepeating = true;
99 } else if (batch.selectedInUse) {
100 for(int j=0; j != n; j++) {
103 outputVector[i] = vector[i] <OperatorSymbol> value ? 1 : 0;
106 //comparison with null is null
111 System.arraycopy(nullPos, 0, outNulls, 0, n);
112 for(int i = 0; i != n; i++) {
114 outputVector[i] = vector[i] <OperatorSymbol> value ? 1 : 0;
122 public int getOutputColumn() {
127 public String getOutputType() {
128 return "<ReturnType>";
131 public int getColNum() {
135 public void setColNum(int colNum) {
136 this.colNum = colNum;
139 public <OperandType2> getValue() {
143 public void setValue(<OperandType2> value) {
147 public void setOutputColumn(int outputColumn) {
148 this.outputColumn = outputColumn;
152 public VectorExpressionDescriptor.Descriptor getDescriptor() {
153 return (new VectorExpressionDescriptor.Builder())
155 VectorExpressionDescriptor.Mode.PROJECTION)
158 VectorExpressionDescriptor.ArgumentType.getType("<VectorExprArgType1>"),
159 VectorExpressionDescriptor.ArgumentType.getType("<VectorExprArgType2>"))
160 .setInputExpressionTypes(
161 VectorExpressionDescriptor.InputExpressionType.COLUMN,
162 VectorExpressionDescriptor.InputExpressionType.SCALAR).build();