Search in sources :

Example 6 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn in project parquet-mr by apache.

the class TestRecordLevelFilters method testNameNotStartWithP.

@Test
public void testNameNotStartWithP() throws Exception {
    BinaryColumn name = binaryColumn("name");
    FilterPredicate pred = not(userDefined(name, StartWithP.class));
    List<Group> found = PhoneBookWriter.readFile(phonebookFile, FilterCompat.get(pred));
    assertFilter(found, new UserFilter() {

        @Override
        public boolean keep(User u) {
            return u.getName() == null || !u.getName().startsWith("p");
        }
    });
}
Also used : Group(org.apache.parquet.example.data.Group) User(org.apache.parquet.filter2.recordlevel.PhoneBookWriter.User) BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) FilterPredicate(org.apache.parquet.filter2.predicate.FilterPredicate) Test(org.junit.Test)

Example 7 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn in project parquet-mr by apache.

the class TestRecordLevelFilters method testNameNotNull.

@Test
public void testNameNotNull() throws Exception {
    BinaryColumn name = binaryColumn("name");
    FilterPredicate pred = notEq(name, null);
    List<Group> found = PhoneBookWriter.readFile(phonebookFile, FilterCompat.get(pred));
    assertFilter(found, new UserFilter() {

        @Override
        public boolean keep(User u) {
            return u.getName() != null;
        }
    });
}
Also used : Group(org.apache.parquet.example.data.Group) User(org.apache.parquet.filter2.recordlevel.PhoneBookWriter.User) BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) FilterPredicate(org.apache.parquet.filter2.predicate.FilterPredicate) Test(org.junit.Test)

Example 8 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn in project parquet-mr by apache.

the class DictionaryFilterTest method testGtEqMissingColumn.

@Test
public void testGtEqMissingColumn() throws Exception {
    BinaryColumn b = binaryColumn("missing_column");
    assertTrue("Should drop block for any non-null query", canDrop(gtEq(b, Binary.fromString("any")), ccmd, dictionaries));
}
Also used : BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) Test(org.junit.Test)

Example 9 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn in project parquet-mr by apache.

the class DictionaryFilterTest method testAnd.

@Test
public void testAnd() 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"));
    assertTrue("Should drop when either predicate must be false", canDrop(and(B, y), ccmd, dictionaries));
    assertTrue("Should drop when either predicate must be false", canDrop(and(x, C), ccmd, dictionaries));
    assertTrue("Should drop when either predicate must be false", canDrop(and(B, C), ccmd, dictionaries));
    assertFalse("Should not drop when either predicate could be true", canDrop(and(x, y), ccmd, dictionaries));
}
Also used : BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) FilterPredicate(org.apache.parquet.filter2.predicate.FilterPredicate) Test(org.junit.Test)

Example 10 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn in project parquet-mr by apache.

the class DictionaryFilterTest method testLtEqMissingColumn.

@Test
public void testLtEqMissingColumn() throws Exception {
    BinaryColumn b = binaryColumn("missing_column");
    assertTrue("Should drop block for any non-null query", canDrop(ltEq(b, Binary.fromString("any")), ccmd, dictionaries));
}
Also used : BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) Test(org.junit.Test)

Aggregations

BinaryColumn (org.apache.parquet.filter2.predicate.Operators.BinaryColumn)15 Test (org.junit.Test)15 FilterPredicate (org.apache.parquet.filter2.predicate.FilterPredicate)7 Group (org.apache.parquet.example.data.Group)4 User (org.apache.parquet.filter2.recordlevel.PhoneBookWriter.User)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 DoubleColumn (org.apache.parquet.filter2.predicate.Operators.DoubleColumn)1