Class BaseMatcher<TypeMetadata, AttributeMetadata, AttributeId extends Comparable<AttributeId>>

java.lang.Object
org.infinispan.query.objectfilter.impl.BaseMatcher<TypeMetadata, AttributeMetadata, AttributeId>
All Implemented Interfaces:
Matcher
Direct Known Subclasses:
ProtobufMatcher, ReflectionMatcher, RowMatcher

public abstract class BaseMatcher<TypeMetadata, AttributeMetadata, AttributeId extends Comparable<AttributeId>> extends Object implements Matcher
Since:
7.0
Author:
anistor@redhat.com
  • Field Details

    • propertyHelper

      protected final org.infinispan.query.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata> propertyHelper
  • Constructor Details

    • BaseMatcher

      protected BaseMatcher(org.infinispan.query.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata> propertyHelper)
  • Method Details

    • getPropertyHelper

      public org.infinispan.query.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata> getPropertyHelper()
    • match

      public void match(Object userContext, Object eventType, Object instance)
      Executes the registered filters and notifies each one of them whether it was satisfied or not by the given instance.
      Specified by:
      match in interface Matcher
      Parameters:
      userContext - an optional user provided object to be passed to matching subscribers along with the matching instance; can be null
      eventType - on optional event type discriminator that is matched against the even type specified when the filter was registered; can be null
      instance - the object to test against the registered filters; never null
    • matchDelta

      public void matchDelta(Object userContext, Object eventType, Object instanceOld, Object instanceNew, Object joiningEvent, Object updatedEvent, Object leavingEvent)
      Description copied from interface: Matcher
      Test two instances (which are actually before/after snapshots of the same instance) against all the subscribed filters and notify all callbacks registered for instances of the same instance type. The isDelta parameter of the callback will be true.
      Specified by:
      matchDelta in interface Matcher
      Parameters:
      userContext - an optional user provided object to be passed to matching subscribers along with the matching instance; can be null
      eventType - on optional event type discriminator that is matched against the event type specified when the filter was registered; can be null
      instanceOld - the 'before' object to test against the registered filters; never null
      instanceNew - the 'after' object to test against the registered filters; never null
      joiningEvent - the event to generate if the instance joins the matching set
      updatedEvent - the event to generate if a matching instance is updated and continues to the match
      leavingEvent - the event to generate if the instance leaves the matching set
    • getObjectFilter

      public ObjectFilter getObjectFilter(org.infinispan.query.dsl.Query<?> query)
      Specified by:
      getObjectFilter in interface Matcher
    • getObjectFilter

      public ObjectFilter getObjectFilter(String queryString)
      Specified by:
      getObjectFilter in interface Matcher
    • getObjectFilter

      public ObjectFilter getObjectFilter(String queryString, List<org.infinispan.query.objectfilter.impl.aggregation.FieldAccumulator> acc)
      Specified by:
      getObjectFilter in interface Matcher
    • getObjectFilter

      public ObjectFilter getObjectFilter(FilterSubscription filterSubscription)
      Description copied from interface: Matcher
      Obtains an ObjectFilter instance that is capable of testing a single filter condition.
      Specified by:
      getObjectFilter in interface Matcher
      Parameters:
      filterSubscription - a filter subscription previously registered with this Matcher; the newly created ObjectFilter will be based on the same filter condition
      Returns:
      the single-filter
    • registerFilter

      public FilterSubscription registerFilter(org.infinispan.query.dsl.Query<?> query, FilterCallback callback, Object... eventType)
      Specified by:
      registerFilter in interface Matcher
    • registerFilter

      public FilterSubscription registerFilter(org.infinispan.query.dsl.Query<?> query, FilterCallback callback, boolean isDeltaFilter, Object... eventType)
      Specified by:
      registerFilter in interface Matcher
    • registerFilter

      public FilterSubscription registerFilter(String queryString, FilterCallback callback, Object... eventType)
      Specified by:
      registerFilter in interface Matcher
    • registerFilter

      public FilterSubscription registerFilter(String queryString, FilterCallback callback, boolean isDeltaFilter, Object... eventType)
      Specified by:
      registerFilter in interface Matcher
    • registerFilter

      public FilterSubscription registerFilter(String queryString, Map<String,Object> namedParameters, FilterCallback callback, Object... eventType)
      Specified by:
      registerFilter in interface Matcher
    • registerFilter

      public FilterSubscription registerFilter(String queryString, Map<String,Object> namedParameters, FilterCallback callback, boolean isDeltaFilter, Object... eventType)
      Specified by:
      registerFilter in interface Matcher
    • unregisterFilter

      public void unregisterFilter(FilterSubscription filterSubscription)
      Specified by:
      unregisterFilter in interface Matcher
    • startMultiTypeContext

      protected abstract org.infinispan.query.objectfilter.impl.predicateindex.MatcherEvalContext<TypeMetadata, AttributeMetadata, AttributeId> startMultiTypeContext(boolean isDelta, Object userContext, Object eventType, Object instance)
      Creates a new MatcherEvalContext capable of dealing with multiple filters. The context is created only if the given instance is recognized to be of a type that has some filters registered. If there are no filters, null is returned to signal this condition and make the evaluation faster. This method must be called while holding the internal write lock.
      Parameters:
      isDelta - indicates if this is a delta match of not
      userContext - an opaque value, possibly null, the is received from the caller and is to be handed to the FilterCallback in case a match is detected
      eventType - on optional event type discriminator
      instance - the instance to filter; never null
      Returns:
      the MatcherEvalContext or null if no filter was registered for the instance
    • startSingleTypeContext

      protected abstract org.infinispan.query.objectfilter.impl.predicateindex.MatcherEvalContext<TypeMetadata, AttributeMetadata, AttributeId> startSingleTypeContext(Object userContext, Object eventType, Object key, Object instance, Object metadata, MetadataAdapter<TypeMetadata, AttributeMetadata, AttributeId> metadataAdapter)
      Creates a new MatcherEvalContext capable of dealing with a single filter for a single type. The context is created only if the given instance is recognized to be of a type that has some filters registered. If there are no filters, null is returned to signal this condition and make the evaluation faster. This method must be called while holding the internal write lock.
      Parameters:
      userContext - an opaque value, possibly null, the is received from the caller and is to be handed to the FilterCallback in case a match is detected
      instance - the instance to filter; never null
      metadataAdapter - the metadata adapter of expected instance type
      Returns:
      the MatcherEvalContext or null if no filter was registered for the instance
    • createMetadataAdapter

      protected abstract MetadataAdapter<TypeMetadata, AttributeMetadata, AttributeId> createMetadataAdapter(TypeMetadata entityType)
    • getFilterRegistryForType

      protected final FilterRegistry<TypeMetadata, AttributeMetadata, AttributeId> getFilterRegistryForType(boolean isDeltaFilter, TypeMetadata entityType)
    • convert

      protected Object convert(Object instance)
      Decorates a matching instance before it is presented to the caller of the ObjectFilter.filter(Object).
      Parameters:
      instance - never null
      Returns:
      the converted/decorated instance