Class FilterCompat
- java.lang.Object
-
- org.apache.parquet.filter2.compat.FilterCompat
-
public class FilterCompat extends Object
Parquet currently has two ways to specify a filter for dropping records at read time. The first way, that only supports filtering records during record assembly, is found inorg.apache.parquet.filter. The new API (found inorg.apache.parquet.filter2) supports also filtering entire rowgroups of records without reading them at all.This class defines a common interface that both of these filters share,
FilterCompat.Filter. A Filter can be either anUnboundRecordFilterfrom the old API, or aFilterPredicatefrom the new API, or a sentinel no-op filter.Having this common interface simplifies passing a filter through the read path of parquet's codebase.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceFilterCompat.Filterstatic classFilterCompat.FilterPredicateCompatstatic classFilterCompat.NoOpFilterstatic classFilterCompat.UnboundRecordFilterCompatstatic interfaceFilterCompat.Visitor<T>Anyone wanting to use aFilterCompat.Filterneed only implement this interface, per the visitor pattern.
-
Field Summary
Fields Modifier and Type Field Description static FilterCompat.FilterNOOP
-
Constructor Summary
Constructors Constructor Description FilterCompat()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FilterCompat.Filterget(UnboundRecordFilter unboundRecordFilter)Given an UnboundRecordFilter, return a Filter that wraps it.static FilterCompat.Filterget(FilterPredicate filterPredicate)Given a FilterPredicate, return a Filter that wraps it.static FilterCompat.Filterget(FilterPredicate filterPredicate, UnboundRecordFilter unboundRecordFilter)Given either a FilterPredicate or the class of an UnboundRecordFilter, or neither (but not both) return a Filter that wraps whichever was provided.static booleanisFilteringRequired(FilterCompat.Filter filter)Returns whether filtering is required based on the specified filter.
-
-
-
Field Detail
-
NOOP
public static final FilterCompat.Filter NOOP
-
-
Method Detail
-
get
public static FilterCompat.Filter get(FilterPredicate filterPredicate)
Given a FilterPredicate, return a Filter that wraps it. This method also logs the filter being used and rewrites the predicate to not include the not() operator.- Parameters:
filterPredicate- a filter predicate- Returns:
- a filter for the given predicate
-
get
public static FilterCompat.Filter get(UnboundRecordFilter unboundRecordFilter)
Given an UnboundRecordFilter, return a Filter that wraps it.- Parameters:
unboundRecordFilter- an unbound record filter- Returns:
- a Filter for the given record filter (from the old API)
-
get
public static FilterCompat.Filter get(FilterPredicate filterPredicate, UnboundRecordFilter unboundRecordFilter)
Given either a FilterPredicate or the class of an UnboundRecordFilter, or neither (but not both) return a Filter that wraps whichever was provided.Either filterPredicate or unboundRecordFilterClass must be null, or an exception is thrown.
If both are null, the no op filter will be returned.
- Parameters:
filterPredicate- a filter predicate, or nullunboundRecordFilter- an unbound record filter, or null- Returns:
- a Filter wrapping either the predicate or the unbound record filter (from the old API)
-
isFilteringRequired
public static boolean isFilteringRequired(FilterCompat.Filter filter)
Returns whether filtering is required based on the specified filter. It is used to avoid any significant steps to prepare filtering ifNOOPis used.- Parameters:
filter- the filter to be checked- Returns:
falseif the filter isnullor is a no-op filter,trueotherwise.
-
-