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:
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
-
-
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObjectSink(ObjectSink objectSink)Adds theObjectSinkso that it may receiveObjectspropagated from thisObjectSource.voidassertObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)This is the entry point into the network for all asserted Facts.voidbyPassModifyToBetaNode(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)BitMaskcalculateDeclaredMask(Class modifiedClass, List<String> settableProperties)voiddoAttach(BuildContext context)protected booleandoRemove(RuleRemovalContext context, ReteooBuilder builder)Removes the node from the network.booleanequals(Object object)EntryPointNodegetEntryPointNode(EntryPointId entryPoint)Map<EntryPointId,EntryPointNode>getEntryPointNodes()List<ObjectTypeNode>getObjectTypeNodes()Map<ObjectType,ObjectTypeNode>getObjectTypeNodes(EntryPointId entryPoint)RuleBasegetRuleBase()shortgetType()voidmodifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)voidnetworkUpdated(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 updatevoidremoveObjectSink(ObjectSink objectSink)Removes theObjectSinkvoidretractObject(InternalFactHandle handle, PropagationContext context, ReteEvaluator reteEvaluator)Retract a fact object from thisRuleBaseand the specifiedWorkingMemory.voidupdateSink(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
addAssociation, addAssociation, attach, getAssociatedRules, getAssociatedRuleSize, getAssociationsSize, getAssociationsSize, getId, getMemoryId, getPartitionId, getSinks, hashCode, initMemoryId, isAssociatedWith, isStreamMode, remove, removeAssociation, setId, setPartitionsEnabled, setStreamMode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.drools.core.common.NetworkNode
getAssociatedRules, getAssociatedRuleSize, getAssociationsSize, getAssociationsSize, getId, getPartitionId, isAssociatedWith
-
-
-
-
Constructor Detail
-
Rete
public Rete()
-
Rete
public Rete(RuleBase kBase)
-
-
Method Detail
-
getType
public short getType()
- Specified by:
getTypein interfaceNetworkNode
-
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 matchingObjectTypdeNodes asserting the Fact. If the cache does not exist it first iteraes and builds the cache.- Specified by:
assertObjectin interfaceObjectSink- Parameters:
factHandle- The FactHandle of the fact to assertcontext- ThePropagationContextof theWorkingMemoryactionreteEvaluator- The working memory session.
-
retractObject
public void retractObject(InternalFactHandle handle, PropagationContext context, ReteEvaluator reteEvaluator)
Retract a fact object from thisRuleBaseand 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:
modifyObjectin interfaceObjectSink
-
addObjectSink
public void addObjectSink(ObjectSink objectSink)
Adds theObjectSinkso that it may receiveObjectspropagated from thisObjectSource.- Overrides:
addObjectSinkin classObjectSource- Parameters:
objectSink- TheObjectSinkto receive propagatedObjects. Rete only acceptsObjectTypeNodes as parameters to this method, though.
-
removeObjectSink
public void removeObjectSink(ObjectSink objectSink)
Description copied from class:ObjectSourceRemoves theObjectSink- Overrides:
removeObjectSinkin classObjectSource- Parameters:
objectSink- TheObjectSinkto remove
-
doAttach
public void doAttach(BuildContext context)
-
networkUpdated
public void networkUpdated(UpdateContext updateContext)
Description copied from class:BaseNodeA 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:
networkUpdatedin classObjectSource
-
doRemove
protected boolean doRemove(RuleRemovalContext context, ReteooBuilder builder)
Description copied from class:BaseNodeRemoves the node from the network. Usually from the parentObjectSourceorTupleSource- Overrides:
doRemovein classObjectSource
-
getEntryPointNode
public EntryPointNode getEntryPointNode(EntryPointId entryPoint)
-
getObjectTypeNodes
public List<ObjectTypeNode> getObjectTypeNodes()
-
getObjectTypeNodes
public Map<ObjectType,ObjectTypeNode> getObjectTypeNodes(EntryPointId entryPoint)
-
getRuleBase
public RuleBase getRuleBase()
- Overrides:
getRuleBasein classObjectSource
-
updateSink
public void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory wm)
- Specified by:
updateSinkin classObjectSource
-
getEntryPointNodes
public Map<EntryPointId,EntryPointNode> getEntryPointNodes()
-
byPassModifyToBetaNode
public void byPassModifyToBetaNode(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
- Specified by:
byPassModifyToBetaNodein interfaceObjectSink
-
calculateDeclaredMask
public BitMask calculateDeclaredMask(Class modifiedClass, List<String> settableProperties)
- Specified by:
calculateDeclaredMaskin classObjectSource
-
-