Package org.drools.core.reteoo
Class Rete
- java.lang.Object
-
- org.drools.core.common.BaseNode
-
- org.drools.core.reteoo.ObjectSource
-
- org.drools.core.reteoo.Rete
-
- All Implemented Interfaces:
java.io.Serializable
,org.drools.base.common.NetworkNode
,ObjectSink
,Sink
public class Rete extends ObjectSource implements ObjectSink
The Rete-OO network. The Rete class is the rootObject
. All objects are asserted into the Rete node where it propagates to all matching ObjectTypeNodes. The first time an instance of a Class type is asserted it does a full iteration of all ObjectTyppeNodes looking for matches, any matches are then cached in a HashMap which is used for future assertions. While Rete extends ObjectSource nad implements ObjectSink it nulls the methods attach(), remove() and updateNewNode() as this is the root node they are no applicable- See Also:
ObjectTypeNode
, Serialized Form
-
-
Field Summary
-
Fields inherited from class org.drools.core.reteoo.ObjectSource
alphaNodeHashingThreshold, alphaNodeRangeIndexThreshold, declaredMask, inferredMask, sink, source
-
Fields inherited from class org.drools.core.common.BaseNode
associations, hashcode, id, memoryId, partitionId, partitionsEnabled
-
-
Constructor Summary
Constructors Constructor Description Rete()
Rete(InternalRuleBase kBase)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObjectSink(ObjectSink objectSink)
Adds theObjectSink
so that it may receiveObjects
propagated from thisObjectSource
.void
assertObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
This is the entry point into the network for all asserted Facts.void
byPassModifyToBetaNode(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
org.drools.core.util.bitmask.BitMask
calculateDeclaredMask(org.drools.base.base.ObjectType modifiedType, java.util.List<java.lang.String> settableProperties)
void
doAttach(BuildContext context)
protected boolean
doRemove(RuleRemovalContext context, ReteooBuilder builder)
Removes the node from the network.boolean
equals(java.lang.Object object)
EntryPointNode
getEntryPointNode(org.drools.base.rule.EntryPointId entryPoint)
java.util.Map<org.drools.base.rule.EntryPointId,EntryPointNode>
getEntryPointNodes()
java.util.List<ObjectTypeNode>
getObjectTypeNodes()
java.util.Map<org.drools.base.base.ObjectType,ObjectTypeNode>
getObjectTypeNodes(org.drools.base.rule.EntryPointId entryPoint)
InternalRuleBase
getRuleBase()
short
getType()
void
modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
void
networkUpdated(UpdateContext updateContext)
A method that is called for all nodes whose network below them changed, after the change is complete, providing them with an opportunity for state updatevoid
removeObjectSink(ObjectSink objectSink)
Removes theObjectSink
void
retractObject(InternalFactHandle handle, PropagationContext context, ReteEvaluator reteEvaluator)
Retract a fact object from thisRuleBase
and the specifiedWorkingMemory
.void
updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory wm)
-
Methods inherited from class org.drools.core.reteoo.ObjectSource
getDeclaredMask, getObjectSinkPropagator, getObjectTypeNode, getParentObjectSource, initDeclaredMask, isInUse, resetInferredMask, setObjectSinkPropagator, setParentObjectSource, setPartitionId, setPartitionIdWithSinks, setSourcePartitionId, updateMask
-
Methods inherited from class org.drools.core.common.BaseNode
addAssociatedTerminal, addAssociation, addAssociation, attach, getAssociatedRules, getAssociatedTerminalsSize, getAssociationsSize, getId, getMemoryId, getPartitionId, getSinks, hasAssociatedTerminal, hashCode, initMemoryId, isAssociatedWith, isStreamMode, remove, removeAssociatedTerminal, removeAssociation, setId, setPartitionsEnabled, setStreamMode, toString
-
-
-
-
Constructor Detail
-
Rete
public Rete()
-
Rete
public Rete(InternalRuleBase kBase)
-
-
Method Detail
-
getType
public short getType()
- Specified by:
getType
in interfaceorg.drools.base.common.NetworkNode
-
assertObject
public void assertObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
This is the entry point into the network for all asserted Facts. Iterates a cache of matchingObjectTypdeNode
s asserting the Fact. If the cache does not exist it first iteraes and builds the cache.- Specified by:
assertObject
in interfaceObjectSink
- Parameters:
factHandle
- The FactHandle of the fact to assertcontext
- ThePropagationContext
of theWorkingMemory
actionreteEvaluator
- The working memory session.
-
retractObject
public void retractObject(InternalFactHandle handle, PropagationContext context, ReteEvaluator reteEvaluator)
Retract a fact object from thisRuleBase
and the specifiedWorkingMemory
.- Parameters:
handle
- The handle of the fact to retract.reteEvaluator
- The working memory session.
-
modifyObject
public void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
- Specified by:
modifyObject
in interfaceObjectSink
-
addObjectSink
public void addObjectSink(ObjectSink objectSink)
Adds theObjectSink
so that it may receiveObjects
propagated from thisObjectSource
.- Overrides:
addObjectSink
in classObjectSource
- Parameters:
objectSink
- TheObjectSink
to receive propagatedObjects
. Rete only acceptsObjectTypeNode
s as parameters to this method, though.
-
removeObjectSink
public void removeObjectSink(ObjectSink objectSink)
Description copied from class:ObjectSource
Removes theObjectSink
- Overrides:
removeObjectSink
in classObjectSource
- Parameters:
objectSink
- TheObjectSink
to remove
-
doAttach
public void doAttach(BuildContext context)
-
networkUpdated
public void networkUpdated(UpdateContext updateContext)
Description copied from class:BaseNode
A method that is called for all nodes whose network below them changed, after the change is complete, providing them with an opportunity for state update- Overrides:
networkUpdated
in classObjectSource
-
doRemove
protected boolean doRemove(RuleRemovalContext context, ReteooBuilder builder)
Description copied from class:BaseNode
Removes the node from the network. Usually from the parentObjectSource
orTupleSource
- Overrides:
doRemove
in classObjectSource
-
getEntryPointNode
public EntryPointNode getEntryPointNode(org.drools.base.rule.EntryPointId entryPoint)
-
getObjectTypeNodes
public java.util.List<ObjectTypeNode> getObjectTypeNodes()
-
getObjectTypeNodes
public java.util.Map<org.drools.base.base.ObjectType,ObjectTypeNode> getObjectTypeNodes(org.drools.base.rule.EntryPointId entryPoint)
-
getRuleBase
public InternalRuleBase getRuleBase()
- Overrides:
getRuleBase
in classObjectSource
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
updateSink
public void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory wm)
- Specified by:
updateSink
in classObjectSource
-
getEntryPointNodes
public java.util.Map<org.drools.base.rule.EntryPointId,EntryPointNode> getEntryPointNodes()
-
byPassModifyToBetaNode
public void byPassModifyToBetaNode(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
- Specified by:
byPassModifyToBetaNode
in interfaceObjectSink
-
calculateDeclaredMask
public org.drools.core.util.bitmask.BitMask calculateDeclaredMask(org.drools.base.base.ObjectType modifiedType, java.util.List<java.lang.String> settableProperties)
- Specified by:
calculateDeclaredMask
in classObjectSource
-
-