use of com.facebook.presto.common.relation.Predicate in project presto by prestodb.
the class TestOrcReaderPositions method testStripeSkippingWithAppendNumber.
@Test
public void testStripeSkippingWithAppendNumber() throws Exception {
try (TempFile tempFile = new TempFile()) {
createMultiStripeFile(tempFile.getFile());
// EVery stripe has 20 rows and there are total of 5 stripes
// test reading second and fourth stripes
OrcPredicate predicate = (numberOfRows, statisticsByColumnIndex) -> {
if (numberOfRows == 100) {
return true;
}
IntegerStatistics stats = statisticsByColumnIndex.get(0).getIntegerStatistics();
return ((stats.getMin() == 60) && (stats.getMax() == 117)) || ((stats.getMin() == 180) && (stats.getMax() == 237));
};
List<Long> expectedValues = new ArrayList<>();
expectedValues.addAll(LongStream.range(20, 40).collect(ArrayList::new, List::add, List::addAll));
expectedValues.addAll(LongStream.range(60, 80).collect(ArrayList::new, List::add, List::addAll));
List<Long> actualValues = new ArrayList<>();
OrcSelectiveRecordReader reader = createCustomOrcSelectiveRecordReader(tempFile, ORC, predicate, BIGINT, MAX_BATCH_SIZE, false, true);
assertNotNull(reader);
Page returnPage;
while (true) {
returnPage = reader.getNextPage();
if (returnPage == null) {
break;
}
Block rowNumberBlock = returnPage.getBlock(1);
for (int i = 0; i < returnPage.getPositionCount(); i++) {
actualValues.add(rowNumberBlock.getLong(i));
}
}
assertEquals(actualValues, expectedValues);
}
}
use of com.facebook.presto.common.relation.Predicate in project presto by prestodb.
the class RowExpressionPredicateCompiler method definePredicateClass.
private ClassDefinition definePredicateClass(SqlFunctionProperties sqlFunctionProperties, Map<SqlFunctionId, SqlInvokedFunction> sessionFunctions, RowExpression predicate, int[] inputChannels, CallSiteBinder callSiteBinder) {
ClassDefinition classDefinition = new ClassDefinition(a(PUBLIC, FINAL), makeClassName(Predicate.class.getSimpleName(), Optional.empty()), type(Object.class), type(Predicate.class));
CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(classDefinition, callSiteBinder);
generatePredicateMethod(sqlFunctionProperties, sessionFunctions, classDefinition, callSiteBinder, cachedInstanceBinder, predicate);
// getInputChannels
classDefinition.declareMethod(a(PUBLIC), "getInputChannels", type(int[].class)).getBody().append(invoke(callSiteBinder.bind(inputChannels, int[].class), "getInputChannels")).retObject();
// constructor
generateConstructor(classDefinition, cachedInstanceBinder);
return classDefinition;
}
Aggregations