Search in sources :

Example 21 with VectorizedRowBatch

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

the class TestUnaryMinus method testUnaryMinus.

@Test
public void testUnaryMinus() {
    VectorizedRowBatch vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(1024, 2, 23);
    LongColUnaryMinus expr = new LongColUnaryMinus(0, 1);
    expr.evaluate(vrg);
    //verify
    long[] inVector = ((LongColumnVector) vrg.cols[0]).vector;
    long[] outVector = ((LongColumnVector) vrg.cols[1]).vector;
    for (int i = 0; i < outVector.length; i++) {
        assertEquals(0, inVector[i] + outVector[i]);
    }
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) LongColUnaryMinus(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinus) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Example 22 with VectorizedRowBatch

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

the class TestVectorArithmeticExpressions method getVectorizedRowBatchSingleLongVector.

private VectorizedRowBatch getVectorizedRowBatchSingleLongVector(int size) {
    VectorizedRowBatch vrg = new VectorizedRowBatch(2, size);
    LongColumnVector lcv = new LongColumnVector(size);
    for (int i = 0; i < size; i++) {
        lcv.vector[i] = i * 37;
    }
    vrg.cols[0] = lcv;
    vrg.cols[1] = new LongColumnVector(size);
    vrg.size = size;
    return vrg;
}
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 23 with VectorizedRowBatch

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

the class TestVectorArithmeticExpressions method getVectorizedRowBatch3DecimalCols.

// Make a decimal batch with three columns, including two for inputs and one for the result.
private VectorizedRowBatch getVectorizedRowBatch3DecimalCols() {
    VectorizedRowBatch b = new VectorizedRowBatch(3);
    DecimalColumnVector v0, v1;
    b.cols[0] = v0 = new DecimalColumnVector(18, 2);
    b.cols[1] = v1 = new DecimalColumnVector(18, 2);
    b.cols[2] = new DecimalColumnVector(18, 2);
    v0.vector[0].set(HiveDecimal.create("1.20"));
    v0.vector[1].set(HiveDecimal.create("-3.30"));
    v0.vector[2].set(HiveDecimal.create("0"));
    v1.vector[0].set(HiveDecimal.create("1.00"));
    v1.vector[1].set(HiveDecimal.create("1.00"));
    v1.vector[2].set(HiveDecimal.create("1.00"));
    b.size = 3;
    return b;
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) DecimalColumnVector(org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector)

Example 24 with VectorizedRowBatch

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

the class TestVectorArithmeticExpressions method testDecimalColAddDecimalColumn.

@Test
public void testDecimalColAddDecimalColumn() {
    VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
    VectorExpression expr = new DecimalColAddDecimalColumn(0, 1, 2);
    DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
    // test without nulls
    expr.evaluate(b);
    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.20")));
    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-2.30")));
    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("1.00")));
    // test nulls propagation
    b = getVectorizedRowBatch3DecimalCols();
    DecimalColumnVector c0 = (DecimalColumnVector) b.cols[0];
    c0.noNulls = false;
    c0.isNull[0] = true;
    r = (DecimalColumnVector) b.cols[2];
    expr.evaluate(b);
    assertTrue(!r.noNulls && r.isNull[0]);
    // Verify null output data entry is not 0, but rather the value specified by design,
    // which is the minimum non-0 value, 0.01 in this case.
    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.01")));
    // test that overflow produces NULL
    b = getVectorizedRowBatch3DecimalCols();
    c0 = (DecimalColumnVector) b.cols[0];
    // set to max possible value
    c0.vector[0].set(HiveDecimal.create("9999999999999999.99"));
    r = (DecimalColumnVector) b.cols[2];
    // will cause overflow for result at position 0, must yield NULL
    expr.evaluate(b);
    assertTrue(!r.noNulls && r.isNull[0]);
    // verify proper null output data value
    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.01")));
    // test left input repeating
    b = getVectorizedRowBatch3DecimalCols();
    c0 = (DecimalColumnVector) b.cols[0];
    c0.isRepeating = true;
    r = (DecimalColumnVector) b.cols[2];
    expr.evaluate(b);
    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.20")));
    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("2.20")));
    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("2.20")));
    // test both inputs repeating
    DecimalColumnVector c1 = (DecimalColumnVector) b.cols[1];
    c1.isRepeating = true;
    expr.evaluate(b);
    assertTrue(r.isRepeating);
    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.20")));
    // test right input repeating
    b = getVectorizedRowBatch3DecimalCols();
    c1 = (DecimalColumnVector) b.cols[1];
    c1.isRepeating = true;
    c1.vector[0].set(HiveDecimal.create("2.00"));
    r = (DecimalColumnVector) b.cols[2];
    expr.evaluate(b);
    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("2.00")));
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) DecimalColumnVector(org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector) DecimalColAddDecimalColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.DecimalColAddDecimalColumn) Test(org.junit.Test)

Example 25 with VectorizedRowBatch

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

the class FakeVectorRowBatchFromConcat method produceNextBatch.

@Override
public VectorizedRowBatch produceNextBatch() {
    VectorizedRowBatch ret = null;
    do {
        if (null != iterator && iterator.hasNext()) {
            ret = iterator.next();
            break;
        }
        if (index >= iterables.length) {
            ret = emptyBatch;
            break;
        }
        iterator = iterables[index].iterator();
        ++index;
    } while (true);
    return ret;
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)

Aggregations

VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)280 Test (org.junit.Test)182 LongColumnVector (org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)118 BytesColumnVector (org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector)69 TestVectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch)68 DoubleColumnVector (org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector)56 DecimalColumnVector (org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector)39 TimestampColumnVector (org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector)22 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)20 HiveDecimal (org.apache.hadoop.hive.common.type.HiveDecimal)18 IOException (java.io.IOException)16 Timestamp (java.sql.Timestamp)16 Configuration (org.apache.hadoop.conf.Configuration)13 VectorExpression (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression)13 JoinUtil (org.apache.hadoop.hive.ql.exec.JoinUtil)12 VectorizedParquetRecordReader (org.apache.hadoop.hive.ql.io.parquet.vector.VectorizedParquetRecordReader)11 Random (java.util.Random)9 ColumnVector (org.apache.hadoop.hive.ql.exec.vector.ColumnVector)8 Path (org.apache.hadoop.fs.Path)6 HiveChar (org.apache.hadoop.hive.common.type.HiveChar)6