Search in sources :

Example 1 with BinaryColumn

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

the class TestFilterApiMethods method testSerializable.

@Test
public void testSerializable() throws Exception {
    BinaryColumn binary = binaryColumn("foo");
    FilterPredicate p = and(or(and(userDefined(intColumn, DummyUdp.class), predicate), eq(binary, Binary.fromString("hi"))), userDefined(longColumn, new IsMultipleOf(7)));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(p);
    oos.close();
    ObjectInputStream is = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
    FilterPredicate read = (FilterPredicate) is.readObject();
    assertEquals(p, read);
}
Also used : BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 2 with BinaryColumn

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

the class DictionaryFilterTest method testGtMissingColumn.

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

Example 3 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn 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));
}
Also used : BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) FilterPredicate(org.apache.parquet.filter2.predicate.FilterPredicate) Test(org.junit.Test)

Example 4 with BinaryColumn

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

the class DictionaryFilterTest method testNotEqBinary.

@Test
public void testNotEqBinary() throws Exception {
    BinaryColumn sharp = binaryColumn("single_value_field");
    BinaryColumn b = binaryColumn("binary_field");
    assertTrue("Should drop block with only the excluded value", canDrop(notEq(sharp, Binary.fromString("sharp")), ccmd, dictionaries));
    assertFalse("Should not drop block with any other value", canDrop(notEq(sharp, Binary.fromString("applause")), ccmd, dictionaries));
    assertFalse("Should not drop block with a known value", canDrop(notEq(b, Binary.fromString("x")), ccmd, dictionaries));
    assertFalse("Should not drop block with a known value", canDrop(notEq(b, Binary.fromString("B")), ccmd, dictionaries));
    assertFalse("Should not drop block for null", canDrop(notEq(b, null), ccmd, dictionaries));
}
Also used : BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) Test(org.junit.Test)

Example 5 with BinaryColumn

use of org.apache.parquet.filter2.predicate.Operators.BinaryColumn 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);
}
Also used : Group(org.apache.parquet.example.data.Group) BinaryColumn(org.apache.parquet.filter2.predicate.Operators.BinaryColumn) FilterPredicate(org.apache.parquet.filter2.predicate.FilterPredicate) 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