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:
MemoryFactory<ObjectTypeNode.ObjectTypeNodeMemory>,NetworkNode,ObjectSink,Sink
- Direct Known Subclasses:
ReteObjectTypeNode
public class ObjectTypeNode extends ObjectSource implements ObjectSink, MemoryFactory<ObjectTypeNode.ObjectTypeNodeMemory>
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classObjectTypeNode.ExpireJobstatic classObjectTypeNode.ExpireJobContextstatic classObjectTypeNode.Idstatic classObjectTypeNode.InitialFactObjectTypeNodeMemorystatic classObjectTypeNode.ObjectTypeNodeMemory
-
Field Summary
Fields Modifier and Type Field Description static ObjectTypeNode.IdDEFAULT_IDprotected org.drools.core.reteoo.ObjectTypeNode.IdGeneratoridGeneratorprotected 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
associatedTerminals, associations, hashcode, id, memoryId, partitionId, partitionsEnabled, posInSegment
-
-
Constructor Summary
Constructors Constructor Description ObjectTypeNode()ObjectTypeNode(int id, EntryPointNode source, 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)BitMaskcalculateDeclaredMask(ObjectType modifiedType, List<String> settableProperties)protected voidcheckDirty()ObjectTypeNode.ObjectTypeNodeMemorycreateMemory(RuleBaseConfiguration config, ReteEvaluator reteEvaluator)Creates memory for the node using PrimitiveLongMap as its optimised for storage and reteivals of Longs.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(Object object)static voidexpireLeftTuple(LeftTuple leftTuple)static voidexpireRightTuple(RightTuple rightTuple)EntryPointIdgetEntryPoint()longgetExpirationOffset()ObjectTypegetObjectType()Retrieve the semanticObjectTypedifferentiator.intgetOtnIdCounter()RuleBasePartitionIdgetPartitionId()Returns the partition ID for which this node belongs toshortgetType()booleanisAssignableFrom(ObjectType objectType)booleanisObjectMemoryEnabled()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)voidsetObjectMemoryEnabled(boolean objectMemoryEnabled)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
addAssociation, addAssociation, attach, getAssociatedRules, getAssociatedTerminals, getAssociationsSize, getId, getMemoryId, getPosInSegment, getSinks, hashCode, initMemoryId, isAssociatedWith, isStreamMode, removeAssociation, setId, setPartitionsEnabled, setPosInSegment, setStreamMode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.drools.core.common.MemoryFactory
getMemoryId
-
Methods inherited from interface org.drools.core.common.NetworkNode
getAssociatedRules, getAssociatedTerminals, getId, getPosInSegment, getSinks, isAssociatedWith
-
-
-
-
Field Detail
-
objectType
protected 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, 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()
-
getType
public short getType()
- Specified by:
getTypein interfaceNetworkNode
-
getObjectType
public ObjectType getObjectType()
Retrieve the semanticObjectTypedifferentiator.- Returns:
- The semantic
ObjectTypedifferentiator.
-
getPartitionId
public RuleBasePartitionId getPartitionId()
Returns the partition ID for which this node belongs to- Specified by:
getPartitionIdin interfaceNetworkNode- Overrides:
getPartitionIdin classBaseNode
-
calculateDeclaredMask
public BitMask calculateDeclaredMask(ObjectType modifiedType, List<String> settableProperties)
- Specified by:
calculateDeclaredMaskin classObjectSource
-
isAssignableFrom
public boolean isAssignableFrom(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
-
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
-
createMemory
public ObjectTypeNode.ObjectTypeNodeMemory createMemory(RuleBaseConfiguration config, ReteEvaluator reteEvaluator)
Creates memory for the node using PrimitiveLongMap as its optimised for storage and reteivals of Longs. However PrimitiveLongMap is not ideal for spase data. So it should be monitored incase its more optimal to switch back to a standard HashMap.- Specified by:
createMemoryin interfaceMemoryFactory<ObjectTypeNode.ObjectTypeNodeMemory>
-
isObjectMemoryEnabled
public boolean isObjectMemoryEnabled()
-
setObjectMemoryEnabled
public void setObjectMemoryEnabled(boolean objectMemoryEnabled)
-
getEntryPoint
public 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
-
-