Search in sources :

Example 41 with VectorizedRowBatch

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

the class TestVectorLogicalExpressions method testFilterExprOrExprWithBatchReuse.

@Test
public void testFilterExprOrExprWithBatchReuse() {
    VectorizedRowBatch batch1 = getBatchThreeBooleanCols();
    SelectColumnIsTrue expr1 = new SelectColumnIsTrue(0);
    SelectColumnIsFalse expr2 = new SelectColumnIsFalse(1);
    FilterExprOrExpr orExpr = new FilterExprOrExpr();
    orExpr.setChildExpressions(new VectorExpression[] { expr1, expr2 });
    orExpr.evaluate(batch1);
    // Now re-initialize batch1 to simulate batch-object re-use.
    for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
        batch1.selected[i] = 0;
    }
    batch1.size = BOOLEAN_COLUMN_TEST_SIZE;
    batch1.selectedInUse = false;
    // Swap column vectors to simulate change in data
    ColumnVector tmp = batch1.cols[0];
    batch1.cols[0] = batch1.cols[1];
    batch1.cols[1] = tmp;
    orExpr.evaluate(batch1);
    assertEquals(5, batch1.size);
    assertEquals(0, batch1.selected[0]);
    assertEquals(1, batch1.selected[1]);
    assertEquals(3, batch1.selected[2]);
    assertEquals(5, batch1.selected[3]);
    assertEquals(6, batch1.selected[4]);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) ColumnVector(org.apache.hadoop.hive.ql.exec.vector.ColumnVector) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Example 42 with VectorizedRowBatch

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

the class TestVectorLogicalExpressions method testSelectColumnIsNull.

@Test
public void testSelectColumnIsNull() {
    // has nulls, not repeating
    VectorizedRowBatch batch = getBatchThreeBooleanCols();
    SelectColumnIsNull expr = new SelectColumnIsNull(0);
    expr.evaluate(batch);
    assertEquals(3, batch.size);
    assertEquals(4, batch.selected[0]);
    assertEquals(5, batch.selected[1]);
    assertEquals(8, batch.selected[2]);
    // No nulls case, not repeating
    batch = getBatchThreeBooleanCols();
    batch.cols[0].noNulls = true;
    expr.evaluate(batch);
    Assert.assertEquals(0, batch.size);
    // isRepeating, and there are nulls
    batch = getBatchThreeBooleanCols();
    batch.cols[0].isRepeating = true;
    batch.cols[0].isNull[0] = true;
    int initialSize = batch.size;
    expr.evaluate(batch);
    Assert.assertEquals(initialSize, batch.size);
    // isRepeating, and no nulls
    batch = getBatchThreeBooleanCols();
    batch.cols[0].isRepeating = true;
    batch.cols[0].noNulls = true;
    expr.evaluate(batch);
    Assert.assertEquals(0, batch.size);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) Test(org.junit.Test)

Example 43 with VectorizedRowBatch

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

the class TestVectorStringExpressions method testStringColCompareVarCharScalarProjection.

@Test
public void testStringColCompareVarCharScalarProjection() {
    VectorizedRowBatch batch = makeStringBatch();
    VectorExpression expr;
    expr = new StringGroupColEqualVarCharScalar(0, new HiveVarchar(new String(red2), 8), 2);
    expr.evaluate(batch);
    Assert.assertEquals(3, batch.size);
    LongColumnVector outVector = (LongColumnVector) batch.cols[2];
    Assert.assertEquals(1, outVector.vector[0]);
    Assert.assertEquals(0, outVector.vector[1]);
    Assert.assertEquals(0, outVector.vector[2]);
    batch = makeStringBatch();
    expr = new StringGroupColEqualVarCharScalar(0, new HiveVarchar(new String(green), 10), 2);
    expr.evaluate(batch);
    Assert.assertEquals(3, batch.size);
    outVector = (LongColumnVector) batch.cols[2];
    Assert.assertEquals(0, outVector.vector[0]);
    Assert.assertEquals(1, outVector.vector[1]);
    Assert.assertEquals(0, outVector.vector[2]);
}
Also used : StringGroupColEqualVarCharScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.StringGroupColEqualVarCharScalar) FilterStringGroupColEqualVarCharScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterStringGroupColEqualVarCharScalar) VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) HiveVarchar(org.apache.hadoop.hive.common.type.HiveVarchar) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Example 44 with VectorizedRowBatch

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

the class TestVectorStringExpressions method testStringColCompareStringScalarProjection.

@Test
public void testStringColCompareStringScalarProjection() {
    VectorizedRowBatch batch = makeStringBatch();
    VectorExpression expr;
    expr = new StringGroupColEqualStringScalar(0, red2, 2);
    expr.evaluate(batch);
    Assert.assertEquals(3, batch.size);
    LongColumnVector outVector = (LongColumnVector) batch.cols[2];
    Assert.assertEquals(1, outVector.vector[0]);
    Assert.assertEquals(0, outVector.vector[1]);
    Assert.assertEquals(0, outVector.vector[2]);
    batch = makeStringBatch();
    expr = new StringGroupColEqualStringScalar(0, green, 2);
    expr.evaluate(batch);
    Assert.assertEquals(3, batch.size);
    outVector = (LongColumnVector) batch.cols[2];
    Assert.assertEquals(0, outVector.vector[0]);
    Assert.assertEquals(1, outVector.vector[1]);
    Assert.assertEquals(0, outVector.vector[2]);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) StringGroupColEqualStringScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.StringGroupColEqualStringScalar) FilterStringGroupColEqualStringScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterStringGroupColEqualStringScalar) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Example 45 with VectorizedRowBatch

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

the class TestVectorStringExpressions method makeTrimBatch.

// Make a batch to test the trim functions.
private VectorizedRowBatch makeTrimBatch() {
    VectorizedRowBatch b = new VectorizedRowBatch(2);
    BytesColumnVector inV = new BytesColumnVector();
    BytesColumnVector outV = new BytesColumnVector();
    b.cols[0] = inV;
    b.cols[1] = outV;
    inV.setRef(0, emptyString, 0, 0);
    inV.setRef(1, blanksLeft, 0, blanksLeft.length);
    inV.setRef(2, blanksRight, 0, blanksRight.length);
    inV.setRef(3, blanksBoth, 0, blanksBoth.length);
    inV.setRef(4, red, 0, red.length);
    inV.setRef(5, blankString, 0, blankString.length);
    b.size = 5;
    return b;
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) BytesColumnVector(org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector)

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