use of com.facebook.presto.common.predicate.FilterFunction in project presto by prestodb.
the class TestFilterFunction method testFilter.
@Test
public void testFilter() {
ConnectorSession session = new TestingConnectorSession(ImmutableList.of());
FilterFunction filter = new FilterFunction(session.getSqlFunctionProperties(), true, new IsOddPredicate());
Block numbers = makeNumbers(0, 1000);
int[] allPositions = makePositions(0, 1000, 1);
assertFilter(filter, numbers, allPositions, allPositions.length);
Block dictionaryNumbers = new DictionaryBlock(numbers, allPositions);
// Sparse coverage of the dictionary values
int[] sparsePositions = makePositions(1, 300, 3);
assertFilter(filter, dictionaryNumbers, sparsePositions, sparsePositions.length);
// Full coverage of the dictionary values
assertFilter(filter, dictionaryNumbers, allPositions, allPositions.length);
// Test with a different DictionaryBlock over the same numbers. Results are reused. The DictionaryBlock covers the
// values sparsely. TheDictionaryBlock itself is accessed sparsely.
DictionaryBlock otherDictionary = new DictionaryBlock(numbers, makePositions(1, 332, 3));
int[] otherDictionaryPositions = makePositions(0, 150, 2);
assertFilter(filter, otherDictionary, otherDictionaryPositions, otherDictionaryPositions.length);
// Repeat test on a DictionaryBlock over different content to make sure that cached results are not reused.
assertFilter(filter, new DictionaryBlock(makeNumbers(1, 1001), allPositions), allPositions, allPositions.length);
}
Aggregations