use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorMathFunctions method testVectorLn.
@Test
public void testVectorLn() {
// test double->double version
VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut();
DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1];
b.cols[0].noNulls = true;
VectorExpression expr = new FuncLnDoubleToDouble(0, 1);
expr.evaluate(b);
Assert.assertEquals(Math.log(0.5), resultV.vector[4]);
// test long->double version
b = getVectorizedRowBatchLongInDoubleOut();
resultV = (DoubleColumnVector) b.cols[1];
b.cols[0].noNulls = true;
expr = new FuncLnLongToDouble(0, 1);
expr.evaluate(b);
Assert.assertEquals(Math.log(2), resultV.vector[4]);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorMathFunctions method getVectorizedRowBatchDoubleInDoubleOut.
public static VectorizedRowBatch getVectorizedRowBatchDoubleInDoubleOut() {
VectorizedRowBatch batch = new VectorizedRowBatch(2);
DoubleColumnVector inV;
DoubleColumnVector outV;
outV = new DoubleColumnVector();
inV = new DoubleColumnVector();
inV.vector[0] = -1.5d;
inV.vector[1] = -0.5d;
inV.vector[2] = -0.1d;
inV.vector[3] = 0d;
inV.vector[4] = 0.5d;
inV.vector[5] = 0.7d;
inV.vector[6] = 1.5d;
inV.vector[7] = 1.2345678d;
batch.cols[0] = inV;
batch.cols[1] = outV;
batch.size = 8;
return batch;
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorGenericDateExpressions method testDateAddColScalar.
private void testDateAddColScalar(VectorExpression.Type colType1, boolean isPositive) {
LongColumnVector date1 = newRandomLongColumnVector(10000, size);
ColumnVector col1 = castTo(date1, colType1);
long scalar2 = newRandom(1000);
LongColumnVector output = new LongColumnVector(size);
VectorizedRowBatch batch = new VectorizedRowBatch(2, size);
batch.cols[0] = col1;
batch.cols[1] = output;
validateDateAdd(batch, colType1, scalar2, isPositive, date1);
TestVectorizedRowBatch.addRandomNulls(batch.cols[0]);
validateDateAdd(batch, colType1, scalar2, isPositive, date1);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorGenericDateExpressions method testDateAddScalarCol.
private void testDateAddScalarCol(VectorExpression.Type colType1, boolean isPositive) {
LongColumnVector date2 = newRandomLongColumnVector(10000, size);
long scalar1 = newRandom(1000);
LongColumnVector output = new LongColumnVector(size);
VectorizedRowBatch batch = new VectorizedRowBatch(2, size);
batch.cols[0] = date2;
batch.cols[1] = output;
validateDateAdd(batch, scalar1, date2, colType1, isPositive);
TestVectorizedRowBatch.addRandomNulls(date2);
batch.cols[0] = date2;
validateDateAdd(batch, scalar1, date2, colType1, isPositive);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorLogicalExpressions method testBooleanFiltersOnColumns.
@Test
public void testBooleanFiltersOnColumns() {
VectorizedRowBatch batch = getBatchThreeBooleanCols();
SelectColumnIsTrue expr = new SelectColumnIsTrue(0);
expr.evaluate(batch);
assertEquals(3, batch.size);
assertEquals(2, batch.selected[0]);
assertEquals(3, batch.selected[1]);
assertEquals(7, batch.selected[2]);
batch = getBatchThreeBooleanCols();
SelectColumnIsFalse expr1 = new SelectColumnIsFalse(1);
expr1.evaluate(batch);
assertEquals(3, batch.size);
assertEquals(0, batch.selected[0]);
assertEquals(2, batch.selected[1]);
assertEquals(4, batch.selected[2]);
}
Aggregations