Class AbstractQueryRecorderFilter<T>

Type Parameters:
T - the type of the input argument to the filter
All Implemented Interfaces:
Filter<T>, QueryRecorderFilter<T>, Serializable
Direct Known Subclasses:
AlwaysFilter, ExtractorFilter, InKeySetFilter, LimitFilter, NeverFilter, NotFilter, WrapperQueryRecorderFilter

public abstract class AbstractQueryRecorderFilter<T> extends ExternalizableHelper implements QueryRecorderFilter<T>
Abstract base class implementation of QueryRecorderFilter.
Since:
Coherence 3.7.1
Author:
tb 2011.05.26
See Also:
  • Constructor Details

    • AbstractQueryRecorderFilter

      public AbstractQueryRecorderFilter()
  • Method Details

    • explain

      public void explain(QueryContext ctx, QueryRecord.PartialResult.ExplainStep step, Set setKeys)
      Record the projected query execution cost by this filter.

      This method is expected to record the order of execution and estimated cost of applying corresponding indexes in the given step without actually applying any indexes or evaluating entries.

      Specified by:
      explain in interface QueryRecorderFilter<T>
      Parameters:
      ctx - the query context
      step - the step used to record the estimated execution cost
      setKeys - the set of keys that would be filtered
    • trace

      public Filter trace(QueryContext ctx, QueryRecord.PartialResult.TraceStep step, Set setKeys)
      Filter the given keys using available indexes and record the cost of execution on the given step of the QueryRecord.

      This method should record the size of the given key set before and after applying corresponding indexes using QueryRecord.PartialResult.RecordableStep.recordPreFilterKeys(int) and QueryRecord.PartialResult.TraceStep.recordPostFilterKeys(int) as well as the corresponding execution time using the QueryRecord.PartialResult.TraceStep.recordDuration(long) method.

      This method is only called if the filter is an IndexAwareFilter and its implementations should explicitly call applyIndex() to actually perform the query. Additionally, this method should return the filter object (if any) returned by the applyIndex() call.

      Specified by:
      trace in interface QueryRecorderFilter<T>
      Parameters:
      ctx - the query context
      step - the step used to record the execution cost
      setKeys - the mutable set of keys that remain to be filtered
      Returns:
      the filter returned from IndexAwareFilter.applyIndex(Map, Set)
    • trace

      public boolean trace(QueryContext ctx, QueryRecord.PartialResult.TraceStep step, Map.Entry entry)
      Evaluate the specified entry against this filter and record the evaluation cost on the given step of the QueryRecord.

      This method should record the corresponding latencies using QueryRecord.PartialResult.TraceStep.recordDuration(long).

      Implementations are responsible for explicitly calling evaluateEntry() method to perform the actual entry evaluation. Additionally, this method should return the result of the evaluateEntry call.

      Specified by:
      trace in interface QueryRecorderFilter<T>
      Parameters:
      ctx - the context
      step - the step used to record the evaluation cost
      entry - the entry to evaluate
      Returns:
      the result returned from EntryFilter.evaluateEntry(Map.Entry)
    • explain

      protected static <T> void explain(Filter<T> filter, Map mapIndexes, Set setKeys, QueryRecord.PartialResult.ExplainStep step)
      Record an estimated cost of query execution for a given filter.
      Type Parameters:
      T - the type of the input argument to the filter
      Parameters:
      filter - the filter
      mapIndexes - a read-only map of available MapIndex objects, keyed by the associated ValueExtractor
      setKeys - the mutable set of keys that remain to be filtered
      step - the step used to record the execution cost
    • explain

      protected static <T> void explain(Filter<T> filter, Map mapIndexes, Set setKeys, QueryRecord.PartialResult.ExplainStep step, ValueExtractor extractor)
      Record an estimated cost of query execution for a given filter.
      Type Parameters:
      T - the type of the input argument to the filter
      Parameters:
      filter - the filter
      mapIndexes - a read-only map of available MapIndex objects, keyed by the associated ValueExtractor
      setKeys - the mutable set of keys that remain to be filtered
      step - the step used to record the execution cost
      extractor - an optional ValueExtractor used by the query
    • trace

      protected static <T> Filter<T> trace(Filter<T> filter, Map mapIndexes, Set setKeys, QueryRecord.PartialResult.TraceStep step)
      Record the actual cost of applying the specified filter to the specified keySet.
      Type Parameters:
      T - the type of the input argument to the filter
      Parameters:
      filter - the filter
      mapIndexes - a read-only map of available MapIndex objects, keyed by the associated ValueExtractor
      setKeys - the mutable set of keys that remain to be filtered
      step - the step used to record the execution cost
      Returns:
      a Filter object (which may be an EntryFilter) that can be used to process the remaining keys, or null if no additional filter processing is necessary
    • trace

      protected static <T> Filter<T> trace(Filter<T> filter, Map mapIndexes, Set setKeys, QueryRecord.PartialResult.TraceStep step, ValueExtractor extractor)
      Record the actual cost of applying the specified filter to the specified keySet.
      Type Parameters:
      T - the type of the input argument to the filter
      Parameters:
      filter - the filter
      mapIndexes - a read-only map of available MapIndex objects, keyed by the associated ValueExtractor
      setKeys - the mutable set of keys that remain to be filtered
      step - the step used to record the execution cost
      extractor - an optional ValueExtractor used by the query
      Returns:
      a Filter object (which may be an EntryFilter) that can be used to process the remaining keys, or null if no additional filter processing is necessary
    • trace

      protected static <T> boolean trace(Filter<T> filter, Map.Entry entry, QueryRecord.PartialResult.TraceStep step)
      Record the actual cost of query execution for a given filter.
      Type Parameters:
      T - the type of the input argument to the filter
      Parameters:
      filter - the filter
      entry - the entry to be evaluated
      step - the step used to record the execution cost
      Returns:
      true if the entry passes the filter, false otherwise