use of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinusChecked in project hive by apache.
the class TestUnaryMinus method testUnaryMinusCheckedOverflow.
@Test
public void testUnaryMinusCheckedOverflow() {
VectorizedRowBatch vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(1, 2, 0);
// set value to MIN_VALUE so that -MIN_VALUE overflows and gets set to MIN_VALUE again
((LongColumnVector) vrg.cols[0]).vector[0] = Integer.MIN_VALUE;
LongColUnaryMinusChecked expr = new LongColUnaryMinusChecked(0, 1);
expr.setOutputTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo("int"));
expr.evaluate(vrg);
// verify
long[] inVector = ((LongColumnVector) vrg.cols[0]).vector;
long[] outVector = ((LongColumnVector) vrg.cols[1]).vector;
for (int i = 0; i < outVector.length; i++) {
assertEquals(Integer.MIN_VALUE, outVector[i]);
}
}
use of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinusChecked in project hive by apache.
the class TestUnaryMinus method testUnaryMinusChecked.
@Test
public void testUnaryMinusChecked() {
VectorizedRowBatch vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(1024, 2, 23);
LongColUnaryMinusChecked expr = new LongColUnaryMinusChecked(0, 1);
expr.setOutputTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo("bigint"));
expr.evaluate(vrg);
// verify
long[] inVector = ((LongColumnVector) vrg.cols[0]).vector;
long[] outVector = ((LongColumnVector) vrg.cols[1]).vector;
for (int i = 0; i < outVector.length; i++) {
assertEquals(0, inVector[i] + outVector[i]);
}
}
Aggregations