Search in sources :

Example 1 with LongColAddLongScalar

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

the class TestVectorArithmeticExpressions method testLongColAddLongScalarWithNulls.

@Test
public void testLongColAddLongScalarWithNulls() {
    VectorizedRowBatch batch = getVectorizedRowBatchSingleLongVector(VectorizedRowBatch.DEFAULT_SIZE);
    LongColumnVector lcv = (LongColumnVector) batch.cols[0];
    LongColumnVector lcvOut = (LongColumnVector) batch.cols[1];
    TestVectorizedRowBatch.addRandomNulls(lcv);
    LongColAddLongScalar expr = new LongColAddLongScalar(0, 23, 1);
    expr.evaluate(batch);
    // verify
    for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
        if (!lcv.isNull[i]) {
            Assert.assertEquals(i * 37 + 23, lcvOut.vector[i]);
        } else {
            Assert.assertTrue(lcvOut.isNull[i]);
        }
    }
    Assert.assertFalse(lcvOut.noNulls);
    Assert.assertFalse(lcvOut.isRepeating);
    verifyLongNullDataVectorEntries(lcvOut, batch.selected, batch.selectedInUse, batch.size);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) LongColAddLongScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalar) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Example 2 with LongColAddLongScalar

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

the class TestVectorArithmeticExpressions method longColAddLongScalarNoNulls.

private void longColAddLongScalarNoNulls(boolean checked) throws HiveException {
    VectorizedRowBatch vrg = getVectorizedRowBatchSingleLongVector(VectorizedRowBatch.DEFAULT_SIZE);
    VectorExpression expr;
    if (checked) {
        expr = new LongColAddLongScalarChecked(0, 23, 1);
        expr.setOutputTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo("bigint"));
    } else {
        expr = new LongColAddLongScalar(0, 23, 1);
    }
    expr.evaluate(vrg);
    // verify
    for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
        Assert.assertEquals(i * 37 + 23, ((LongColumnVector) vrg.cols[1]).vector[i]);
    }
    Assert.assertTrue(((LongColumnVector) vrg.cols[1]).noNulls);
    Assert.assertFalse(((LongColumnVector) vrg.cols[1]).isRepeating);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) LongColAddLongScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalar) LongColAddLongScalarChecked(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalarChecked) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)

Example 3 with LongColAddLongScalar

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

the class TestVectorFilterExpressions method testFilterLongColLessLongColumn.

@Test
public void testFilterLongColLessLongColumn() throws HiveException {
    int seed = 17;
    VectorizedRowBatch vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(5, 3, seed);
    LongColumnVector lcv0 = (LongColumnVector) vrg.cols[0];
    LongColumnVector lcv1 = (LongColumnVector) vrg.cols[1];
    LongColumnVector lcv2 = (LongColumnVector) vrg.cols[2];
    FilterLongColLessLongColumn expr = new FilterLongColLessLongColumn(2, 1);
    LongColAddLongScalar childExpr = new LongColAddLongScalar(0, 10, 2);
    expr.setChildExpressions(new VectorExpression[] { childExpr });
    // Basic case
    lcv0.vector[0] = 10;
    lcv0.vector[1] = 20;
    lcv0.vector[2] = 9;
    lcv0.vector[3] = 20;
    lcv0.vector[4] = 10;
    lcv1.vector[0] = 20;
    lcv1.vector[1] = 10;
    lcv1.vector[2] = 20;
    lcv1.vector[3] = 10;
    lcv1.vector[4] = 20;
    expr.evaluate(vrg);
    assertEquals(1, vrg.size);
    assertEquals(2, vrg.selected[0]);
}
Also used : FilterLongColLessLongColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColLessLongColumn) VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) LongColAddLongScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalar) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Example 4 with LongColAddLongScalar

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

the class TestVectorArithmeticExpressions method testLongColAddLongScalarNoNulls.

@Test
public void testLongColAddLongScalarNoNulls() {
    VectorizedRowBatch vrg = getVectorizedRowBatchSingleLongVector(VectorizedRowBatch.DEFAULT_SIZE);
    LongColAddLongScalar expr = new LongColAddLongScalar(0, 23, 1);
    expr.evaluate(vrg);
    //verify
    for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
        Assert.assertEquals(i * 37 + 23, ((LongColumnVector) vrg.cols[1]).vector[i]);
    }
    Assert.assertTrue(((LongColumnVector) vrg.cols[1]).noNulls);
    Assert.assertFalse(((LongColumnVector) vrg.cols[1]).isRepeating);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) LongColAddLongScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalar) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Example 5 with LongColAddLongScalar

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

the class TestVectorArithmeticExpressions method testLongColAddLongScalarWithRepeating.

@Test
public void testLongColAddLongScalarWithRepeating() {
    LongColumnVector in, out;
    VectorizedRowBatch batch;
    LongColAddLongScalar expr;
    // Case 1: is repeating, no nulls
    batch = getVectorizedRowBatchSingleLongVector(VectorizedRowBatch.DEFAULT_SIZE);
    in = (LongColumnVector) batch.cols[0];
    in.isRepeating = true;
    out = (LongColumnVector) batch.cols[1];
    out.isRepeating = false;
    expr = new LongColAddLongScalar(0, 23, 1);
    expr.evaluate(batch);
    // verify
    Assert.assertTrue(out.isRepeating);
    Assert.assertTrue(out.noNulls);
    Assert.assertEquals(out.vector[0], 0 * 37 + 23);
    // Case 2: is repeating, has nulls
    batch = getVectorizedRowBatchSingleLongVector(VectorizedRowBatch.DEFAULT_SIZE);
    in = (LongColumnVector) batch.cols[0];
    in.isRepeating = true;
    in.noNulls = false;
    in.isNull[0] = true;
    out = (LongColumnVector) batch.cols[1];
    out.isRepeating = false;
    out.isNull[0] = false;
    out.noNulls = true;
    expr = new LongColAddLongScalar(0, 23, 1);
    expr.evaluate(batch);
    // verify
    Assert.assertTrue(out.isRepeating);
    Assert.assertFalse(out.noNulls);
    Assert.assertEquals(true, out.isNull[0]);
    verifyLongNullDataVectorEntries(out, batch.selected, batch.selectedInUse, batch.size);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) LongColAddLongScalar(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalar) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Aggregations

LongColumnVector (org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)7 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)7 LongColAddLongScalar (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalar)7 TestVectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch)6 Test (org.junit.Test)4 LongColAddLongScalarChecked (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalarChecked)3 FilterLongColLessLongColumn (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColLessLongColumn)1