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 java.sql.Timestamp;
23 import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
24 import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression;
25 import org.apache.hadoop.hive.ql.exec.vector.*;
26 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
27 import org.apache.hadoop.hive.ql.exec.vector.VectorExpressionDescriptor;
30 * Generated from template TimestampColumnCompareTimestampScalar.txt, which covers binary comparison
31 * expressions between a column and a scalar. The boolean output is stored in a
32 * separate boolean column.
34 public class <ClassName> extends VectorExpression {
36 private static final long serialVersionUID = 1L;
39 private <HiveOperandType> value;
40 private int outputColumn;
42 public <ClassName>(int colNum, <HiveOperandType> value, int outputColumn) {
45 this.outputColumn = outputColumn;
48 public <ClassName>() {
52 public void evaluate(VectorizedRowBatch batch) {
54 if (childExpressions != null) {
55 super.evaluateChildren(batch);
58 // Input #1 is type <OperandType>.
59 <InputColumnVectorType> inputColVector1 = (<InputColumnVectorType>) batch.cols[colNum];
61 LongColumnVector outputColVector = (LongColumnVector) batch.cols[outputColumn];
63 int[] sel = batch.selected;
64 boolean[] nullPos = inputColVector1.isNull;
65 boolean[] outNulls = outputColVector.isNull;
67 long[] outputVector = outputColVector.vector;
69 // return immediately if batch is empty
74 outputColVector.isRepeating = false;
75 outputColVector.noNulls = inputColVector1.noNulls;
76 if (inputColVector1.noNulls) {
77 if (inputColVector1.isRepeating) {
78 //All must be selected otherwise size would be zero
79 //Repeating property will not change.
80 outputVector[0] = inputColVector1.compareTo(0, value) <OperatorSymbol> 0 ? 1 : 0;
81 outputColVector.isRepeating = true;
82 } else if (batch.selectedInUse) {
83 for(int j=0; j != n; j++) {
85 outputVector[i] = inputColVector1.compareTo(i, value) <OperatorSymbol> 0 ? 1 : 0;
88 for(int i = 0; i != n; i++) {
89 outputVector[i] = inputColVector1.compareTo(i, value) <OperatorSymbol> 0 ? 1 : 0;
93 if (inputColVector1.isRepeating) {
94 //All must be selected otherwise size would be zero
95 //Repeating property will not change.
97 outputVector[0] = inputColVector1.compareTo(0, value) <OperatorSymbol> 0 ? 1 : 0;
102 outputColVector.isRepeating = true;
103 } else if (batch.selectedInUse) {
104 for(int j=0; j != n; j++) {
107 outputVector[i] = inputColVector1.compareTo(i, value) <OperatorSymbol> 0 ? 1 : 0;
110 //comparison with null is null
115 System.arraycopy(nullPos, 0, outNulls, 0, n);
116 for(int i = 0; i != n; i++) {
118 outputVector[i] = inputColVector1.compareTo(i, value) <OperatorSymbol> 0 ? 1 : 0;
126 public int getOutputColumn() {
131 public String getOutputType() {
136 public String vectorExpressionParameters() {
137 return "col " + colNum + ", val " + value.toString();
141 public VectorExpressionDescriptor.Descriptor getDescriptor() {
142 return (new VectorExpressionDescriptor.Builder())
144 VectorExpressionDescriptor.Mode.PROJECTION)
147 VectorExpressionDescriptor.ArgumentType.getType("<OperandType>"),
148 VectorExpressionDescriptor.ArgumentType.getType("<OperandType>"))
149 .setInputExpressionTypes(
150 VectorExpressionDescriptor.InputExpressionType.COLUMN,
151 VectorExpressionDescriptor.InputExpressionType.SCALAR).build();