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.VectorizedRowBatch;
24 import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
27 * Generated from template FilterColumnCompareScalar.txt, which covers binary comparison
28 * expressions between a column and a scalar, however output is not produced in a separate column.
29 * The selected vector of the input {@link VectorizedRowBatch} is updated for in-place filtering.
31 public class <ClassName> extends VectorExpression {
33 private static final long serialVersionUID = 1L;
36 private <OperandType2> value;
38 public <ClassName>(int colNum, <OperandType2> value) {
43 public <ClassName>() {
47 public void evaluate(VectorizedRowBatch batch) {
49 if (childExpressions != null) {
50 super.evaluateChildren(batch);
53 <InputColumnVectorType> inputColVector = (<InputColumnVectorType>) batch.cols[colNum];
54 int[] sel = batch.selected;
55 boolean[] nullPos = inputColVector.isNull;
57 <OperandType1>[] vector = inputColVector.vector;
59 // return immediately if batch is empty
64 if (inputColVector.noNulls) {
65 if (inputColVector.isRepeating) {
66 //All must be selected otherwise size would be zero
67 //Repeating property will not change.
68 if (!(vector[0] <OperatorSymbol> value)) {
69 //Entire batch is filtered out.
72 } else if (batch.selectedInUse) {
74 for(int j=0; j != n; j++) {
76 if (vector[i] <OperatorSymbol> value) {
83 for(int i = 0; i != n; i++) {
84 if (vector[i] <OperatorSymbol> value) {
90 batch.selectedInUse = true;
94 if (inputColVector.isRepeating) {
95 //All must be selected otherwise size would be zero
96 //Repeating property will not change.
98 if (!(vector[0] <OperatorSymbol> value)) {
99 //Entire batch is filtered out.
105 } else if (batch.selectedInUse) {
107 for(int j=0; j != n; j++) {
110 if (vector[i] <OperatorSymbol> value) {
115 //Change the selected vector
116 batch.size = newSize;
119 for(int i = 0; i != n; i++) {
121 if (vector[i] <OperatorSymbol> value) {
127 batch.size = newSize;
128 batch.selectedInUse = true;
135 public int getOutputColumn() {
140 public String getOutputType() {
144 public int getColNum() {
148 public void setColNum(int colNum) {
149 this.colNum = colNum;
152 public <OperandType2> getValue() {
156 public void setValue(<OperandType2> value) {
161 public VectorExpressionDescriptor.Descriptor getDescriptor() {
162 return (new VectorExpressionDescriptor.Builder())
164 VectorExpressionDescriptor.Mode.FILTER)
167 VectorExpressionDescriptor.ArgumentType.getType("<VectorExprArgType1>"),
168 VectorExpressionDescriptor.ArgumentType.getType("<VectorExprArgType2>"))
169 .setInputExpressionTypes(
170 VectorExpressionDescriptor.InputExpressionType.COLUMN,
171 VectorExpressionDescriptor.InputExpressionType.SCALAR).build();