use of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalar in project hive by apache.
the class TestVectorArithmeticExpressions method longColAddLongScalarWithRepeatingUtil.
private void longColAddLongScalarWithRepeatingUtil(boolean isChecked) throws HiveException {
LongColumnVector in, out;
VectorizedRowBatch batch;
VectorExpression expr;
// Case 1: is repeating, no nulls
batch = getVectorizedRowBatchSingleLongVector(VectorizedRowBatch.DEFAULT_SIZE);
in = (LongColumnVector) batch.cols[0];
in.isRepeating = true;
out = (LongColumnVector) batch.cols[1];
out.isRepeating = false;
if (isChecked) {
expr = new LongColAddLongScalarChecked(0, 23, 1);
expr.setOutputTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo("bigint"));
} else {
expr = new LongColAddLongScalar(0, 23, 1);
}
expr.evaluate(batch);
// verify
Assert.assertTrue(out.isRepeating);
Assert.assertTrue(out.noNulls);
Assert.assertEquals(out.vector[0], 0 * 37 + 23);
// Case 2: is repeating, has nulls
batch = getVectorizedRowBatchSingleLongVector(VectorizedRowBatch.DEFAULT_SIZE);
in = (LongColumnVector) batch.cols[0];
in.isRepeating = true;
in.noNulls = false;
in.isNull[0] = true;
out = (LongColumnVector) batch.cols[1];
out.isRepeating = false;
out.isNull[0] = false;
out.noNulls = true;
if (isChecked) {
expr = new LongColAddLongScalarChecked(0, 23, 1);
expr.setOutputTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo("bigint"));
} else {
expr = new LongColAddLongScalar(0, 23, 1);
}
expr.evaluate(batch);
// verify
Assert.assertTrue(out.isRepeating);
Assert.assertFalse(out.noNulls);
Assert.assertEquals(true, out.isNull[0]);
verifyLongNullDataVectorEntries(out, batch.selected, batch.selectedInUse, batch.size);
}
use of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColAddLongScalar in project hive by apache.
the class TestVectorArithmeticExpressions method longColAddLongScalarCheckedWithNulls.
private void longColAddLongScalarCheckedWithNulls(boolean isChecked) throws HiveException {
VectorizedRowBatch batch = getVectorizedRowBatchSingleLongVector(VectorizedRowBatch.DEFAULT_SIZE);
LongColumnVector lcv = (LongColumnVector) batch.cols[0];
LongColumnVector lcvOut = (LongColumnVector) batch.cols[1];
TestVectorizedRowBatch.addRandomNulls(lcv);
VectorExpression expr;
if (isChecked) {
expr = new LongColAddLongScalarChecked(0, 23, 1);
expr.setOutputTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo("bigint"));
} else {
expr = new LongColAddLongScalar(0, 23, 1);
}
expr.evaluate(batch);
// verify
for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
if (!lcv.isNull[i]) {
Assert.assertEquals(i * 37 + 23, lcvOut.vector[i]);
} else {
Assert.assertTrue(lcvOut.isNull[i]);
}
}
Assert.assertFalse(lcvOut.noNulls);
Assert.assertFalse(lcvOut.isRepeating);
verifyLongNullDataVectorEntries(lcvOut, batch.selected, batch.selectedInUse, batch.size);
}
Aggregations