public class RetePatternMatcher extends TransformerNode implements IQueryResultProvider
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
connected |
protected IQueryRuntimeContext |
context |
protected ReteEngine |
engine |
protected java.util.Map<java.lang.String,java.lang.Integer> |
posMapping |
protected ProductionNode |
productionNode |
protected RecipeTraceInfo |
productionNodeTrace |
protected java.util.Map<java.lang.Object,Receiver> |
taggedChildren |
mailbox, parentchildMailboxes, childrennodeId, reteContainer, tag, traceInfos| Constructor and Description |
|---|
RetePatternMatcher(ReteEngine engine,
RecipeTraceInfo productionNodeTrace) |
| Modifier and Type | Method and Description |
|---|---|
void |
addUpdateListener(IUpdateable listener,
java.lang.Object listenerTag,
boolean fireNow)
Internal method that registers low-level callbacks for match appearance and disappearance.
|
void |
connect(Receiver receiver,
boolean synchronize)
Connects a new external receiver that will receive update notifications from now on.
|
void |
connect(Receiver receiver,
java.lang.Object tag,
boolean synchronize)
Connects a new external receiver that will receive update notifications from now on.
|
int |
count(java.lang.Object[] inputMapping,
boolean[] fixed)
Counts the number of occurrences of the pattern that match inputMapping on positions where fixed is true.
|
int |
count(TupleMask mask,
ITuple inputSignature)
Counts the number of occurrences of the pattern that match inputMapping on positions where fixed is true.
|
int |
countMatches(java.lang.Object[] parameters)
Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
|
int |
countMatches(TupleMask parameterSeedMask,
ITuple parameters)
Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
|
void |
disconnect(Receiver receiver)
Disconnects a child node.
|
boolean |
disconnectByTag(java.lang.Object tag)
Disconnects the child node that was connected by specifying the given tag.
|
java.util.Optional<java.lang.Long> |
estimateCardinality(TupleMask groupMask,
Accuracy requiredAccuracy)
Gives an estimate of the number of different groups the matches are projected into by the given mask
(e.g.
|
java.util.stream.Stream<Tuple> |
getAllMatches(java.lang.Object[] parameters)
Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
|
java.util.stream.Stream<Tuple> |
getAllMatches(TupleMask parameterSeedMask,
ITuple parameters)
Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
|
java.util.Optional<Tuple> |
getOneArbitraryMatch(java.lang.Object[] parameters)
Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
|
java.util.Optional<Tuple> |
getOneArbitraryMatch(TupleMask parameterSeedMask,
ITuple parameters)
Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
|
ProductionNode |
getProductionNode() |
IQueryBackend |
getQueryBackend()
The underlying query evaluator backend.
|
boolean |
hasMatch(java.lang.Object[] parameters)
Decides whether there are any matches of the pattern that conform to the given fixed values of some parameters.
|
boolean |
hasMatch(TupleMask parameterSeedMask,
ITuple parameters)
Decides whether there are any matches of the pattern that conform to the given fixed values of some parameters.
|
java.util.stream.Stream<Tuple> |
matchAll(java.lang.Object[] inputMapping,
boolean[] fixed) |
java.util.stream.Stream<Tuple> |
matchAll(TupleMask mask,
ITuple inputSignature) |
java.util.Optional<Tuple> |
matchOne(java.lang.Object[] inputMapping,
boolean[] fixed) |
java.util.Optional<Tuple> |
matchOne(TupleMask mask,
ITuple inputSignature) |
Tuple |
matchOneRandomly(java.lang.Object[] inputMapping,
boolean[] fixed) |
int |
projectionSize(TupleMask groupMask)
Counts the number of distinct tuples attainable from the match set by projecting match tuples according to the given mask.
|
void |
removeUpdateListener(java.lang.Object listenerTag)
Removes an existing listener previously registered with the given tag.
|
protected Tuple |
transform(Tuple input) |
pullInto, pullIntoWithTimeline, updateappendParent, assignTraceInfo, getCommunicationTracker, getMailbox, getParents, instantiateMailbox, propagatePullInto, propagatePullIntoWithTimestamp, removeParentappendChild, constructIndex, getChildMailboxes, getPulledContents, getReceivers, issueError, networkStructureChanged, propagateUpdate, removeChildacceptPropagatedTraceInfo, getContainer, getNodeId, getTag, getTraceInfoPatternsEnumerated, getTraceInfos, setTag, toString, toStringCoreclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitestimateAverageBucketSizeappendChild, constructIndex, getPulledContents, getPulledContents, getReceivers, removeChildbatchUpdateacceptPropagatedTraceInfo, getContainer, getNodeId, getTag, getTraceInfos, setTagprotected ReteEngine engine
protected IQueryRuntimeContext context
protected ProductionNode productionNode
protected RecipeTraceInfo productionNodeTrace
protected java.util.Map<java.lang.String,java.lang.Integer> posMapping
protected java.util.Map<java.lang.Object,Receiver> taggedChildren
protected boolean connected
public RetePatternMatcher(ReteEngine engine, RecipeTraceInfo productionNodeTrace)
productionNode - a production node that matches this pattern without any parameter bindingspublic ProductionNode getProductionNode()
public Tuple matchOneRandomly(java.lang.Object[] inputMapping, boolean[] fixed)
public java.util.stream.Stream<Tuple> matchAll(java.lang.Object[] inputMapping, boolean[] fixed)
public java.util.stream.Stream<Tuple> matchAll(TupleMask mask, ITuple inputSignature)
public java.util.Optional<Tuple> matchOne(java.lang.Object[] inputMapping, boolean[] fixed)
public java.util.Optional<Tuple> matchOne(TupleMask mask, ITuple inputSignature)
public int count(java.lang.Object[] inputMapping,
boolean[] fixed)
public int count(TupleMask mask, ITuple inputSignature)
public int projectionSize(TupleMask groupMask)
public void connect(Receiver receiver, boolean synchronize)
synchronize - if true, the contents of the production node will be inserted into the receiver after the connection
is established.public void connect(Receiver receiver, java.lang.Object tag, boolean synchronize)
tag - an identifier to recognize the child node by.synchronize - if true, the contents of the production node will be inserted into the receiver after the connection
is established.public void disconnect(Receiver receiver)
public boolean disconnectByTag(java.lang.Object tag)
protected Tuple transform(Tuple input)
transform in class TransformerNodepublic boolean hasMatch(java.lang.Object[] parameters)
IQueryResultProviderhasMatch in interface IQueryResultProviderparameters - array where each non-null element binds the corresponding pattern parameter to a fixed value.public boolean hasMatch(TupleMask parameterSeedMask, ITuple parameters)
IQueryResultProviderhasMatch in interface IQueryResultProviderparameterSeedMask - a mask that extracts those parameters of the query (from the entire parameter list) that should be
bound to a fixed valuepublic int countMatches(java.lang.Object[] parameters)
IQueryResultProvidercountMatches in interface IQueryResultProviderparameters - array where each non-null element binds the corresponding pattern parameter to a fixed value.public int countMatches(TupleMask parameterSeedMask, ITuple parameters)
IQueryResultProvidercountMatches in interface IQueryResultProviderparameterSeedMask - a mask that extracts those parameters of the query (from the entire parameter list) that should be
bound to a fixed valuepublic java.util.Optional<java.lang.Long> estimateCardinality(TupleMask groupMask, Accuracy requiredAccuracy)
IQueryResultProvider If there is insufficient information to provide an answer up to the required precision, Optional.empty() may be returned.
In other words, query backends may deny an answer, or do their best to give an estimate without actually determining the match set of the query.
However, caching backends are expected to simply return the indexed (projection) size, initialized on-demand if necessary.
PRE: TupleMask.isNonrepeating() must hold for the group mask.
estimateCardinality in interface IQueryResultProviderpublic java.util.Optional<Tuple> getOneArbitraryMatch(java.lang.Object[] parameters)
IQueryResultProvidergetOneArbitraryMatch in interface IQueryResultProviderparameters - array where each non-null element binds the corresponding pattern parameter to a fixed value.Tuple representation.public java.util.Optional<Tuple> getOneArbitraryMatch(TupleMask parameterSeedMask, ITuple parameters)
IQueryResultProvidergetOneArbitraryMatch in interface IQueryResultProviderparameterSeedMask - a mask that extracts those parameters of the query (from the entire parameter list) that should be
bound to a fixed valueparameters - the tuple of fixed values restricting the match set to be considered, in the same order as given in
parameterSeedMask, so that for each considered match tuple,
projectedParameterSeed.equals(parameterSeedMask.transform(match)) should holdTuple representation.public java.util.stream.Stream<Tuple> getAllMatches(java.lang.Object[] parameters)
IQueryResultProvidergetAllMatches in interface IQueryResultProviderparameters - array where each non-null element binds the corresponding pattern parameter to a fixed value.Tuple representation.public java.util.stream.Stream<Tuple> getAllMatches(TupleMask parameterSeedMask, ITuple parameters)
IQueryResultProvidergetAllMatches in interface IQueryResultProviderparameterSeedMask - a mask that extracts those parameters of the query (from the entire parameter list) that should be
bound to a fixed valueparameters - the tuple of fixed values restricting the match set to be considered, in the same order as given in
parameterSeedMask, so that for each considered match tuple,
projectedParameterSeed.equals(parameterSeedMask.transform(match)) should holdTuple representation.public IQueryBackend getQueryBackend()
IQueryResultProvidergetQueryBackend in interface IQueryResultProviderpublic void addUpdateListener(IUpdateable listener, java.lang.Object listenerTag, boolean fireNow)
IQueryResultProviderCaution: This is a low-level callback that is invoked when the pattern matcher is not necessarily in a consistent state yet. Importantly, no model modification permitted during the callback.
The callback can be unregistered via invoking IQueryResultProvider.removeUpdateListener(Object) with the same tag.
addUpdateListener in interface IQueryResultProviderlistener - the listener that will be notified of each new match that appears or disappears, starting from now.listenerTag - a tag by which to identify the listener for later removal by IQueryResultProvider.removeUpdateListener(Object).fireNow - if true, the insertion update allback will be immediately invoked on all current matches as a one-time effect.public void removeUpdateListener(java.lang.Object listenerTag)
IQueryResultProviderremoveUpdateListener in interface IQueryResultProvider