Search in sources :

Example 36 with VectorizedRowBatch

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

the class TestVectorMathFunctions method testVectorLn.

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

Example 37 with VectorizedRowBatch

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

the class TestVectorMathFunctions method getVectorizedRowBatchDoubleInDoubleOut.

public static VectorizedRowBatch getVectorizedRowBatchDoubleInDoubleOut() {
    VectorizedRowBatch batch = new VectorizedRowBatch(2);
    DoubleColumnVector inV;
    DoubleColumnVector outV;
    outV = new DoubleColumnVector();
    inV = new DoubleColumnVector();
    inV.vector[0] = -1.5d;
    inV.vector[1] = -0.5d;
    inV.vector[2] = -0.1d;
    inV.vector[3] = 0d;
    inV.vector[4] = 0.5d;
    inV.vector[5] = 0.7d;
    inV.vector[6] = 1.5d;
    inV.vector[7] = 1.2345678d;
    batch.cols[0] = inV;
    batch.cols[1] = outV;
    batch.size = 8;
    return batch;
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector)

Example 38 with VectorizedRowBatch

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

the class TestVectorGenericDateExpressions method testDateAddColScalar.

private void testDateAddColScalar(VectorExpression.Type colType1, boolean isPositive) {
    LongColumnVector date1 = newRandomLongColumnVector(10000, size);
    ColumnVector col1 = castTo(date1, colType1);
    long scalar2 = newRandom(1000);
    LongColumnVector output = new LongColumnVector(size);
    VectorizedRowBatch batch = new VectorizedRowBatch(2, size);
    batch.cols[0] = col1;
    batch.cols[1] = output;
    validateDateAdd(batch, colType1, scalar2, isPositive, date1);
    TestVectorizedRowBatch.addRandomNulls(batch.cols[0]);
    validateDateAdd(batch, colType1, scalar2, isPositive, date1);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector) BytesColumnVector(org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) ColumnVector(org.apache.hadoop.hive.ql.exec.vector.ColumnVector)

Example 39 with VectorizedRowBatch

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

the class TestVectorGenericDateExpressions method testDateAddScalarCol.

private void testDateAddScalarCol(VectorExpression.Type colType1, boolean isPositive) {
    LongColumnVector date2 = newRandomLongColumnVector(10000, size);
    long scalar1 = newRandom(1000);
    LongColumnVector output = new LongColumnVector(size);
    VectorizedRowBatch batch = new VectorizedRowBatch(2, size);
    batch.cols[0] = date2;
    batch.cols[1] = output;
    validateDateAdd(batch, scalar1, date2, colType1, isPositive);
    TestVectorizedRowBatch.addRandomNulls(date2);
    batch.cols[0] = date2;
    validateDateAdd(batch, scalar1, date2, colType1, isPositive);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)

Example 40 with VectorizedRowBatch

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

the class TestVectorLogicalExpressions method testBooleanFiltersOnColumns.

@Test
public void testBooleanFiltersOnColumns() {
    VectorizedRowBatch batch = getBatchThreeBooleanCols();
    SelectColumnIsTrue expr = new SelectColumnIsTrue(0);
    expr.evaluate(batch);
    assertEquals(3, batch.size);
    assertEquals(2, batch.selected[0]);
    assertEquals(3, batch.selected[1]);
    assertEquals(7, batch.selected[2]);
    batch = getBatchThreeBooleanCols();
    SelectColumnIsFalse expr1 = new SelectColumnIsFalse(1);
    expr1.evaluate(batch);
    assertEquals(3, batch.size);
    assertEquals(0, batch.selected[0]);
    assertEquals(2, batch.selected[1]);
    assertEquals(4, batch.selected[2]);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) Test(org.junit.Test)

Aggregations

VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)331 Test (org.junit.Test)191 LongColumnVector (org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)135 BytesColumnVector (org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector)77 TestVectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch)77 DoubleColumnVector (org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector)61 DecimalColumnVector (org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector)39 TimestampColumnVector (org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector)27 VectorizedParquetRecordReader (org.apache.hadoop.hive.ql.io.parquet.vector.VectorizedParquetRecordReader)26 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)23 Configuration (org.apache.hadoop.conf.Configuration)20 Timestamp (java.sql.Timestamp)19 HiveDecimal (org.apache.hadoop.hive.common.type.HiveDecimal)18 IOException (java.io.IOException)17 VectorExpression (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression)17 Random (java.util.Random)12 JoinUtil (org.apache.hadoop.hive.ql.exec.JoinUtil)12 ColumnVector (org.apache.hadoop.hive.ql.exec.vector.ColumnVector)11 PrimitiveCategory (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory)11 StructColumnVector (org.apache.hadoop.hive.ql.exec.vector.StructColumnVector)7