Search in sources :

Example 1 with LongColAddLongColumnChecked

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

the class TestVectorArithmeticExpressions method longColAddLongColumnUtil.

private void longColAddLongColumnUtil(boolean isChecked) throws HiveException {
    int seed = 17;
    VectorizedRowBatch vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(VectorizedRowBatch.DEFAULT_SIZE, 6, seed);
    LongColumnVector lcv0 = (LongColumnVector) vrg.cols[0];
    LongColumnVector lcv1 = (LongColumnVector) vrg.cols[1];
    LongColumnVector lcv2 = (LongColumnVector) vrg.cols[2];
    LongColumnVector lcv3 = (LongColumnVector) vrg.cols[3];
    LongColumnVector lcv4 = (LongColumnVector) vrg.cols[4];
    LongColumnVector lcv5 = (LongColumnVector) vrg.cols[5];
    VectorExpression expr;
    if (isChecked) {
        expr = new LongColAddLongColumnChecked(0, 1, 2);
        expr.setOutputTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo("bigint"));
    } else {
        expr = new LongColAddLongColumn(0, 1, 2);
    }
    expr.evaluate(vrg);
    for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
        assertEquals((i + 1) * seed * 3, lcv2.vector[i]);
    }
    assertTrue(lcv2.noNulls);
    // Now set one column nullable
    lcv1.noNulls = false;
    lcv1.isNull[1] = true;
    // set output isRepeating to true to make sure it gets over-written
    lcv2.isRepeating = true;
    // similarly with noNulls
    lcv2.noNulls = true;
    expr.evaluate(vrg);
    assertTrue(lcv2.isNull[1]);
    assertFalse(lcv2.noNulls);
    assertFalse(lcv2.isRepeating);
    verifyLongNullDataVectorEntries(lcv2, vrg.selected, vrg.selectedInUse, vrg.size);
    // Now set other column nullable too
    lcv0.noNulls = false;
    lcv0.isNull[1] = true;
    lcv0.isNull[3] = true;
    expr.evaluate(vrg);
    assertTrue(lcv2.isNull[1]);
    assertTrue(lcv2.isNull[3]);
    assertFalse(lcv2.noNulls);
    verifyLongNullDataVectorEntries(lcv2, vrg.selected, vrg.selectedInUse, vrg.size);
    // Now test with repeating flag
    lcv3.isRepeating = true;
    VectorExpression expr2;
    if (isChecked) {
        expr2 = new LongColAddLongColumnChecked(3, 4, 5);
        expr2.setOutputTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo("bigint"));
    } else {
        expr2 = new LongColAddLongColumn(3, 4, 5);
    }
    expr2.evaluate(vrg);
    for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
        assertEquals(seed * (4 + 5 * (i + 1)), lcv5.vector[i]);
    }
    // Repeating with other as nullable
    lcv4.noNulls = false;
    lcv4.isNull[0] = true;
    expr2.evaluate(vrg);
    assertTrue(lcv5.isNull[0]);
    assertFalse(lcv5.noNulls);
    verifyLongNullDataVectorEntries(lcv5, vrg.selected, vrg.selectedInUse, vrg.size);
    // Repeating null value
    lcv3.isRepeating = true;
    lcv3.noNulls = false;
    lcv3.isNull[0] = true;
    expr2.evaluate(vrg);
    assertFalse(lcv5.noNulls);
    assertTrue(lcv5.isRepeating);
    assertTrue(lcv5.isNull[0]);
    verifyLongNullDataVectorEntries(lcv5, vrg.selected, vrg.selectedInUse, vrg.size);
    // Neither input has nulls. Verify that this propagates to output.
    vrg.selectedInUse = false;
    lcv0.noNulls = true;
    lcv1.noNulls = true;
    lcv0.isRepeating = false;
    lcv1.isRepeating = false;
    lcv2.reset();
    expr.evaluate(vrg);
    assertTrue(lcv2.noNulls);
    assertFalse(lcv2.isRepeating);
}
Also used : LongColAddLongColumnChecked(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongColumnChecked) VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) LongColAddLongColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongColumn) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)

Aggregations

LongColumnVector (org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)1 TestVectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch)1 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)1 LongColAddLongColumn (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongColumn)1 LongColAddLongColumnChecked (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongColumnChecked)1