Class ConstraintIndexer
- java.lang.Object
-
- jadex.rules.rulesystem.rete.constraints.ConstraintIndexer
-
public class ConstraintIndexer extends java.lang.Object
The 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 IValueExtractor
extractor1
The value extractor 1 (left).protected IValueExtractor
extractor2
The 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 void
addObject(java.lang.Object right, IOAVState state, BetaMemory bmem)
Add an object to the memory.void
addTuple(Tuple left, IOAVState state, BetaMemory bmem)
Add a tuple to the memory.boolean
equals(java.lang.Object obj)
Test if the evaluator equals an object.java.util.Set
findObjects(Tuple left, BetaMemory bmem)
Find all objects for a tuple.java.util.Set
findTuples(java.lang.Object right, BetaMemory bmem)
Find all tuples for an object.AttributeSet
getIndirectAttributes()
Get the set of indirect attribute types.AttributeSet
getRelevantAttributes()
Get the set of relevant attribute types.int
hashCode()
Get the hash code.boolean
isAffected(int tupleindex, OAVAttributeType attr)
Test if a constraint evaluator is affected from a change of a certain attribute.boolean
isLeftIndex(int tupleindex, OAVAttributeType type)
Test if the indexer uses the given index and attribute type for left side indexing.boolean
isRightIndex(OAVAttributeType type)
Test if the indexer uses the given attribute type for right side indexing.void
removeObject(java.lang.Object right, BetaMemory bmem)
Remove an object from the memory.void
removeTuple(Tuple left, BetaMemory bmem)
Remove a tuple from the memory.java.lang.String
toString()
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:
toString
in classjava.lang.Object
- Returns:
- The string representation.
-
equals
public boolean equals(java.lang.Object obj)
Test if the evaluator equals an object.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Get the hash code.- Overrides:
hashCode
in classjava.lang.Object
-
-