Search in sources :

Example 1 with FilterLongColGreaterLongColumn

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

the class TestVectorFilterExpressions method testFilterLongColGreaterLongColumn.

@Test
public void testFilterLongColGreaterLongColumn() {
    int seed = 17;
    VectorizedRowBatch b = VectorizedRowGroupGenUtil.getVectorizedRowBatch(VectorizedRowBatch.DEFAULT_SIZE, 2, seed);
    LongColumnVector lcv0 = (LongColumnVector) b.cols[0];
    LongColumnVector lcv1 = (LongColumnVector) b.cols[1];
    b.size = 3;
    FilterLongColGreaterLongColumn expr = new FilterLongColGreaterLongColumn(0, 1);
    // Basic case
    lcv0.vector[0] = 10;
    lcv0.vector[1] = 10;
    lcv0.vector[2] = 10;
    lcv1.vector[0] = 20;
    lcv1.vector[1] = 1;
    lcv1.vector[2] = 7;
    expr.evaluate(b);
    assertEquals(2, b.size);
    assertEquals(1, b.selected[0]);
    assertEquals(2, b.selected[1]);
    // handle null with selected in use
    lcv0.noNulls = false;
    lcv0.isNull[1] = true;
    expr.evaluate(b);
    assertEquals(1, b.size);
    assertEquals(2, b.selected[0]);
    // handle repeating
    b.size = 3;
    b.selectedInUse = false;
    lcv0.isRepeating = true;
    lcv0.noNulls = true;
    expr.evaluate(b);
    assertEquals(2, b.size);
    // handle repeating null
    b.size = 3;
    b.selectedInUse = false;
    lcv0.isNull[0] = true;
    lcv0.noNulls = false;
    expr.evaluate(b);
    assertEquals(0, b.size);
    // handle null on both sizes (not repeating)
    b.size = 3;
    b.selectedInUse = false;
    lcv0.isRepeating = false;
    lcv1.noNulls = false;
    lcv1.isNull[2] = true;
    expr.evaluate(b);
    assertEquals(0, b.size);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) FilterLongColGreaterLongColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColGreaterLongColumn) Test(org.junit.Test)

Example 2 with FilterLongColGreaterLongColumn

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

the class TestVectorFilterOperator method testBasicFilterOperator.

@Test
public void testBasicFilterOperator() throws HiveException {
    VectorFilterOperator vfo = getAVectorFilterOperator();
    vfo.initialize(hconf, null);
    VectorExpression ve1 = new FilterLongColGreaterLongColumn(0, 1);
    VectorExpression ve2 = new FilterLongColEqualDoubleScalar(2, 0);
    VectorExpression ve3 = new FilterExprAndExpr();
    ve3.setChildExpressions(new VectorExpression[] { ve1, ve2 });
    vfo.setFilterCondition(ve3);
    FakeDataReader fdr = new FakeDataReader(1024 * 1, 3);
    VectorizedRowBatch vrg = fdr.getNext();
    vfo.getPredicateExpression().evaluate(vrg);
    // Verify
    int rows = 0;
    for (int i = 0; i < 1024; i++) {
        LongColumnVector l1 = (LongColumnVector) vrg.cols[0];
        LongColumnVector l2 = (LongColumnVector) vrg.cols[1];
        LongColumnVector l3 = (LongColumnVector) vrg.cols[2];
        if ((l1.vector[i] > l2.vector[i]) && (l3.vector[i] == 0)) {
            rows++;
        }
    }
    Assert.assertEquals(rows, vrg.size);
}
Also used : FilterExprAndExpr(org.apache.hadoop.hive.ql.exec.vector.expressions.FilterExprAndExpr) FilterLongColEqualDoubleScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColEqualDoubleScalar) VectorExpression(org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression) FilterLongColGreaterLongColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColGreaterLongColumn) Test(org.junit.Test)

Example 3 with FilterLongColGreaterLongColumn

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

the class TestVectorFilterOperator method testBasicFilterLargeData.

@Test
public void testBasicFilterLargeData() throws HiveException {
    VectorFilterOperator vfo = getAVectorFilterOperator();
    vfo.initialize(hconf, null);
    VectorExpression ve1 = new FilterLongColGreaterLongColumn(0, 1);
    VectorExpression ve2 = new FilterLongColEqualDoubleScalar(2, 0);
    VectorExpression ve3 = new FilterExprAndExpr();
    ve3.setChildExpressions(new VectorExpression[] { ve1, ve2 });
    vfo.setFilterCondition(ve3);
    FakeDataReader fdr = new FakeDataReader(16 * 1024 * 1024, 3);
    long startTime = System.currentTimeMillis();
    VectorizedRowBatch vrg = fdr.getNext();
    while (vrg.size > 0) {
        vfo.process(vrg, 0);
        vrg = fdr.getNext();
    }
    long endTime = System.currentTimeMillis();
    System.out.println("testBaseFilterOperator Op Time = " + (endTime - startTime));
    // Base time
    fdr = new FakeDataReader(16 * 1024 * 1024, 3);
    long startTime1 = System.currentTimeMillis();
    vrg = fdr.getNext();
    LongColumnVector l1 = (LongColumnVector) vrg.cols[0];
    LongColumnVector l2 = (LongColumnVector) vrg.cols[1];
    LongColumnVector l3 = (LongColumnVector) vrg.cols[2];
    int rows = 0;
    for (int j = 0; j < 16 * 1024; j++) {
        for (int i = 0; i < l1.vector.length && i < l2.vector.length && i < l3.vector.length; i++) {
            if ((l1.vector[i] > l2.vector[i]) && (l3.vector[i] == 0)) {
                rows++;
            }
        }
    }
    long endTime1 = System.currentTimeMillis();
    System.out.println("testBaseFilterOperator base Op Time = " + (endTime1 - startTime1));
}
Also used : FilterExprAndExpr(org.apache.hadoop.hive.ql.exec.vector.expressions.FilterExprAndExpr) FilterLongColEqualDoubleScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColEqualDoubleScalar) VectorExpression(org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression) FilterLongColGreaterLongColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColGreaterLongColumn) Test(org.junit.Test)

Aggregations

FilterLongColGreaterLongColumn (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColGreaterLongColumn)3 Test (org.junit.Test)3 FilterExprAndExpr (org.apache.hadoop.hive.ql.exec.vector.expressions.FilterExprAndExpr)2 VectorExpression (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression)2 FilterLongColEqualDoubleScalar (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColEqualDoubleScalar)2 LongColumnVector (org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)1 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)1