Search in sources :

Example 26 with LongColumnVector

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

the class TestVectorGenericDateExpressions method validateDateDiff.

private void validateDateDiff(VectorizedRowBatch batch, LongColumnVector date1, long scalar2, VectorExpression.Type colType1, VectorExpression.Type scalarType2) {
    VectorExpression udf = null;
    switch(scalarType2) {
        case DATE:
            udf = new VectorUDFDateDiffColScalar(0, scalar2, 1);
            break;
        case TIMESTAMP:
            udf = new VectorUDFDateDiffColScalar(0, toTimestamp(scalar2), 1);
            break;
        case STRING:
            udf = new VectorUDFDateDiffColScalar(0, toString(scalar2), 1);
            break;
    }
    udf.setInputTypes(colType1, scalarType2);
    udf.evaluate(batch);
    LongColumnVector output = (LongColumnVector) batch.cols[1];
    for (int i = 0; i < date1.vector.length; i++) {
        Assert.assertEquals(date1.vector[i] - scalar2, output.vector[i]);
    }
}
Also used : LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)

Example 27 with LongColumnVector

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

the class TestVectorGenericDateExpressions method testDateAddColCol.

private void testDateAddColCol(VectorExpression.Type colType1, boolean isPositive) {
    LongColumnVector date1 = newRandomLongColumnVector(10000, size);
    LongColumnVector days2 = newRandomLongColumnVector(1000, size);
    ColumnVector col1 = castTo(date1, colType1);
    LongColumnVector output = new LongColumnVector(size);
    VectorizedRowBatch batch = new VectorizedRowBatch(3, size);
    batch.cols[0] = col1;
    batch.cols[1] = days2;
    batch.cols[2] = output;
    validateDateAdd(batch, date1, days2, colType1, isPositive);
    TestVectorizedRowBatch.addRandomNulls(date1);
    batch.cols[0] = castTo(date1, colType1);
    validateDateAdd(batch, date1, days2, colType1, isPositive);
    TestVectorizedRowBatch.addRandomNulls(days2);
    batch.cols[1] = days2;
    validateDateAdd(batch, date1, days2, colType1, isPositive);
}
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) TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector) BytesColumnVector(org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) ColumnVector(org.apache.hadoop.hive.ql.exec.vector.ColumnVector)

Example 28 with LongColumnVector

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

the class TestVectorGenericDateExpressions method testToDate.

@Test
public void testToDate() {
    for (VectorExpression.Type type : Arrays.asList(VectorExpression.Type.TIMESTAMP, VectorExpression.Type.STRING)) {
        LongColumnVector date = newRandomLongColumnVector(10000, size);
        LongColumnVector output = new LongColumnVector(size);
        VectorizedRowBatch batch = new VectorizedRowBatch(2, size);
        batch.cols[0] = castTo(date, type);
        batch.cols[1] = output;
        validateToDate(batch, type, date);
        TestVectorizedRowBatch.addRandomNulls(date);
        batch.cols[0] = castTo(date, type);
        validateToDate(batch, type, date);
    }
    VectorExpression udf = new CastStringToDate(0, 1);
    udf.setInputTypes(VectorExpression.Type.STRING);
    VectorizedRowBatch batch = new VectorizedRowBatch(2, 1);
    batch.cols[0] = new BytesColumnVector(1);
    batch.cols[1] = new LongColumnVector(1);
    BytesColumnVector bcv = (BytesColumnVector) batch.cols[0];
    byte[] bytes = "error".getBytes(utf8);
    bcv.vector[0] = bytes;
    bcv.start[0] = 0;
    bcv.length[0] = bytes.length;
    udf.evaluate(batch);
    Assert.assertEquals(batch.cols[1].isNull[0], true);
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TestVectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch) BytesColumnVector(org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Example 29 with LongColumnVector

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

the class TestVectorFilterExpressions method testFilterLongColLessLongColumn.

@Test
public void testFilterLongColLessLongColumn() {
    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 30 with LongColumnVector

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

the class TestVectorFilterExpressions method getSimpleLongBatch.

private VectorizedRowBatch getSimpleLongBatch() {
    VectorizedRowBatch batch = VectorizedRowGroupGenUtil.getVectorizedRowBatch(4, 1, 1);
    LongColumnVector lcv0 = (LongColumnVector) batch.cols[0];
    lcv0.vector[0] = 0;
    lcv0.vector[1] = 1;
    lcv0.vector[2] = 2;
    lcv0.vector[3] = 3;
    return batch;
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)

Aggregations

LongColumnVector (org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)223 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)116 Test (org.junit.Test)67 BytesColumnVector (org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector)50 TestVectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch)36 TimestampColumnVector (org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector)25 DoubleColumnVector (org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector)24 ColumnVector (org.apache.hadoop.hive.ql.exec.vector.ColumnVector)17 DecimalColumnVector (org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector)14 Random (java.util.Random)12 Configuration (org.apache.hadoop.conf.Configuration)8 VectorizedParquetRecordReader (org.apache.hadoop.hive.ql.io.parquet.vector.VectorizedParquetRecordReader)7 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)7 StructColumnVector (org.apache.hadoop.hive.ql.exec.vector.StructColumnVector)6 Path (org.apache.hadoop.fs.Path)5 LongWritable (org.apache.hadoop.io.LongWritable)5 IOException (java.io.IOException)4 Timestamp (java.sql.Timestamp)4 JoinUtil (org.apache.hadoop.hive.ql.exec.JoinUtil)4 IntervalDayTimeColumnVector (org.apache.hadoop.hive.ql.exec.vector.IntervalDayTimeColumnVector)4