Search in sources :

Example 61 with DoubleColumnVector

use of org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector in project hive by apache.

the class TestVectorMathFunctions method testVectorASin.

@Test
public void testVectorASin() {
    VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut();
    DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1];
    b.cols[0].noNulls = true;
    VectorExpression expr = new FuncASinDoubleToDouble(0, 1);
    expr.evaluate(b);
    Assert.assertEquals(Math.asin(0.5d), resultV.vector[4]);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector) FuncASinDoubleToDouble(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncASinDoubleToDouble) Test(org.junit.Test)

Example 62 with DoubleColumnVector

use of org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector in project hive by apache.

the class TestVectorMathFunctions method testVectorDegrees.

@Test
public void testVectorDegrees() {
    VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut();
    DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1];
    b.cols[0].noNulls = true;
    VectorExpression expr = new FuncDegreesDoubleToDouble(0, 1);
    expr.evaluate(b);
    Assert.assertEquals(Math.toDegrees(0.5d), resultV.vector[4]);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector) FuncDegreesDoubleToDouble(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncDegreesDoubleToDouble) Test(org.junit.Test)

Example 63 with DoubleColumnVector

use of org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector in project hive by apache.

the class TestVectorMathFunctions method testVectorRadians.

@Test
public void testVectorRadians() {
    VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut();
    DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1];
    b.cols[0].noNulls = true;
    VectorExpression expr = new FuncRadiansDoubleToDouble(0, 1);
    expr.evaluate(b);
    Assert.assertEquals(Math.toRadians(0.5d), resultV.vector[4]);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector) FuncRadiansDoubleToDouble(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncRadiansDoubleToDouble) Test(org.junit.Test)

Example 64 with DoubleColumnVector

use of org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector 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)

Example 65 with DoubleColumnVector

use of org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector in project hive by apache.

the class TestVectorMathFunctions method testVectorAbs.

@Test
public void testVectorAbs() {
    // test double->double version
    VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut();
    DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1];
    b.cols[0].noNulls = true;
    VectorExpression expr = new FuncAbsDoubleToDouble(0, 1);
    expr.evaluate(b);
    Assert.assertEquals(1.5, resultV.vector[0]);
    Assert.assertEquals(0.5, resultV.vector[4]);
    // test long->long version
    b = getVectorizedRowBatchLongInLongOut();
    LongColumnVector resultVLong = (LongColumnVector) b.cols[1];
    b.cols[0].noNulls = true;
    expr = new FuncAbsLongToLong(0, 1);
    expr.evaluate(b);
    Assert.assertEquals(2, resultVLong.vector[0]);
    Assert.assertEquals(2, resultVLong.vector[1]);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) FuncAbsLongToLong(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncAbsLongToLong) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector) FuncAbsDoubleToDouble(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FuncAbsDoubleToDouble) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Aggregations

DoubleColumnVector (org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector)104 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)59 Test (org.junit.Test)37 LongColumnVector (org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)33 BytesColumnVector (org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector)18 DecimalColumnVector (org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector)17 TimestampColumnVector (org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector)13 ColumnVector (org.apache.hadoop.hive.ql.exec.vector.ColumnVector)10 VectorizedParquetRecordReader (org.apache.hadoop.hive.ql.io.parquet.vector.VectorizedParquetRecordReader)9 Configuration (org.apache.hadoop.conf.Configuration)7 Random (java.util.Random)5 DoubleWritable (org.apache.hadoop.hive.serde2.io.DoubleWritable)5 Timestamp (java.sql.Timestamp)4 TestVectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch)4 HiveDecimalWritable (org.apache.hadoop.hive.serde2.io.HiveDecimalWritable)4 StructColumnVector (org.apache.hadoop.hive.ql.exec.vector.StructColumnVector)3 HiveDecimal (org.apache.hadoop.hive.common.type.HiveDecimal)2 IntervalDayTimeColumnVector (org.apache.hadoop.hive.ql.exec.vector.IntervalDayTimeColumnVector)2 ListColumnVector (org.apache.hadoop.hive.ql.exec.vector.ListColumnVector)2 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)2