Search in sources :

Example 1 with LongColUnaryMinusChecked

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]);
    }
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) LongColUnaryMinusChecked(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinusChecked) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Example 2 with LongColUnaryMinusChecked

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]);
    }
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) LongColUnaryMinusChecked(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinusChecked) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Aggregations

LongColumnVector (org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)2 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)2 LongColUnaryMinusChecked (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinusChecked)2 Test (org.junit.Test)2