Class AbstractPrefilteredAdaptationFilter

java.lang.Object
com.onwbp.adaptation.AbstractPrefilteredAdaptationFilter
All Implemented Interfaces:
AdaptationFilter, PrefilteredAdaptationFilter

public abstract class AbstractPrefilteredAdaptationFilter extends Object implements PrefilteredAdaptationFilter
Defines a base class for implementing a PrefilteredAdaptationFilter.

It ensures that the prefilter is always applied in the AdaptationFilter.accept(Adaptation) method. The prefilter does not need to be checked again in the implementation of acceptPrefilteredRecord(Adaptation). As a consequence, the necessary consistency condition of PrefilteredAdaptationFilter is always fulfilled.

Warning: this class is not thread-safe, i.e., an instance of a subclass may only be used by one thread at a time (including the execution in a Request or calling the methods directly).

  • Constructor Details

    • AbstractPrefilteredAdaptationFilter

      public AbstractPrefilteredAdaptationFilter()
  • Method Details

    • acceptPrefilteredRecord

      public abstract boolean acceptPrefilteredRecord(Adaptation aRecord)
      Returns whether or not a record is included in the filter result, without taking the prefilter into account.

      The caller is responsible to ensure that the prefilter is already applied, i.e., this method should only be called for records for which the prefilter evaluates to true. The conditions and recommendations of the AdaptationFilter.accept(Adaptation) method apply here as well.

      Parameters:
      aRecord - for filtering, which has already passed the prefilter.
      See Also:
    • getPrefilter

      public abstract XPathFilter getPrefilter()
      Description copied from interface: PrefilteredAdaptationFilter
      Defines the prefilter. This method must always return the same filter for an instance of this interface.

      The prefilter

      • must be consistent with AdaptationFilter.accept(Adaptation), i.e., it must evaluate to true for all records where the accept method returns true.
      • may not use parameters.
      • should be selective, i.e., it should evaluate to true only for a relatively small part of the records of the table where the filter is applied on.
      • should be "index-friendly" for best performance, i.e., it should be evaluated using indexes only. This can be checked by activating the debug level of the request log and executing a the request that uses the AdaptationFilter (see Request.setSpecificFilter(AdaptationFilter)). The logged physical plan should have a Lucene scan operation with a filter corresponding to the specified prefilter.

      Specified by:
      getPrefilter in interface PrefilteredAdaptationFilter
    • accept

      public final boolean accept(Adaptation aRecord)
      Description copied from interface: AdaptationFilter
      Returns whether or not a record is included in the filter result.

      No assumptions should be made about the order that the records of the table are evaluated by this method (if sort criteria is set, the specified ordering can be applied before or after the evaluation of this filter).

      When the filter is used on large tables, it is important to implement a low-computation algorithm.

      In case of performance problems, a PrefilteredAdaptationFilter might give the query optimizer enough information to speed up the queries that use the AdaptationFilter.

      Specified by:
      accept in interface AdaptationFilter
      See Also: