Class FilterApi
- java.lang.Object
-
- org.apache.parquet.filter2.predicate.FilterApi
-
public final class FilterApi extends Object
The Filter API is expressed through these static methods.Example usage:
IntColumn foo = intColumn("foo"); DoubleColumn bar = doubleColumn("x.y.bar"); // foo == 10 || bar <= 17.0 FilterPredicate pred = or(eq(foo, 10), ltEq(bar, 17.0));
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FilterPredicateand(FilterPredicate left, FilterPredicate right)Constructs the logical and of two predicates.static Operators.BinaryColumnbinaryColumn(String columnPath)static Operators.BooleanColumnbooleanColumn(String columnPath)static Operators.DoubleColumndoubleColumn(String columnPath)static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq>
Operators.Eq<T>eq(C column, T value)Keeps records if their value is equal to the provided value.static Operators.FloatColumnfloatColumn(String columnPath)static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt>
Operators.Gt<T>gt(C column, T value)Keeps records if their value is greater than (but not equal to) the provided value.static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt>
Operators.GtEq<T>gtEq(C column, T value)Keeps records if their value is greater than or equal to the provided value.static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq>
Operators.In<T>in(C column, Set<T> values)Keeps records if their value is in the provided values.static Operators.IntColumnintColumn(String columnPath)static Operators.LongColumnlongColumn(String columnPath)static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt>
Operators.Lt<T>lt(C column, T value)Keeps records if their value is less than (but not equal to) the provided value.static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt>
Operators.LtEq<T>ltEq(C column, T value)Keeps records if their value is less than or equal to the provided value.static FilterPredicatenot(FilterPredicate predicate)Constructs the logical not (or inverse) of a predicate.static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq>
Operators.NotEq<T>notEq(C column, T value)Keeps records if their value is not equal to the provided value.static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq>
Operators.NotIn<T>notIn(C column, Set<T> values)Keeps records if their value is not in the provided values.static FilterPredicateor(FilterPredicate left, FilterPredicate right)Constructs the logical or of two predicates.static <T extends Comparable<T>,U extends UserDefinedPredicate<T>>
Operators.UserDefined<T,U>userDefined(Operators.Column<T> column, Class<U> clazz)Keeps records that pass the providedUserDefinedPredicatestatic <T extends Comparable<T>,U extends UserDefinedPredicate<T> & Serializable>
Operators.UserDefined<T,U>userDefined(Operators.Column<T> column, U udp)Keeps records that pass the providedUserDefinedPredicate
-
-
-
Method Detail
-
intColumn
public static Operators.IntColumn intColumn(String columnPath)
-
longColumn
public static Operators.LongColumn longColumn(String columnPath)
-
floatColumn
public static Operators.FloatColumn floatColumn(String columnPath)
-
doubleColumn
public static Operators.DoubleColumn doubleColumn(String columnPath)
-
booleanColumn
public static Operators.BooleanColumn booleanColumn(String columnPath)
-
binaryColumn
public static Operators.BinaryColumn binaryColumn(String columnPath)
-
eq
public static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> Operators.Eq<T> eq(C column, T value)
Keeps records if their value is equal to the provided value. Nulls are treated the same way the java programming language does.For example: eq(column, null) will keep all records whose value is null. eq(column, 7) will keep all records whose value is 7, and will drop records whose value is null
- Type Parameters:
T- the Java type of values in the columnC- the column type that corresponds to values of type T- Parameters:
column- a column reference created by FilterApivalue- a value that matches the column's type- Returns:
- an equals predicate for the given column and value
-
notEq
public static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> Operators.NotEq<T> notEq(C column, T value)
Keeps records if their value is not equal to the provided value. Nulls are treated the same way the java programming language does.For example: notEq(column, null) will keep all records whose value is not null. notEq(column, 7) will keep all records whose value is not 7, including records whose value is null. NOTE: this is different from how some query languages handle null. For example, SQL and pig will drop nulls when you filter by not equal to 7. To achieve similar behavior in this api, do: and(notEq(column, 7), notEq(column, null)) NOTE: be sure to read the
lt(C, T),ltEq(C, T),gt(C, T),gtEq(C, T)operator's docs for how they handle nulls- Type Parameters:
T- the Java type of values in the columnC- the column type that corresponds to values of type T- Parameters:
column- a column reference created by FilterApivalue- a value that matches the column's type- Returns:
- a not-equals predicate for the given column and value
-
lt
public static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> Operators.Lt<T> lt(C column, T value)
Keeps records if their value is less than (but not equal to) the provided value. The provided value cannot be null, as less than null has no meaning. Records with null values will be dropped.For example: lt(column, 7) will keep all records whose value is less than (but not equal to) 7, and not null.
- Type Parameters:
T- the Java type of values in the columnC- the column type that corresponds to values of type T- Parameters:
column- a column reference created by FilterApivalue- a value that matches the column's type- Returns:
- a less-than predicate for the given column and value
-
ltEq
public static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> Operators.LtEq<T> ltEq(C column, T value)
Keeps records if their value is less than or equal to the provided value. The provided value cannot be null, as less than null has no meaning. Records with null values will be dropped.For example: ltEq(column, 7) will keep all records whose value is less than or equal to 7, and not null.
- Type Parameters:
T- the Java type of values in the columnC- the column type that corresponds to values of type T- Parameters:
column- a column reference created by FilterApivalue- a value that matches the column's type- Returns:
- a less-than-or-equal predicate for the given column and value
-
gt
public static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> Operators.Gt<T> gt(C column, T value)
Keeps records if their value is greater than (but not equal to) the provided value. The provided value cannot be null, as less than null has no meaning. Records with null values will be dropped.For example: gt(column, 7) will keep all records whose value is greater than (but not equal to) 7, and not null.
- Type Parameters:
T- the Java type of values in the columnC- the column type that corresponds to values of type T- Parameters:
column- a column reference created by FilterApivalue- a value that matches the column's type- Returns:
- a greater-than predicate for the given column and value
-
gtEq
public static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> Operators.GtEq<T> gtEq(C column, T value)
Keeps records if their value is greater than or equal to the provided value. The provided value cannot be null, as less than null has no meaning. Records with null values will be dropped.For example: gtEq(column, 7) will keep all records whose value is greater than or equal to 7, and not null.
- Type Parameters:
T- the Java type of values in the columnC- the column type that corresponds to values of type T- Parameters:
column- a column reference created by FilterApivalue- a value that matches the column's type- Returns:
- a greater-than-or-equal predicate for the given column and value
-
in
public static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> Operators.In<T> in(C column, Set<T> values)
Keeps records if their value is in the provided values. The provided values set could not be null, but could contains a null value.For example:
will keep all records whose values are 9, null, or 50.Set<Integer> set = new HashSet<>(); set.add(9); set.add(null); set.add(50); in(column, set);- Type Parameters:
T- the Java type of values in the columnC- the column type that corresponds to values of type T- Parameters:
column- a column reference created by FilterApivalues- a set of values that match the column's type- Returns:
- an in predicate for the given column and value
-
notIn
public static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> Operators.NotIn<T> notIn(C column, Set<T> values)
Keeps records if their value is not in the provided values. The provided values set could not be null, but could contains a null value.For example:
will keep all records whose values are not 9, null, and 50.Set<Integer> set = new HashSet<>(); set.add(9); set.add(null); set.add(50); notIn(column, set);- Type Parameters:
T- the Java type of values in the columnC- the column type that corresponds to values of type T- Parameters:
column- a column reference created by FilterApivalues- a set of values that match the column's type- Returns:
- an notIn predicate for the given column and value
-
userDefined
public static <T extends Comparable<T>,U extends UserDefinedPredicate<T>> Operators.UserDefined<T,U> userDefined(Operators.Column<T> column, Class<U> clazz)
Keeps records that pass the providedUserDefinedPredicateThe provided class must have a default constructor. To use an instance of a UserDefinedPredicate instead, see userDefined below.
- Type Parameters:
T- the Java type of values in the columnU- a user-defined predicate for values of type T- Parameters:
column- a column reference created by FilterApiclazz- a user-defined predicate class- Returns:
- a user-defined predicate for the given column
-
userDefined
public static <T extends Comparable<T>,U extends UserDefinedPredicate<T> & Serializable> Operators.UserDefined<T,U> userDefined(Operators.Column<T> column, U udp)
Keeps records that pass the providedUserDefinedPredicateThe provided instance of UserDefinedPredicate must be serializable.
- Type Parameters:
T- the Java type of values in the columnU- a user-defined predicate for values of type T- Parameters:
column- a column reference created by FilterApiudp- a user-defined predicate instance- Returns:
- a user-defined predicate for the given column
-
and
public static FilterPredicate and(FilterPredicate left, FilterPredicate right)
Constructs the logical and of two predicates. Records will be kept if both the left and right predicate agree that the record should be kept.- Parameters:
left- a predicateright- a predicate- Returns:
- an and predicate from the result of the left and right predicates
-
or
public static FilterPredicate or(FilterPredicate left, FilterPredicate right)
Constructs the logical or of two predicates. Records will be kept if either the left or right predicate is satisfied (or both).- Parameters:
left- a predicateright- a predicate- Returns:
- an or predicate from the result of the left and right predicates
-
not
public static FilterPredicate not(FilterPredicate predicate)
Constructs the logical not (or inverse) of a predicate. Records will be kept if the provided predicate is not satisfied.- Parameters:
predicate- a predicate- Returns:
- a not predicate wrapping the result of the given predicate
-
-