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);
}
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));
}
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));
}
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));
}
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);
}
Aggregations