use of org.apache.parquet.filter2.predicate.FilterPredicate in project parquet-mr by apache.
the class DictionaryFilterTest method testOr.
@Test
public void testOr() throws Exception {
BinaryColumn col = binaryColumn("binary_field");
// both evaluate to false (no upper-case letters are in the dictionary)
FilterPredicate B = eq(col, Binary.fromString("B"));
FilterPredicate C = eq(col, Binary.fromString("C"));
// both evaluate to true (all lower-case letters are in the dictionary)
FilterPredicate x = eq(col, Binary.fromString("x"));
FilterPredicate y = eq(col, Binary.fromString("y"));
assertFalse("Should not drop when one predicate could be true", canDrop(or(B, y), ccmd, dictionaries));
assertFalse("Should not drop when one predicate could be true", canDrop(or(x, C), ccmd, dictionaries));
assertTrue("Should drop when both predicates must be false", canDrop(or(B, C), ccmd, dictionaries));
assertFalse("Should not drop when one predicate could be true", canDrop(or(x, y), ccmd, dictionaries));
}
use of org.apache.parquet.filter2.predicate.FilterPredicate in project parquet-mr by apache.
the class TestInputFormat method testGetFilter.
@Test
public void testGetFilter() throws IOException {
IntColumn intColumn = intColumn("foo");
FilterPredicate p = or(eq(intColumn, 7), eq(intColumn, 12));
Configuration conf = new Configuration();
ParquetInputFormat.setFilterPredicate(conf, p);
Filter read = ParquetInputFormat.getFilter(conf);
assertTrue(read instanceof FilterPredicateCompat);
assertEquals(p, ((FilterPredicateCompat) read).getFilterPredicate());
conf = new Configuration();
ParquetInputFormat.setFilterPredicate(conf, not(p));
read = ParquetInputFormat.getFilter(conf);
assertTrue(read instanceof FilterPredicateCompat);
assertEquals(and(notEq(intColumn, 7), notEq(intColumn, 12)), ((FilterPredicateCompat) read).getFilterPredicate());
assertEquals(FilterCompat.NOOP, ParquetInputFormat.getFilter(new Configuration()));
}
use of org.apache.parquet.filter2.predicate.FilterPredicate in project parquet-mr by apache.
the class TestInputFormat method testOnlyOneKindOfFilterSupported.
@Test
public void testOnlyOneKindOfFilterSupported() throws Exception {
IntColumn foo = intColumn("foo");
FilterPredicate p = or(eq(foo, 10), eq(foo, 11));
Job job = new Job();
Configuration conf = job.getConfiguration();
ParquetInputFormat.setUnboundRecordFilter(job, DummyUnboundRecordFilter.class);
try {
ParquetInputFormat.setFilterPredicate(conf, p);
fail("this should throw");
} catch (IllegalArgumentException e) {
assertEquals("You cannot provide a FilterPredicate after providing an UnboundRecordFilter", e.getMessage());
}
job = new Job();
conf = job.getConfiguration();
ParquetInputFormat.setFilterPredicate(conf, p);
try {
ParquetInputFormat.setUnboundRecordFilter(job, DummyUnboundRecordFilter.class);
fail("this should throw");
} catch (IllegalArgumentException e) {
assertEquals("You cannot provide an UnboundRecordFilter after providing a FilterPredicate", e.getMessage());
}
}
use of org.apache.parquet.filter2.predicate.FilterPredicate in project parquet-mr by apache.
the class TestRecordLevelFilters method testAllFilter.
@Test
public void testAllFilter() throws Exception {
BinaryColumn name = binaryColumn("name");
FilterPredicate pred = eq(name, Binary.fromString("no matches"));
List<Group> found = PhoneBookWriter.readFile(phonebookFile, FilterCompat.get(pred));
assertEquals(new ArrayList<Group>(), found);
}
use of org.apache.parquet.filter2.predicate.FilterPredicate in project parquet-mr by apache.
the class TestStatisticsFilter method testAnd.
@Test
public void testAnd() {
FilterPredicate yes = eq(intColumn, 9);
FilterPredicate no = eq(doubleColumn, 50D);
assertTrue(canDrop(and(yes, yes), columnMetas));
assertTrue(canDrop(and(yes, no), columnMetas));
assertTrue(canDrop(and(no, yes), columnMetas));
assertFalse(canDrop(and(no, no), columnMetas));
}
Aggregations