Class ConstraintIndexer
- java.lang.Object
-
- jadex.rules.rulesystem.rete.constraints.ConstraintIndexer
-
public class ConstraintIndexer extends java.lang.ObjectThe constraint indexer has the purpose to index equal constraints via the beta memory of the node, i.e. for each side a memory is kept that allows direct fetching of all matching values via the "indexed" attribute.
-
-
Field Summary
Fields Modifier and Type Field Description protected IValueExtractorextractor1The value extractor 1 (left).protected IValueExtractorextractor2The value extractor 2 (right).
-
Constructor Summary
Constructors Constructor Description ConstraintIndexer(IValueExtractor extractor1, IValueExtractor extractor2)Create a new indexed constraint evaluator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObject(java.lang.Object right, IOAVState state, BetaMemory bmem)Add an object to the memory.voidaddTuple(Tuple left, IOAVState state, BetaMemory bmem)Add a tuple to the memory.booleanequals(java.lang.Object obj)Test if the evaluator equals an object.java.util.SetfindObjects(Tuple left, BetaMemory bmem)Find all objects for a tuple.java.util.SetfindTuples(java.lang.Object right, BetaMemory bmem)Find all tuples for an object.AttributeSetgetIndirectAttributes()Get the set of indirect attribute types.AttributeSetgetRelevantAttributes()Get the set of relevant attribute types.inthashCode()Get the hash code.booleanisAffected(int tupleindex, OAVAttributeType attr)Test if a constraint evaluator is affected from a change of a certain attribute.booleanisLeftIndex(int tupleindex, OAVAttributeType type)Test if the indexer uses the given index and attribute type for left side indexing.booleanisRightIndex(OAVAttributeType type)Test if the indexer uses the given attribute type for right side indexing.voidremoveObject(java.lang.Object right, BetaMemory bmem)Remove an object from the memory.voidremoveTuple(Tuple left, BetaMemory bmem)Remove a tuple from the memory.java.lang.StringtoString()Create a string representation.
-
-
-
Field Detail
-
extractor1
protected IValueExtractor extractor1
The value extractor 1 (left).
-
extractor2
protected IValueExtractor extractor2
The value extractor 2 (right).
-
-
Constructor Detail
-
ConstraintIndexer
public ConstraintIndexer(IValueExtractor extractor1, IValueExtractor extractor2)
Create a new indexed constraint evaluator.
-
-
Method Detail
-
findObjects
public java.util.Set findObjects(Tuple left, BetaMemory bmem)
Find all objects for a tuple.- Parameters:
left- The tuple.bmem- The beta memory.- Returns:
- The result collection.
-
findTuples
public java.util.Set findTuples(java.lang.Object right, BetaMemory bmem)Find all tuples for an object.- Parameters:
right- The object.bmem- The beta memory.- Returns:
- The result collection.
-
addObject
public void addObject(java.lang.Object right, IOAVState state, BetaMemory bmem)Add an object to the memory.- Parameters:
right- The object.state- The state.bmem- The beta memory.
-
addTuple
public void addTuple(Tuple left, IOAVState state, BetaMemory bmem)
Add a tuple to the memory.- Parameters:
left- The tuple.state- The state.bmem- The beta memory.
-
removeObject
public void removeObject(java.lang.Object right, BetaMemory bmem)Remove an object from the memory.- Parameters:
right- The object.bmem- The beta memory.
-
removeTuple
public void removeTuple(Tuple left, BetaMemory bmem)
Remove a tuple from the memory.- Parameters:
left- The tuple.bmem- The beta memory.
-
isRightIndex
public boolean isRightIndex(OAVAttributeType type)
Test if the indexer uses the given attribute type for right side indexing.- Returns:
- True, if type is used for indexing.
-
isLeftIndex
public boolean isLeftIndex(int tupleindex, OAVAttributeType type)Test if the indexer uses the given index and attribute type for left side indexing.- Returns:
- True, if combination is used for indexing.
-
isAffected
public boolean isAffected(int tupleindex, OAVAttributeType attr)Test if a constraint evaluator is affected from a change of a certain attribute.- Parameters:
tupleindex- The tuple index.attr- The attribute.- Returns:
- True, if affected.
-
getRelevantAttributes
public AttributeSet getRelevantAttributes()
Get the set of relevant attribute types.
-
getIndirectAttributes
public AttributeSet getIndirectAttributes()
Get the set of indirect attribute types. I.e. attributes of objects, which are not part of an object conditions (e.g. for chained extractors)- Returns:
- The relevant attribute types.
-
toString
public java.lang.String toString()
Create a string representation.- Overrides:
toStringin classjava.lang.Object- Returns:
- The string representation.
-
equals
public boolean equals(java.lang.Object obj)
Test if the evaluator equals an object.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Get the hash code.- Overrides:
hashCodein classjava.lang.Object
-
-