Class 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 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.

    • Constructor Detail

      • FilterCompat

        public FilterCompat()
    • 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 null
        unboundRecordFilter - 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 if NOOP is used.
        Parameters:
        filter - the filter to be checked
        Returns:
        false if the filter is null or is a no-op filter, true otherwise.