Search in sources :

Example 1 with FuncLog2LongToDouble

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

the class TestVectorMathFunctions method testVectorLog2.

@Test
public void testVectorLog2() {
    // test double->double version
    VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut();
    DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1];
    b.cols[0].noNulls = true;
    VectorExpression expr = new FuncLog2DoubleToDouble(0, 1);
    expr.evaluate(b);
    Assert.assertEquals(Math.log(0.5d) / Math.log(2), resultV.vector[4]);
    // test long->double version
    b = getVectorizedRowBatchLongInDoubleOut();
    resultV = (DoubleColumnVector) b.cols[1];
    b.cols[0].noNulls = true;
    expr = new FuncLog2LongToDouble(0, 1);
    expr.evaluate(b);
    Assert.assertEquals(Math.log(1) / Math.log(2), resultV.vector[3]);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) FuncLog2DoubleToDouble(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncLog2DoubleToDouble) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector) FuncLog2LongToDouble(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncLog2LongToDouble) 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 FuncLog2DoubleToDouble (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncLog2DoubleToDouble)1 FuncLog2LongToDouble (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncLog2LongToDouble)1 Test (org.junit.Test)1