Search in sources :

Example 1 with FuncSignDoubleToDouble

use of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncSignDoubleToDouble in project hive by apache.

the class TestVectorMathFunctions method testVectorSign.

@Test
public void testVectorSign() {
    // test double->double version
    VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut();
    DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1];
    b.cols[0].noNulls = true;
    VectorExpression expr = new FuncSignDoubleToDouble(0, 1);
    expr.evaluate(b);
    Assert.assertEquals(-1.0d, resultV.vector[0]);
    Assert.assertEquals(1.0d, resultV.vector[4]);
    // test long->double version
    b = getVectorizedRowBatchLongInDoubleOut();
    resultV = (DoubleColumnVector) b.cols[1];
    b.cols[0].noNulls = true;
    expr = new FuncSignLongToDouble(0, 1);
    expr.evaluate(b);
    Assert.assertEquals(-1.0d, resultV.vector[0]);
    Assert.assertEquals(1.0d, resultV.vector[4]);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) FuncSignDoubleToDouble(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncSignDoubleToDouble) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector) FuncSignLongToDouble(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncSignLongToDouble) Test(org.junit.Test)

Aggregations

DoubleColumnVector (org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector)1 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)1 FuncSignDoubleToDouble (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncSignDoubleToDouble)1 FuncSignLongToDouble (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncSignLongToDouble)1 Test (org.junit.Test)1