ilog.rules.factory
Class IlrHasher
- java.lang.Object
-
- ilog.rules.factory.IlrHasher
-
- All Implemented Interfaces:
- java.io.Serializable
public final class IlrHasher extends java.lang.Object implements java.io.SerializableThe class defines a hasher of the ruleset. A hasher is a way to optimize the join test of a rule by activating an internal hash table. A hasher is composed of a formal variable defining on which class the hasher is applied, a hashing expression, and a set of properties.The properties are the size of the internal hash table, an accuracy flag to indicate which internal structure should be used, a constant flag indicating whether the hasher class instances are constant or not, and an ordered flag activating the hasher on relation orders. These properties may have an important influence on the performance of the engine.
By default, a hasher is activated only on an equality relation, is not accurate, and not constant.
There are additional constraints on the properties and the hashing expressions. Please refer to the reference manual.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static intDEFAULT_SIZE
-
Constructor Summary
Constructors Constructor and Description IlrHasher(IlrVariable formalVariable, IlrValue hashingExpr)Builds a hasher given its formal parameter and hashing expression.
-
Method Summary
Methods Modifier and Type Method and Description IlrVariablegetFormalVariable()Gets the formal variable of the hasher.IlrValuegetHashingExpression()Gets the hashing expression of the hasher.java.lang.StringgetIdentifier()Gets the identifier of the hasher.intgetSize()Gets the size of the internal hash table.booleanisAccurate()Indicates whether the hasher is accurate or not.booleanisConstant()Indicates whether the hasher is constant or not.booleanisOrdered()Indicates whether the hasher is ordered or not.voidsetAccurate(boolean accurate)Sets the accuracy of the hasher.voidsetConstant(boolean constant)Sets the constant quality of the hasher.voidsetOrdered(boolean ordered)Sets the ordered quality of the hasher.voidsetSize(int size)Sets the size of the internal hash table dedicated to this hasher.
-
-
-
Field Detail
-
DEFAULT_SIZE
public static final int DEFAULT_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IlrHasher
public IlrHasher(IlrVariable formalVariable, IlrValue hashingExpr)
Builds a hasher given its formal parameter and hashing expression.- Parameters:
formalVariable- The formal parameter.hashingExpr- The hashing expression.
-
-
Method Detail
-
setAccurate
public void setAccurate(boolean accurate)
Sets the accuracy of the hasher. An accurate hasher is related to an internal hash map where the key provided by the hashing expression exactly identifies the set of corresponding instances.- Parameters:
accurate-trueto set the hasher accuracy property.
-
setConstant
public void setConstant(boolean constant)
Sets the constant quality of the hasher. A constant hasher assumes that the cardinality of its related class is constant when the rules are fired in the engine. Adding a new instance is then time consuming compared to a nonconstant hasher.- Parameters:
constant-trueto set the hasher constant property.
-
setOrdered
public void setOrdered(boolean ordered)
Sets the ordered quality of the hasher. An ordered hasher could be activated with an equality or an ordered relation. The hashing expression must be consistent with this ordered relation.- Parameters:
ordered-trueto set the hasher ordered property.
-
getIdentifier
public java.lang.String getIdentifier()
Gets the identifier of the hasher. This identifier is composed of the formal variable.
-
isAccurate
public boolean isAccurate()
Indicates whether the hasher is accurate or not.- Returns:
trueif accurate.
-
isConstant
public boolean isConstant()
Indicates whether the hasher is constant or not.- Returns:
trueif constant.
-
isOrdered
public boolean isOrdered()
Indicates whether the hasher is ordered or not.- Returns:
trueif ordered.
-
setSize
public void setSize(int size)
Sets the size of the internal hash table dedicated to this hasher.- Parameters:
size- The size to be set.
-
getSize
public int getSize()
Gets the size of the internal hash table.- Returns:
- The size.
-
getFormalVariable
public IlrVariable getFormalVariable()
Gets the formal variable of the hasher.- Returns:
- The formal variable.
-
getHashingExpression
public IlrValue getHashingExpression()
Gets the hashing expression of the hasher.- Returns:
- The expression.
-
-