| <!-- |
| 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. |
| --> |
| @Test |
| public void <TestName>() throws HiveException { |
| |
| Random rand = new Random(SEED); |
| |
| <OutputColumnVectorType> outputColumnVector = |
| VectorizedRowGroupGenUtil.generate<OutputColumnVectorType>(<InitOuputColHasNulls>, |
| <InitOuputColIsRepeating>, BATCH_SIZE, rand); |
| |
| <InputColumnVectorType1> inputColumnVector1 = |
| VectorizedRowGroupGenUtil.generate<InputColumnVectorType1>(<Column1HasNulls>, |
| <Column1IsRepeating>, BATCH_SIZE, rand); |
| |
| <InputColumnVectorType2> inputColumnVector2 = |
| VectorizedRowGroupGenUtil.generate<InputColumnVectorType2>(<Column2HasNulls>, |
| <Column2IsRepeating>, BATCH_SIZE, rand); |
| |
| VectorizedRowBatch rowBatch = new VectorizedRowBatch(3, BATCH_SIZE); |
| rowBatch.cols[0] = inputColumnVector1; |
| rowBatch.cols[1] = inputColumnVector2; |
| rowBatch.cols[2] = outputColumnVector; |
| |
| <VectorExpClassName> vectorExpression = |
| new <VectorExpClassName>(0, 1, 2); |
| |
| vectorExpression.evaluate(rowBatch); |
| |
| assertEquals( |
| "Output column vector repeating state does not match operand columns", |
| (!inputColumnVector1.noNulls && inputColumnVector1.isRepeating) |
| || (!inputColumnVector2.noNulls && inputColumnVector2.isRepeating) |
| || inputColumnVector1.isRepeating && inputColumnVector2.isRepeating, |
| outputColumnVector.isRepeating); |
| |
| /* |
| We no longer set noNulls to the input ColumnVector's value since that doesn't work |
| for scratch column reuse. |
| assertEquals( |
| "Output column vector no nulls state does not match operand columns", |
| inputColumnVector1.noNulls && inputColumnVector2.noNulls, outputColumnVector.noNulls); |
| */ |
| |
| //if repeating, only the first value matters |
| if(!outputColumnVector.noNulls && !outputColumnVector.isRepeating) { |
| for(int i = 0; i < BATCH_SIZE; i++) { |
| //null vectors are safe to check, as they are always initialized to match the data vector |
| assertEquals("Output vector doesn't match input vectors' is null state for index", |
| inputColumnVector1.isNull[i] || inputColumnVector2.isNull[i], |
| outputColumnVector.isNull[i]); |
| } |
| } |
| } |