Package org.drools.core.reteoo
Class ObjectTypeNode
- java.lang.Object
-
- org.drools.core.common.BaseNode
-
- org.drools.core.reteoo.ObjectSource
-
- org.drools.core.reteoo.ObjectTypeNode
-
- All Implemented Interfaces:
java.io.Serializable,org.drools.base.common.NetworkNode,ObjectSink,Sink
- Direct Known Subclasses:
ReteObjectTypeNode
public class ObjectTypeNode extends ObjectSource implements ObjectSink
ObjectTypeNodesare responsible for filtering and propagating the matching fact assertions propagated from theRetenode usingObjectTypeinterface. The assert and retract methods do not attempt to filter as this is the role of theRetenode which builds up a cache of matchingObjectTypdeNodess for each asserted object, using thematches(Object object)method. Incorrect propagation in these methods is not checked and will result inClassCastExpcectionslater on in the network. FiltersObjectscoming from theReteusing aObjectTypesemantic module.- See Also:
Rete, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classObjectTypeNode.ExpireJobstatic classObjectTypeNode.ExpireJobContextstatic classObjectTypeNode.Id
-
Field Summary
Fields Modifier and Type Field Description static ObjectTypeNode.IdDEFAULT_IDprotected org.drools.core.reteoo.ObjectTypeNode.IdGeneratoridGeneratorprotected org.drools.base.base.ObjectTypeobjectTypeTheObjectTypesemantic module.-
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
-
-
Constructor Summary
Constructors Constructor Description ObjectTypeNode()ObjectTypeNode(int id, EntryPointNode source, org.drools.base.base.ObjectType objectType, BuildContext context)Construct given a semanticObjectTypeand the provided unique id.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertInitialFact(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)voidassertObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)Propagate theFactHandleimplthrough theRetenetwork.voidbyPassModifyToBetaNode(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)org.drools.util.bitmask.BitMaskcalculateDeclaredMask(org.drools.base.base.ObjectType modifiedType, java.util.List<java.lang.String> settableProperties)protected voidcheckDirty()voiddoAttach(BuildContext context)Rete needs to know that this ObjectTypeNode has been addedprotected booleandoRemove(RuleRemovalContext context, ReteooBuilder builder)OTN needs to override remove to avoid releasing the node ID, since OTN are never removed from the rulebase in the current implementationstatic voiddoRetractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)booleanequals(java.lang.Object object)static voidexpireLeftTuple(LeftTuple leftTuple)static voidexpireRightTuple(RightTuple rightTuple)org.drools.base.rule.EntryPointIdgetEntryPoint()longgetExpirationOffset()java.util.Iterator<InternalFactHandle>getFactHandlesIterator(InternalWorkingMemory workingMemory)org.drools.base.base.ObjectTypegetObjectType()Retrieve the semanticObjectTypedifferentiator.intgetOtnIdCounter()org.drools.base.common.RuleBasePartitionIdgetPartitionId()Returns the partition ID for which this node belongs toshortgetType()booleanisAssignableFrom(org.drools.base.base.ObjectType objectType)voidmergeExpirationOffset(ObjectTypeNode other)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 updateObjectTypeNode.IdnextOtnId()voidpropagateAssert(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)booleanremove(RuleRemovalContext context, ReteooBuilder builder)OTN needs to override remove to avoid releasing the node ID, since OTN are never removed from the rulebase in the current implementationprotected voidresetIdGenerator()static voidretractLeftTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)static voidretractLeftTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)voidretractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)Retract theFactHandleimplfrom theRetenetwork.voidretractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)static voidretractRightTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)static voidretractRightTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)voidsetExpirationOffset(long expirationOffset)voidsetupParallelExecution(InternalRuleBase kbase)java.lang.StringtoString()voidupdateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory)protected static voidupdateTupleSinkId(ObjectTypeNode otn, ObjectSource source)-
Methods inherited from class org.drools.core.reteoo.ObjectSource
addObjectSink, getDeclaredMask, getObjectSinkPropagator, getObjectTypeNode, getParentObjectSource, getRuleBase, initDeclaredMask, isInUse, removeObjectSink, 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, getSinks, hasAssociatedTerminal, hashCode, initMemoryId, isAssociatedWith, isStreamMode, removeAssociatedTerminal, removeAssociation, setId, setStreamMode
-
-
-
-
Field Detail
-
objectType
protected org.drools.base.base.ObjectType objectType
TheObjectTypesemantic module.
-
idGenerator
protected transient org.drools.core.reteoo.ObjectTypeNode.IdGenerator idGenerator
-
DEFAULT_ID
public static final ObjectTypeNode.Id DEFAULT_ID
-
-
Constructor Detail
-
ObjectTypeNode
public ObjectTypeNode()
-
ObjectTypeNode
public ObjectTypeNode(int id, EntryPointNode source, org.drools.base.base.ObjectType objectType, BuildContext context)Construct given a semanticObjectTypeand the provided unique id. AllObjectTypdeNodehave node memory.- Parameters:
id- The unique id for the node.objectType- The semantic object-type differentiator.
-
-
Method Detail
-
getOtnIdCounter
public int getOtnIdCounter()
-
setupParallelExecution
public void setupParallelExecution(InternalRuleBase kbase)
-
getType
public short getType()
- Specified by:
getTypein interfaceorg.drools.base.common.NetworkNode
-
getObjectType
public org.drools.base.base.ObjectType getObjectType()
Retrieve the semanticObjectTypedifferentiator.- Returns:
- The semantic
ObjectTypedifferentiator.
-
getPartitionId
public org.drools.base.common.RuleBasePartitionId getPartitionId()
Returns the partition ID for which this node belongs to- Specified by:
getPartitionIdin interfaceorg.drools.base.common.NetworkNode- Overrides:
getPartitionIdin classBaseNode
-
calculateDeclaredMask
public org.drools.util.bitmask.BitMask calculateDeclaredMask(org.drools.base.base.ObjectType modifiedType, java.util.List<java.lang.String> settableProperties)- Specified by:
calculateDeclaredMaskin classObjectSource
-
isAssignableFrom
public boolean isAssignableFrom(org.drools.base.base.ObjectType objectType)
-
assertInitialFact
public void assertInitialFact(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
-
checkDirty
protected void checkDirty()
-
assertObject
public void assertObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
Propagate theFactHandleimplthrough theRetenetwork. AllFactHandleImplshould be remembered in the node memory, so that later runtime rule attachmnents can have the matched facts propagated to them.- Specified by:
assertObjectin interfaceObjectSink- Parameters:
factHandle- The fact handle.context- The propagation context.reteEvaluator- The working memory session.
-
propagateAssert
public void propagateAssert(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
-
retractObject
public void retractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
Retract theFactHandleimplfrom theRetenetwork. Also remove theFactHandleImplfrom the node memory.- Parameters:
factHandle- The fact handle.context- The propagation context.reteEvaluator- The working memory session.
-
retractObject
public void retractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)
-
doRetractObject
public static void doRetractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
-
expireLeftTuple
public static void expireLeftTuple(LeftTuple leftTuple)
-
expireRightTuple
public static void expireRightTuple(RightTuple rightTuple)
-
retractLeftTuples
public static void retractLeftTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
-
retractLeftTuples
public static void retractLeftTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)
-
retractRightTuples
public static void retractRightTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
-
retractRightTuples
public static void retractRightTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)
-
resetIdGenerator
protected void resetIdGenerator()
-
modifyObject
public void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
- Specified by:
modifyObjectin interfaceObjectSink
-
updateSink
public void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory)
- Specified by:
updateSinkin classObjectSource
-
getFactHandlesIterator
public java.util.Iterator<InternalFactHandle> getFactHandlesIterator(InternalWorkingMemory workingMemory)
-
doAttach
public void doAttach(BuildContext context)
Rete needs to know that this ObjectTypeNode has been added
-
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
-
updateTupleSinkId
protected static void updateTupleSinkId(ObjectTypeNode otn, ObjectSource source)
-
nextOtnId
public ObjectTypeNode.Id nextOtnId()
-
remove
public boolean remove(RuleRemovalContext context, ReteooBuilder builder)
OTN needs to override remove to avoid releasing the node ID, since OTN are never removed from the rulebase in the current implementation
-
doRemove
protected boolean doRemove(RuleRemovalContext context, ReteooBuilder builder)
OTN needs to override remove to avoid releasing the node ID, since OTN are never removed from the rulebase in the current implementation- Overrides:
doRemovein classObjectSource
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
getEntryPoint
public org.drools.base.rule.EntryPointId getEntryPoint()
- Returns:
- the entryPoint
-
getExpirationOffset
public long getExpirationOffset()
-
setExpirationOffset
public void setExpirationOffset(long expirationOffset)
-
mergeExpirationOffset
public void mergeExpirationOffset(ObjectTypeNode other)
-
byPassModifyToBetaNode
public void byPassModifyToBetaNode(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
- Specified by:
byPassModifyToBetaNodein interfaceObjectSink
-
-