Search in sources :

Example 36 with TimestampColumnVector

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

the class RecordReaderImpl method nextTimestamp.

static TimestampWritable nextTimestamp(ColumnVector vector, int row, Object previous) {
    if (vector.isRepeating) {
        row = 0;
    }
    if (vector.noNulls || !vector.isNull[row]) {
        TimestampWritable result;
        if (previous == null || previous.getClass() != TimestampWritable.class) {
            result = new TimestampWritable();
        } else {
            result = (TimestampWritable) previous;
        }
        TimestampColumnVector tcv = (TimestampColumnVector) vector;
        result.setInternal(tcv.time[row], tcv.nanos[row]);
        return result;
    } else {
        return null;
    }
}
Also used : TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector) TimestampWritable(org.apache.hadoop.hive.serde2.io.TimestampWritable)

Example 37 with TimestampColumnVector

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

the class TestVectorMathFunctions method getVectorizedRowBatchTimestampInDoubleOut.

public static VectorizedRowBatch getVectorizedRowBatchTimestampInDoubleOut(double[] doubleValues) {
    Random r = new Random(45993);
    VectorizedRowBatch batch = new VectorizedRowBatch(2);
    TimestampColumnVector tcv;
    DoubleColumnVector dcv;
    tcv = new TimestampColumnVector(doubleValues.length);
    dcv = new DoubleColumnVector(doubleValues.length);
    for (int i = 0; i < doubleValues.length; i++) {
        doubleValues[i] = r.nextDouble() % (double) SECONDS_LIMIT;
        dcv.vector[i] = doubleValues[i];
    }
    batch.cols[0] = tcv;
    batch.cols[1] = dcv;
    batch.size = doubleValues.length;
    return batch;
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector) Random(java.util.Random)

Example 38 with TimestampColumnVector

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

the class TestVectorMathFunctions method getVectorizedRowBatchDoubleInTimestampOut.

public static VectorizedRowBatch getVectorizedRowBatchDoubleInTimestampOut() {
    VectorizedRowBatch batch = new VectorizedRowBatch(2);
    TimestampColumnVector tcv;
    DoubleColumnVector dcv;
    tcv = new TimestampColumnVector();
    dcv = new DoubleColumnVector();
    dcv.vector[0] = -1.5d;
    dcv.vector[1] = -0.5d;
    dcv.vector[2] = -0.1d;
    dcv.vector[3] = 0d;
    dcv.vector[4] = 0.5d;
    dcv.vector[5] = 0.7d;
    dcv.vector[6] = 1.5d;
    batch.cols[0] = dcv;
    batch.cols[1] = tcv;
    batch.size = 7;
    return batch;
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector) DoubleColumnVector(org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector)

Example 39 with TimestampColumnVector

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

the class TestVectorMathFunctions method getVectorizedRowBatchLongInTimestampOut.

public static VectorizedRowBatch getVectorizedRowBatchLongInTimestampOut(long[] longValues) {
    Random r = new Random(12099);
    VectorizedRowBatch batch = new VectorizedRowBatch(2);
    LongColumnVector inV;
    TimestampColumnVector outV;
    inV = new LongColumnVector();
    outV = new TimestampColumnVector();
    for (int i = 0; i < longValues.length; i++) {
        longValues[i] = r.nextLong() % SECONDS_LIMIT;
        inV.vector[i] = longValues[i];
    }
    batch.cols[0] = inV;
    batch.cols[1] = outV;
    batch.size = longValues.length;
    return batch;
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector) Random(java.util.Random) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)

Example 40 with TimestampColumnVector

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

the class BatchToRowReader method nextTimestamp.

public static TimestampWritable nextTimestamp(ColumnVector vector, int row, Object previous) {
    if (vector.isRepeating) {
        row = 0;
    }
    if (vector.noNulls || !vector.isNull[row]) {
        TimestampWritable result;
        if (previous == null || previous.getClass() != TimestampWritable.class) {
            result = new TimestampWritable();
        } else {
            result = (TimestampWritable) previous;
        }
        TimestampColumnVector tcv = (TimestampColumnVector) vector;
        result.setInternal(tcv.time[row], tcv.nanos[row]);
        return result;
    } else {
        return null;
    }
}
Also used : TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector) TimestampWritable(org.apache.hadoop.hive.serde2.io.TimestampWritable)

Aggregations

TimestampColumnVector (org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector)66 LongColumnVector (org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)24 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)22 Timestamp (java.sql.Timestamp)17 BytesColumnVector (org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector)11 DecimalColumnVector (org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector)11 DoubleColumnVector (org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector)11 Test (org.junit.Test)11 Random (java.util.Random)9 TimestampWritable (org.apache.hadoop.hive.serde2.io.TimestampWritable)7 ColumnVector (org.apache.hadoop.hive.ql.exec.vector.ColumnVector)5 HiveDecimalWritable (org.apache.hadoop.hive.serde2.io.HiveDecimalWritable)4 TestVectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.TestVectorizedRowBatch)3 ByteWritable (org.apache.hadoop.hive.serde2.io.ByteWritable)3 DoubleWritable (org.apache.hadoop.hive.serde2.io.DoubleWritable)3 ShortWritable (org.apache.hadoop.hive.serde2.io.ShortWritable)3 PrimitiveTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo)3 BooleanWritable (org.apache.hadoop.io.BooleanWritable)3 IntWritable (org.apache.hadoop.io.IntWritable)3 LongWritable (org.apache.hadoop.io.LongWritable)3