use of org.apache.hadoop.hive.ql.exec.vector.expressions.FilterExprAndExpr in project hive by apache.
the class TestVectorFilterOperator method testBasicFilterOperator.
@Test
public void testBasicFilterOperator() throws HiveException {
VectorFilterOperator vfo = getAVectorFilterOperator();
vfo.initialize(hconf, null);
VectorExpression ve1 = new FilterLongColGreaterLongColumn(0, 1);
VectorExpression ve2 = new FilterLongColEqualDoubleScalar(2, 0);
VectorExpression ve3 = new FilterExprAndExpr();
ve3.setChildExpressions(new VectorExpression[] { ve1, ve2 });
vfo.setFilterCondition(ve3);
FakeDataReader fdr = new FakeDataReader(1024 * 1, 3);
VectorizedRowBatch vrg = fdr.getNext();
vfo.getPredicateExpression().evaluate(vrg);
// Verify
int rows = 0;
for (int i = 0; i < 1024; i++) {
LongColumnVector l1 = (LongColumnVector) vrg.cols[0];
LongColumnVector l2 = (LongColumnVector) vrg.cols[1];
LongColumnVector l3 = (LongColumnVector) vrg.cols[2];
if ((l1.vector[i] > l2.vector[i]) && (l3.vector[i] == 0)) {
rows++;
}
}
Assert.assertEquals(rows, vrg.size);
}
use of org.apache.hadoop.hive.ql.exec.vector.expressions.FilterExprAndExpr in project hive by apache.
the class TestVectorFilterOperator method testBasicFilterLargeData.
@Test
public void testBasicFilterLargeData() throws HiveException {
VectorFilterOperator vfo = getAVectorFilterOperator();
vfo.initialize(hconf, null);
VectorExpression ve1 = new FilterLongColGreaterLongColumn(0, 1);
VectorExpression ve2 = new FilterLongColEqualDoubleScalar(2, 0);
VectorExpression ve3 = new FilterExprAndExpr();
ve3.setChildExpressions(new VectorExpression[] { ve1, ve2 });
vfo.setFilterCondition(ve3);
FakeDataReader fdr = new FakeDataReader(16 * 1024 * 1024, 3);
long startTime = System.currentTimeMillis();
VectorizedRowBatch vrg = fdr.getNext();
while (vrg.size > 0) {
vfo.process(vrg, 0);
vrg = fdr.getNext();
}
long endTime = System.currentTimeMillis();
System.out.println("testBaseFilterOperator Op Time = " + (endTime - startTime));
// Base time
fdr = new FakeDataReader(16 * 1024 * 1024, 3);
long startTime1 = System.currentTimeMillis();
vrg = fdr.getNext();
LongColumnVector l1 = (LongColumnVector) vrg.cols[0];
LongColumnVector l2 = (LongColumnVector) vrg.cols[1];
LongColumnVector l3 = (LongColumnVector) vrg.cols[2];
int rows = 0;
for (int j = 0; j < 16 * 1024; j++) {
for (int i = 0; i < l1.vector.length && i < l2.vector.length && i < l3.vector.length; i++) {
if ((l1.vector[i] > l2.vector[i]) && (l3.vector[i] == 0)) {
rows++;
}
}
}
long endTime1 = System.currentTimeMillis();
System.out.println("testBaseFilterOperator base Op Time = " + (endTime1 - startTime1));
}
Aggregations