Search in sources :

Example 46 with TimestampColumnVector

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

the class VectorUDAFVarPopTimestamp method aggregateInput.

@Override
public void aggregateInput(AggregationBuffer agg, VectorizedRowBatch batch) throws HiveException {
    inputExpression.evaluate(batch);
    TimestampColumnVector inputColVector = (TimestampColumnVector) batch.cols[this.inputExpression.getOutputColumn()];
    int batchSize = batch.size;
    if (batchSize == 0) {
        return;
    }
    Aggregation myagg = (Aggregation) agg;
    if (inputColVector.isRepeating) {
        if (inputColVector.noNulls) {
            iterateRepeatingNoNulls(myagg, inputColVector.getDouble(0), batchSize);
        }
    } else if (!batch.selectedInUse && inputColVector.noNulls) {
        iterateNoSelectionNoNulls(myagg, inputColVector, batchSize);
    } else if (!batch.selectedInUse) {
        iterateNoSelectionHasNulls(myagg, inputColVector, batchSize, inputColVector.isNull);
    } else if (inputColVector.noNulls) {
        iterateSelectionNoNulls(myagg, inputColVector, batchSize, batch.selected);
    } else {
        iterateSelectionHasNulls(myagg, inputColVector, batchSize, inputColVector.isNull, batch.selected);
    }
}
Also used : TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector)

Example 47 with TimestampColumnVector

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

the class VectorUDAFVarSampTimestamp method aggregateInput.

@Override
public void aggregateInput(AggregationBuffer agg, VectorizedRowBatch batch) throws HiveException {
    inputExpression.evaluate(batch);
    TimestampColumnVector inputColVector = (TimestampColumnVector) batch.cols[this.inputExpression.getOutputColumn()];
    int batchSize = batch.size;
    if (batchSize == 0) {
        return;
    }
    Aggregation myagg = (Aggregation) agg;
    if (inputColVector.isRepeating) {
        if (inputColVector.noNulls) {
            iterateRepeatingNoNulls(myagg, inputColVector.getDouble(0), batchSize);
        }
    } else if (!batch.selectedInUse && inputColVector.noNulls) {
        iterateNoSelectionNoNulls(myagg, inputColVector, batchSize);
    } else if (!batch.selectedInUse) {
        iterateNoSelectionHasNulls(myagg, inputColVector, batchSize, inputColVector.isNull);
    } else if (inputColVector.noNulls) {
        iterateSelectionNoNulls(myagg, inputColVector, batchSize, batch.selected);
    } else {
        iterateSelectionHasNulls(myagg, inputColVector, batchSize, inputColVector.isNull, batch.selected);
    }
}
Also used : TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector)

Example 48 with TimestampColumnVector

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

the class VectorUDAFAvgTimestamp method aggregateInput.

@Override
public void aggregateInput(AggregationBuffer agg, VectorizedRowBatch batch) throws HiveException {
    inputExpression.evaluate(batch);
    TimestampColumnVector inputColVector = (TimestampColumnVector) batch.cols[this.inputExpression.getOutputColumn()];
    int batchSize = batch.size;
    if (batchSize == 0) {
        return;
    }
    Aggregation myagg = (Aggregation) agg;
    if (inputColVector.isRepeating) {
        if (inputColVector.noNulls) {
            if (myagg.isNull) {
                myagg.isNull = false;
                myagg.sum = 0;
                myagg.count = 0;
            }
            myagg.sum += inputColVector.getDouble(0) * batchSize;
            myagg.count += batchSize;
        }
        return;
    }
    if (!batch.selectedInUse && inputColVector.noNulls) {
        iterateNoSelectionNoNulls(myagg, inputColVector, batchSize);
    } else if (!batch.selectedInUse) {
        iterateNoSelectionHasNulls(myagg, inputColVector, batchSize, inputColVector.isNull);
    } else if (inputColVector.noNulls) {
        iterateSelectionNoNulls(myagg, inputColVector, batchSize, batch.selected);
    } else {
        iterateSelectionHasNulls(myagg, inputColVector, batchSize, inputColVector.isNull, batch.selected);
    }
}
Also used : TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector)

Example 49 with TimestampColumnVector

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

the class VectorUDAFStdSampTimestamp method aggregateInputSelection.

@Override
public void aggregateInputSelection(VectorAggregationBufferRow[] aggregationBufferSets, int aggregateIndex, VectorizedRowBatch batch) throws HiveException {
    inputExpression.evaluate(batch);
    TimestampColumnVector inputColVector = (TimestampColumnVector) batch.cols[this.inputExpression.getOutputColumn()];
    int batchSize = batch.size;
    if (batchSize == 0) {
        return;
    }
    if (inputColVector.isRepeating) {
        if (inputColVector.noNulls || !inputColVector.isNull[0]) {
            iterateRepeatingNoNullsWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputColVector.getDouble(0), batchSize);
        }
    } else if (!batch.selectedInUse && inputColVector.noNulls) {
        iterateNoSelectionNoNullsWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputColVector, batchSize);
    } else if (!batch.selectedInUse) {
        iterateNoSelectionHasNullsWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputColVector, batchSize, inputColVector.isNull);
    } else if (inputColVector.noNulls) {
        iterateSelectionNoNullsWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputColVector, batchSize, batch.selected);
    } else {
        iterateSelectionHasNullsWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputColVector, batchSize, inputColVector.isNull, batch.selected);
    }
}
Also used : TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector)

Example 50 with TimestampColumnVector

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

the class ColumnVectorGenUtil method generateTimestampColumnVector.

public static TimestampColumnVector generateTimestampColumnVector(boolean nulls, boolean repeating, int size, Random rand, Timestamp[] timestampValues) {
    TimestampColumnVector tcv = new TimestampColumnVector(size);
    tcv.noNulls = !nulls;
    tcv.isRepeating = repeating;
    Timestamp repeatingTimestamp = RandomTypeUtil.getRandTimestamp(rand);
    int nullFrequency = generateNullFrequency(rand);
    for (int i = 0; i < size; i++) {
        if (nulls && (repeating || i % nullFrequency == 0)) {
            tcv.isNull[i] = true;
            tcv.setNullValue(i);
            timestampValues[i] = null;
        } else {
            tcv.isNull[i] = false;
            if (!repeating) {
                Timestamp randomTimestamp = RandomTypeUtil.getRandTimestamp(rand);
                tcv.set(i, randomTimestamp);
                timestampValues[i] = randomTimestamp;
            } else {
                tcv.set(i, repeatingTimestamp);
                timestampValues[i] = repeatingTimestamp;
            }
        }
    }
    return tcv;
}
Also used : TimestampColumnVector(org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector) Timestamp(java.sql.Timestamp)

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