Class FilterCompat
java.lang.Object
org.apache.parquet.filter2.compat.FilterCompat
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
in
org.apache.parquet.filter. The new API (found in org.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 an UnboundRecordFilter from the old API, or
a FilterPredicate from 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 ClassesModifier and TypeClassDescriptionstatic interfacestatic final classstatic final classstatic final classstatic interfaceAnyone wanting to use aFilterCompat.Filterneed only implement this interface, per the visitor pattern. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 booleanReturns whether filtering is required based on the specified filter.
-
Field Details
-
NOOP
-
-
Constructor Details
-
FilterCompat
public FilterCompat()
-
-
Method Details
-
get
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
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
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.
-