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.common.type.<TruncStringHiveType>;
23 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
24 import org.apache.hadoop.hive.ql.exec.vector.expressions.StringExpr;
25 import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
26 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
27 import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
31 * This is a generated class to evaluate a [NOT] BETWEEN comparison on a vector of strings.
33 public class <ClassName> extends VectorExpression {
35 private static final long serialVersionUID = 1L;
41 public <ClassName>(int colNum, <TruncStringHiveType> left, <TruncStringHiveType> right) {
43 this.left = left.<TruncStringHiveGetBytes>;
44 this.right = right.<TruncStringHiveGetBytes>;
47 public <ClassName>() {
51 public void evaluate(VectorizedRowBatch batch) {
52 if (childExpressions != null) {
53 super.evaluateChildren(batch);
55 BytesColumnVector inputColVector = (BytesColumnVector) batch.cols[colNum];
56 int[] sel = batch.selected;
57 boolean[] nullPos = inputColVector.isNull;
59 byte[][] vector = inputColVector.vector;
60 int[] length = inputColVector.length;
61 int[] start = inputColVector.start;
64 // return immediately if batch is empty
69 if (inputColVector.noNulls) {
70 if (inputColVector.isRepeating) {
72 // All must be selected otherwise size would be zero. Repeating property will not change.
73 if (<OptionalNot>(StringExpr.compare(vector[0], start[0], length[0], left, 0, left.length) < 0
74 || StringExpr.compare(right, 0, right.length, vector[0], start[0], length[0]) < 0)) {
76 //Entire batch is filtered out.
79 } else if (batch.selectedInUse) {
81 for(int j = 0; j != n; j++) {
83 if (<OptionalNot>(StringExpr.compare(left, 0, left.length, vector[i], start[i], length[i]) <= 0
84 && StringExpr.compare(vector[i], start[i], length[i], right, 0, right.length) <= 0)) {
91 for(int i = 0; i != n; i++) {
92 if (<OptionalNot>(StringExpr.compare(left, 0, left.length, vector[i], start[i], length[i]) <= 0
93 && StringExpr.compare(vector[i], start[i], length[i], right, 0, right.length) <= 0)) {
99 batch.selectedInUse = true;
103 if (inputColVector.isRepeating) {
105 // All must be selected otherwise size would be zero. Repeating property will not change.
107 if (<OptionalNot>(StringExpr.compare(vector[0], start[0], length[0], left, 0, left.length) < 0
108 || StringExpr.compare(right, 0, right.length, vector[0], start[0], length[0]) < 0)) {
110 //Entire batch is filtered out.
116 } else if (batch.selectedInUse) {
118 for(int j=0; j != n; j++) {
121 if (<OptionalNot>(StringExpr.compare(left, 0, left.length, vector[i], start[i], length[i]) <= 0
122 && StringExpr.compare(vector[i], start[i], length[i], right, 0, right.length) <= 0)) {
128 //Change the selected vector
129 batch.size = newSize;
132 for(int i = 0; i != n; i++) {
134 if (<OptionalNot>(StringExpr.compare(left, 0, left.length, vector[i], start[i], length[i]) <= 0
135 && StringExpr.compare(vector[i], start[i], length[i], right, 0, right.length) <= 0)) {
141 batch.size = newSize;
142 batch.selectedInUse = true;
149 public int getOutputColumn() {
154 public String getOutputType() {
158 public int getColNum() {
162 public void setColNum(int colNum) {
163 this.colNum = colNum;
166 public byte[] getLeft() {
170 public void setLeft(byte[] value) {
174 public byte[] getRight() {
178 public void setRight(byte[] value) {
183 public VectorExpressionDescriptor.Descriptor getDescriptor() {
184 return (new VectorExpressionDescriptor.Builder())
186 VectorExpressionDescriptor.Mode.FILTER)
189 VectorExpressionDescriptor.ArgumentType.getType("<TruncStringTypeName>"),
190 VectorExpressionDescriptor.ArgumentType.getType("<TruncStringTypeName>"),
191 VectorExpressionDescriptor.ArgumentType.getType("<TruncStringTypeName>"))
192 .setInputExpressionTypes(
193 VectorExpressionDescriptor.InputExpressionType.COLUMN,
194 VectorExpressionDescriptor.InputExpressionType.SCALAR,
195 VectorExpressionDescriptor.InputExpressionType.SCALAR).build();