use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorFilterExpressions method getSimpleLongBatch.
private VectorizedRowBatch getSimpleLongBatch() {
VectorizedRowBatch batch = VectorizedRowGroupGenUtil.getVectorizedRowBatch(4, 1, 1);
LongColumnVector lcv0 = (LongColumnVector) batch.cols[0];
lcv0.vector[0] = 0;
lcv0.vector[1] = 1;
lcv0.vector[2] = 2;
lcv0.vector[3] = 3;
return batch;
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorFilterExpressions method testFilterDoubleNotBetween.
@Test
public void testFilterDoubleNotBetween() throws HiveException {
// Spot check only. null & repeating behavior are checked elsewhere for the same template.
int seed = 17;
VectorizedRowBatch vrb = VectorizedRowGroupGenUtil.getVectorizedRowBatch(5, 2, seed);
vrb.cols[0] = new DoubleColumnVector();
DoubleColumnVector dcv = (DoubleColumnVector) vrb.cols[0];
// Basic case
dcv.vector[0] = 5;
dcv.vector[1] = 20;
dcv.vector[2] = 17;
dcv.vector[3] = 15;
dcv.vector[4] = 10;
VectorExpression expr = new FilterDoubleColumnNotBetween(0, 10, 20);
expr.evaluate(vrb);
assertEquals(1, vrb.size);
assertTrue(vrb.selectedInUse);
assertEquals(0, vrb.selected[0]);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorFilterExpressions method testFilterLongColEqualLongScalar.
@Test
public void testFilterLongColEqualLongScalar() throws HiveException {
VectorizedRowBatch vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(1024, 1, 23);
FilterLongColEqualLongScalar expr = new FilterLongColEqualLongScalar(0, 46);
expr.evaluate(vrg);
assertEquals(1, vrg.size);
assertEquals(1, vrg.selected[0]);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorFilterExpressions method testFilterLongColGreaterLongColumn.
@Test
public void testFilterLongColGreaterLongColumn() throws HiveException {
int seed = 17;
VectorizedRowBatch b = VectorizedRowGroupGenUtil.getVectorizedRowBatch(VectorizedRowBatch.DEFAULT_SIZE, 2, seed);
LongColumnVector lcv0 = (LongColumnVector) b.cols[0];
LongColumnVector lcv1 = (LongColumnVector) b.cols[1];
b.size = 3;
FilterLongColGreaterLongColumn expr = new FilterLongColGreaterLongColumn(0, 1);
// Basic case
lcv0.vector[0] = 10;
lcv0.vector[1] = 10;
lcv0.vector[2] = 10;
lcv1.vector[0] = 20;
lcv1.vector[1] = 1;
lcv1.vector[2] = 7;
expr.evaluate(b);
assertEquals(2, b.size);
assertEquals(1, b.selected[0]);
assertEquals(2, b.selected[1]);
// handle null with selected in use
lcv0.noNulls = false;
lcv0.isNull[1] = true;
expr.evaluate(b);
assertEquals(1, b.size);
assertEquals(2, b.selected[0]);
// handle repeating
b.size = 3;
b.selectedInUse = false;
lcv0.isRepeating = true;
lcv0.noNulls = true;
expr.evaluate(b);
assertEquals(2, b.size);
// handle repeating null
b.size = 3;
b.selectedInUse = false;
lcv0.isNull[0] = true;
lcv0.noNulls = false;
expr.evaluate(b);
assertEquals(0, b.size);
// handle null on both sizes (not repeating)
b.size = 3;
b.selectedInUse = false;
lcv0.isRepeating = false;
lcv1.noNulls = false;
lcv1.isNull[2] = true;
expr.evaluate(b);
assertEquals(0, b.size);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorFilterExpressions method testFilterDecimalColEqualDecimalScalar.
/**
* This tests the template for Decimal Column-Scalar comparison filters,
* called FilterDecimalColumnCompareScalar.txt. Only equal is tested for
* multiple cases because the logic is the same for <, >, <=, >=, == and !=.
*/
@Test
public void testFilterDecimalColEqualDecimalScalar() throws HiveException {
VectorizedRowBatch b = getVectorizedRowBatch1DecimalCol();
HiveDecimal scalar = HiveDecimal.create("-3.30");
VectorExpression expr = new FilterDecimalColEqualDecimalScalar(0, scalar);
expr.evaluate(b);
// check that right row(s) are selected
assertTrue(b.selectedInUse);
assertEquals(1, b.selected[0]);
assertEquals(1, b.size);
// try again with a null value
b = getVectorizedRowBatch1DecimalCol();
b.cols[0].noNulls = false;
b.cols[0].isNull[1] = true;
expr.evaluate(b);
// verify that no rows were selected
assertEquals(0, b.size);
// try the repeating case
b = getVectorizedRowBatch1DecimalCol();
b.cols[0].isRepeating = true;
expr.evaluate(b);
// verify that no rows were selected
assertEquals(0, b.size);
// try the repeating null case
b = getVectorizedRowBatch1DecimalCol();
b.cols[0].isRepeating = true;
b.cols[0].noNulls = false;
b.cols[0].isNull[0] = true;
expr.evaluate(b);
// verify that no rows were selected
assertEquals(0, b.size);
}
Aggregations