Optimization for sub-attributes in LHS conditions
-------------------------------------------------
Key: JBRULES-2781
URL:
https://jira.jboss.org/browse/JBRULES-2781
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-compiler, drools-core
Affects Versions: 5.1.0.FINAL
Environment: Windows XP & 7 Pro, Eclipse Galileo, JDK 1.6 update 21
Reporter: Frederico Ramos
Assignee: Mark Proctor
Priority: Minor
When building a simple rule, we discovered that the resulting "rete tree" did
not reused some node conditions, dispite they are listed in the same order. After some
different approaches we get to the expected tree using explicit predicates.
Shouldn't both alternatives generate the same tree? And if don't, can some
optimization be created in Drools CORE to handle this?
Note that although the tree is different, it uses the same node types.
OPTION 1: OPTIMIZED RETE TREE
------
{{{
#created on: 09/11/2010
package aa
#list any import classes here.
import br.com.auster.om.invoice.telco.CallDetail;
import br.com.auster.om.invoice.telco.ServiceTypeEnum;
import br.com.auster.om.util.UnitCounter;
import br.com.auster.om.util.UnitCounter.TypeOfUnitEnum;
import br.com.auster.om.invoice.telco.TelcoCustomer;
rule "call duration check 1"
when
CallDetail( serviceType == ServiceTypeEnum.VOICE,
$realDuration : realDuration -> ($realDuration.getType() == TypeOfUnitEnum.TIME),
$billedDuration : billedDuration -> ($billedDuration.getType() ==
TypeOfUnitEnum.TIME),
realDuration.seconds <= 3 )
then
// TODO
end
rule "call duration check 2"
when
CallDetail( serviceType == ServiceTypeEnum.VOICE,
$realDuration : realDuration -> ($realDuration.getType() == TypeOfUnitEnum.TIME),
$billedDuration : billedDuration -> ($billedDuration.getType() ==
TypeOfUnitEnum.TIME),
realDuration.seconds > 3 )
then
// TODO
end
rule "call-duration-check - realDuration > 30"
when
CallDetail( serviceType == ServiceTypeEnum.VOICE,
$realDuration : realDuration -> ($realDuration.getType() == TypeOfUnitEnum.TIME),
$billedDuration : billedDuration -> ($billedDuration.getType() ==
TypeOfUnitEnum.TIME),
realDuration.seconds > 30 )
then
// TODO
end
}}}
OPTION 2: NOT-OPTIMIZED RETE TREE
------
{{{
#created on: 09/11/2010
package aa
#list any import classes here.
import br.com.auster.om.invoice.telco.CallDetail;
import br.com.auster.om.invoice.telco.ServiceTypeEnum;
import br.com.auster.om.util.UnitCounter;
import br.com.auster.om.util.UnitCounter.TypeOfUnitEnum;
import br.com.auster.om.invoice.telco.TelcoCustomer;
rule "call duration check 1"
when
CallDetail( serviceType == ServiceTypeEnum.VOICE,
$realDuration : realDuration.type == TypeOfUnitEnum.TIME,
$billedDuration : billedDuration.type == TypeOfUnitEnum.TIME,
realDuration.seconds <= 3 )
then
// TODO
end
rule "call duration check 2"
when
CallDetail( serviceType == ServiceTypeEnum.VOICE,
$realDuration : realDuration.type == TypeOfUnitEnum.TIME,
$billedDuration : billedDuration.type == TypeOfUnitEnum.TIME,
realDuration.seconds > 3 )
then
// TODO
end
rule "call-duration-check - realDuration > 30"
when
CallDetail( serviceType == ServiceTypeEnum.VOICE,
$realDuration : realDuration.type == TypeOfUnitEnum.TIME,
$billedDuration : billedDuration.type == TypeOfUnitEnum.TIME,
realDuration.seconds > 30 )
then
// TODO
end
}}}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira