use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorLogicalExpressions method testFilterExprOrExprWithBatchReuse.
@Test
public void testFilterExprOrExprWithBatchReuse() {
VectorizedRowBatch batch1 = getBatchThreeBooleanCols();
SelectColumnIsTrue expr1 = new SelectColumnIsTrue(0);
SelectColumnIsFalse expr2 = new SelectColumnIsFalse(1);
FilterExprOrExpr orExpr = new FilterExprOrExpr();
orExpr.setChildExpressions(new VectorExpression[] { expr1, expr2 });
orExpr.evaluate(batch1);
// Now re-initialize batch1 to simulate batch-object re-use.
for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
batch1.selected[i] = 0;
}
batch1.size = BOOLEAN_COLUMN_TEST_SIZE;
batch1.selectedInUse = false;
// Swap column vectors to simulate change in data
ColumnVector tmp = batch1.cols[0];
batch1.cols[0] = batch1.cols[1];
batch1.cols[1] = tmp;
orExpr.evaluate(batch1);
assertEquals(5, batch1.size);
assertEquals(0, batch1.selected[0]);
assertEquals(1, batch1.selected[1]);
assertEquals(3, batch1.selected[2]);
assertEquals(5, batch1.selected[3]);
assertEquals(6, batch1.selected[4]);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorLogicalExpressions method testSelectColumnIsNull.
@Test
public void testSelectColumnIsNull() {
// has nulls, not repeating
VectorizedRowBatch batch = getBatchThreeBooleanCols();
SelectColumnIsNull expr = new SelectColumnIsNull(0);
expr.evaluate(batch);
assertEquals(3, batch.size);
assertEquals(4, batch.selected[0]);
assertEquals(5, batch.selected[1]);
assertEquals(8, batch.selected[2]);
// No nulls case, not repeating
batch = getBatchThreeBooleanCols();
batch.cols[0].noNulls = true;
expr.evaluate(batch);
Assert.assertEquals(0, batch.size);
// isRepeating, and there are nulls
batch = getBatchThreeBooleanCols();
batch.cols[0].isRepeating = true;
batch.cols[0].isNull[0] = true;
int initialSize = batch.size;
expr.evaluate(batch);
Assert.assertEquals(initialSize, batch.size);
// isRepeating, and no nulls
batch = getBatchThreeBooleanCols();
batch.cols[0].isRepeating = true;
batch.cols[0].noNulls = true;
expr.evaluate(batch);
Assert.assertEquals(0, batch.size);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorStringExpressions method testStringColCompareVarCharScalarProjection.
@Test
public void testStringColCompareVarCharScalarProjection() {
VectorizedRowBatch batch = makeStringBatch();
VectorExpression expr;
expr = new StringGroupColEqualVarCharScalar(0, new HiveVarchar(new String(red2), 8), 2);
expr.evaluate(batch);
Assert.assertEquals(3, batch.size);
LongColumnVector outVector = (LongColumnVector) batch.cols[2];
Assert.assertEquals(1, outVector.vector[0]);
Assert.assertEquals(0, outVector.vector[1]);
Assert.assertEquals(0, outVector.vector[2]);
batch = makeStringBatch();
expr = new StringGroupColEqualVarCharScalar(0, new HiveVarchar(new String(green), 10), 2);
expr.evaluate(batch);
Assert.assertEquals(3, batch.size);
outVector = (LongColumnVector) batch.cols[2];
Assert.assertEquals(0, outVector.vector[0]);
Assert.assertEquals(1, outVector.vector[1]);
Assert.assertEquals(0, outVector.vector[2]);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorStringExpressions method testStringColCompareStringScalarProjection.
@Test
public void testStringColCompareStringScalarProjection() {
VectorizedRowBatch batch = makeStringBatch();
VectorExpression expr;
expr = new StringGroupColEqualStringScalar(0, red2, 2);
expr.evaluate(batch);
Assert.assertEquals(3, batch.size);
LongColumnVector outVector = (LongColumnVector) batch.cols[2];
Assert.assertEquals(1, outVector.vector[0]);
Assert.assertEquals(0, outVector.vector[1]);
Assert.assertEquals(0, outVector.vector[2]);
batch = makeStringBatch();
expr = new StringGroupColEqualStringScalar(0, green, 2);
expr.evaluate(batch);
Assert.assertEquals(3, batch.size);
outVector = (LongColumnVector) batch.cols[2];
Assert.assertEquals(0, outVector.vector[0]);
Assert.assertEquals(1, outVector.vector[1]);
Assert.assertEquals(0, outVector.vector[2]);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch in project hive by apache.
the class TestVectorStringExpressions method makeTrimBatch.
// Make a batch to test the trim functions.
private VectorizedRowBatch makeTrimBatch() {
VectorizedRowBatch b = new VectorizedRowBatch(2);
BytesColumnVector inV = new BytesColumnVector();
BytesColumnVector outV = new BytesColumnVector();
b.cols[0] = inV;
b.cols[1] = outV;
inV.setRef(0, emptyString, 0, 0);
inV.setRef(1, blanksLeft, 0, blanksLeft.length);
inV.setRef(2, blanksRight, 0, blanksRight.length);
inV.setRef(3, blanksBoth, 0, blanksBoth.length);
inV.setRef(4, red, 0, red.length);
inV.setRef(5, blankString, 0, blankString.length);
b.size = 5;
return b;
}
Aggregations