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 Summary
FieldsModifier and TypeFieldDescriptionprotected final org.infinispan.query.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseMatcher(org.infinispan.query.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata> propertyHelper) -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectDecorates a matching instance before it is presented to the caller of theObjectFilter.filter(Object).protected abstract MetadataAdapter<TypeMetadata, AttributeMetadata, AttributeId> createMetadataAdapter(TypeMetadata entityType) protected final FilterRegistry<TypeMetadata, AttributeMetadata, AttributeId> getFilterRegistryForType(boolean isDeltaFilter, TypeMetadata entityType) getObjectFilter(String queryString) getObjectFilter(String queryString, List<org.infinispan.query.objectfilter.impl.aggregation.FieldAccumulator> acc) getObjectFilter(org.infinispan.query.dsl.Query<?> query) getObjectFilter(FilterSubscription filterSubscription) Obtains an ObjectFilter instance that is capable of testing a single filter condition.org.infinispan.query.objectfilter.impl.syntax.parser.ObjectPropertyHelper<TypeMetadata> voidExecutes the registered filters and notifies each one of them whether it was satisfied or not by the given instance.voidmatchDelta(Object userContext, Object eventType, Object instanceOld, Object instanceNew, Object joiningEvent, Object updatedEvent, Object leavingEvent) 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.registerFilter(String queryString, Map<String, Object> namedParameters, FilterCallback callback, boolean isDeltaFilter, Object... eventType) registerFilter(String queryString, Map<String, Object> namedParameters, FilterCallback callback, Object... eventType) registerFilter(String queryString, FilterCallback callback, boolean isDeltaFilter, Object... eventType) registerFilter(String queryString, FilterCallback callback, Object... eventType) registerFilter(org.infinispan.query.dsl.Query<?> query, FilterCallback callback, boolean isDeltaFilter, Object... eventType) registerFilter(org.infinispan.query.dsl.Query<?> query, FilterCallback callback, Object... eventType) protected abstract org.infinispan.query.objectfilter.impl.predicateindex.MatcherEvalContext<TypeMetadata, AttributeMetadata, AttributeId> startMultiTypeContext(boolean isDelta, Object userContext, Object eventType, Object instance) Creates a newMatcherEvalContextcapable of dealing with multiple filters.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 newMatcherEvalContextcapable of dealing with a single filter for a single type.voidunregisterFilter(FilterSubscription filterSubscription)
-
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
Executes the registered filters and notifies each one of them whether it was satisfied or not by the given instance.- Specified by:
matchin interfaceMatcher- Parameters:
userContext- an optional user provided object to be passed to matching subscribers along with the matching instance; can benulleventType- on optional event type discriminator that is matched against the even type specified when the filter was registered; can benullinstance- the object to test against the registered filters; nevernull
-
matchDelta
public void matchDelta(Object userContext, Object eventType, Object instanceOld, Object instanceNew, Object joiningEvent, Object updatedEvent, Object leavingEvent) Description copied from interface:MatcherTest 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. TheisDeltaparameter of the callback will betrue.- Specified by:
matchDeltain interfaceMatcher- Parameters:
userContext- an optional user provided object to be passed to matching subscribers along with the matching instance; can benulleventType- on optional event type discriminator that is matched against the event type specified when the filter was registered; can benullinstanceOld- the 'before' object to test against the registered filters; nevernullinstanceNew- the 'after' object to test against the registered filters; nevernulljoiningEvent- the event to generate if the instance joins the matching setupdatedEvent- the event to generate if a matching instance is updated and continues to the matchleavingEvent- the event to generate if the instance leaves the matching set
-
getObjectFilter
- Specified by:
getObjectFilterin interfaceMatcher
-
getObjectFilter
- Specified by:
getObjectFilterin interfaceMatcher
-
getObjectFilter
public ObjectFilter getObjectFilter(String queryString, List<org.infinispan.query.objectfilter.impl.aggregation.FieldAccumulator> acc) - Specified by:
getObjectFilterin interfaceMatcher
-
getObjectFilter
Description copied from interface:MatcherObtains an ObjectFilter instance that is capable of testing a single filter condition.- Specified by:
getObjectFilterin interfaceMatcher- 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:
registerFilterin interfaceMatcher
-
registerFilter
public FilterSubscription registerFilter(org.infinispan.query.dsl.Query<?> query, FilterCallback callback, boolean isDeltaFilter, Object... eventType) - Specified by:
registerFilterin interfaceMatcher
-
registerFilter
public FilterSubscription registerFilter(String queryString, FilterCallback callback, Object... eventType) - Specified by:
registerFilterin interfaceMatcher
-
registerFilter
public FilterSubscription registerFilter(String queryString, FilterCallback callback, boolean isDeltaFilter, Object... eventType) - Specified by:
registerFilterin interfaceMatcher
-
registerFilter
public FilterSubscription registerFilter(String queryString, Map<String, Object> namedParameters, FilterCallback callback, Object... eventType) - Specified by:
registerFilterin interfaceMatcher
-
registerFilter
public FilterSubscription registerFilter(String queryString, Map<String, Object> namedParameters, FilterCallback callback, boolean isDeltaFilter, Object... eventType) - Specified by:
registerFilterin interfaceMatcher
-
unregisterFilter
- Specified by:
unregisterFilterin interfaceMatcher
-
startMultiTypeContext
protected abstract org.infinispan.query.objectfilter.impl.predicateindex.MatcherEvalContext<TypeMetadata, AttributeMetadata, AttributeId> startMultiTypeContext(boolean isDelta, Object userContext, Object eventType, Object instance) Creates a newMatcherEvalContextcapable 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,nullis 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 notuserContext- an opaque value, possibly null, the is received from the caller and is to be handed to theFilterCallbackin case a match is detectedeventType- on optional event type discriminatorinstance- the instance to filter; nevernull- Returns:
- the MatcherEvalContext or
nullif 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 newMatcherEvalContextcapable 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,nullis 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 theFilterCallbackin case a match is detectedinstance- the instance to filter; nevernullmetadataAdapter- the metadata adapter of expected instance type- Returns:
- the MatcherEvalContext or
nullif 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
Decorates a matching instance before it is presented to the caller of theObjectFilter.filter(Object).- Parameters:
instance- never null- Returns:
- the converted/decorated instance
-