use of org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector in project hive by apache.
the class VectorUDFDateAddColScalar method evaluateTimestamp.
protected long evaluateTimestamp(ColumnVector columnVector, int index) {
TimestampColumnVector tcv = (TimestampColumnVector) columnVector;
// Convert to date value (in days)
long days = DateWritable.millisToDays(tcv.getTime(index));
if (isPositive) {
days += numDays;
} else {
days -= numDays;
}
return days;
}
use of org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector in project hive by apache.
the class VectorUDFDateDiffColCol method toDateArray.
private LongColumnVector toDateArray(VectorizedRowBatch batch, TypeInfo typeInfo, ColumnVector inputColVector, LongColumnVector dateVector) {
PrimitiveCategory primitiveCategory = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory();
int size = batch.size;
if (primitiveCategory == PrimitiveCategory.DATE) {
return (LongColumnVector) inputColVector;
}
if (size > dateVector.vector.length) {
if (dateVector1 == dateVector) {
dateVector1 = new LongColumnVector(size * 2);
dateVector = dateVector1;
} else {
dateVector2 = new LongColumnVector(size * 2);
dateVector = dateVector2;
}
}
switch(primitiveCategory) {
case TIMESTAMP:
TimestampColumnVector tcv = (TimestampColumnVector) inputColVector;
copySelected(tcv, batch.selectedInUse, batch.selected, batch.size, dateVector);
return dateVector;
case STRING:
case CHAR:
case VARCHAR:
BytesColumnVector bcv = (BytesColumnVector) inputColVector;
copySelected(bcv, batch.selectedInUse, batch.selected, batch.size, dateVector);
return dateVector;
default:
throw new Error("Unsupported input type " + primitiveCategory.name());
}
}
use of org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector in project hive by apache.
the class VectorUDFDateDiffScalarCol method evaluateTimestamp.
protected int evaluateTimestamp(ColumnVector columnVector, int index) {
TimestampColumnVector tcv = (TimestampColumnVector) columnVector;
date.setTime(tcv.getTime(index));
return baseDate - DateWritable.dateToDays(date);
}
use of org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector in project hive by apache.
the class VectorUDAFSumTimestamp method aggregateInputSelection.
@Override
public void aggregateInputSelection(VectorAggregationBufferRow[] aggregationBufferSets, int aggregateIndex, VectorizedRowBatch batch) throws HiveException {
int batchSize = batch.size;
if (batchSize == 0) {
return;
}
inputExpression.evaluate(batch);
TimestampColumnVector inputVector = (TimestampColumnVector) batch.cols[this.inputExpression.getOutputColumnNum()];
if (inputVector.noNulls) {
if (inputVector.isRepeating) {
iterateNoNullsRepeatingWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputVector.getDouble(0), batchSize);
} else {
if (batch.selectedInUse) {
iterateNoNullsSelectionWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputVector, batch.selected, batchSize);
} else {
iterateNoNullsWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputVector, batchSize);
}
}
} else {
if (inputVector.isRepeating) {
if (batch.selectedInUse) {
iterateHasNullsRepeatingSelectionWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputVector.getDouble(0), batchSize, batch.selected, inputVector.isNull);
} else {
iterateHasNullsRepeatingWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputVector.getDouble(0), batchSize, inputVector.isNull);
}
} else {
if (batch.selectedInUse) {
iterateHasNullsSelectionWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputVector, batchSize, batch.selected, inputVector.isNull);
} else {
iterateHasNullsWithAggregationSelection(aggregationBufferSets, aggregateIndex, inputVector, batchSize, inputVector.isNull);
}
}
}
}
use of org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector in project hive by apache.
the class FuncTimestampToDecimal method evaluate.
@Override
public void evaluate(VectorizedRowBatch batch) {
if (childExpressions != null) {
super.evaluateChildren(batch);
}
TimestampColumnVector inputColVector = (TimestampColumnVector) batch.cols[inputColumn];
int[] sel = batch.selected;
int n = batch.size;
DecimalColumnVector outputColVector = (DecimalColumnVector) batch.cols[outputColumnNum];
boolean[] inputIsNull = inputColVector.isNull;
boolean[] outputIsNull = outputColVector.isNull;
if (n == 0) {
// Nothing to do
return;
}
// We do not need to do a column reset since we are carefully changing the output.
outputColVector.isRepeating = false;
if (inputColVector.isRepeating) {
if (inputColVector.noNulls || !inputIsNull[0]) {
// Set isNull before call in case it changes it mind.
outputIsNull[0] = false;
func(outputColVector, inputColVector, 0);
} else {
outputIsNull[0] = true;
outputColVector.noNulls = false;
}
outputColVector.isRepeating = true;
return;
}
if (inputColVector.noNulls) {
if (batch.selectedInUse) {
if (!outputColVector.noNulls) {
for (int j = 0; j != n; j++) {
final int i = sel[j];
// Set isNull before call in case it changes it mind.
outputIsNull[i] = false;
func(outputColVector, inputColVector, i);
}
} else {
for (int j = 0; j != n; j++) {
final int i = sel[j];
func(outputColVector, inputColVector, i);
}
}
} else {
if (!outputColVector.noNulls) {
// Assume it is almost always a performance win to fill all of isNull so we can
// safely reset noNulls.
Arrays.fill(outputIsNull, false);
outputColVector.noNulls = true;
}
for (int i = 0; i != n; i++) {
func(outputColVector, inputColVector, i);
}
}
} else /* there are nulls in the inputColVector */
{
// Carefully handle NULLs...
outputColVector.noNulls = false;
if (batch.selectedInUse) {
for (int j = 0; j != n; j++) {
int i = sel[j];
outputColVector.isNull[i] = inputColVector.isNull[i];
if (!inputColVector.isNull[i]) {
func(outputColVector, inputColVector, i);
}
}
} else {
System.arraycopy(inputColVector.isNull, 0, outputColVector.isNull, 0, n);
for (int i = 0; i != n; i++) {
if (!inputColVector.isNull[i]) {
func(outputColVector, inputColVector, i);
}
}
}
}
}
Aggregations