MVEL performance penalty
by Wolfgang Laun
Drools 5.3.0 FINAL.
This experiment was inspired by code posted with the insinuation that MVEL
would "optimize" condition evaluation. - Consider this rule:
rule "Term - java"
dialect "java"
when
$ea : EasyApp( Test.valueInList( $ea.getProductCode(), "CAR" )==true
&& age < 0 )
then end
You'd expect that Test.valueInList() is called once per inserted EasyApp
fact, and this can be verified easily. - Now the same rule, with MVEL's
syntactic sugar:
rule "Term - mvel"
dialect "mvel"
when
$ea : EasyApp( Test.valueInList( productCode, "CAR" )==true
&& age < 0 )
then end
*Now Test.valueInList() is called twice for each inserted fact.*
Cheers
Wolfgang
14 years
Retriving Rule Id in Rule Template
by srinivasasanda
Hi All,
How to retrieve the cell number(rule id) when i click the load template
data.
My actual requirement is,I created a rule template where i defined some
conditions and actions.Now,when i clicked the load template data,i filled
condition columns and action columns.
I added 4 rows in template data.Now there are 4 rules available which are
postfixed with ids(cell numbers).
Now,how can i get that cellnumbers(1,2,3,4) in then part of rule condition.
Please suggest me
--
View this message in context: http://drools.46999.n3.nabble.com/Retriving-Rule-Id-in-Rule-Template-tp36...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Inserting rules from guvnor into database
by srinivasasanda
Hi All,
Greetings,
I would like to know how to insert the rules from guvnor into
database.Ofcourse,I retrieved the rules from guvnor through KnowledgePackage
classes and API and inserted manually through java code.
But,I should not need that.My requirement is whenever i created rule in the
guvnor and click save changes,my repository of rules must be inserted into
database(mysql or postgres).How can i achieve that.Please suggest me.How can
i achieve that.
Thanks in Advance
--
View this message in context: http://drools.46999.n3.nabble.com/Inserting-rules-from-guvnor-into-databa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Uable to reolve type
by gg
This is my rules file and its throwing this error:
[ isContained : unable to resolve type while building function
]
--------------------------------------------------------------------------------
package com.sample
import com.sample.DroolsTest.Message;
import com.sample.DroolsTest.Result;
import com.sample.DroolsTest.Discount;
import java.util.Arrays;
import java.util.List;
function boolean isContained(List<String> plist, List<String> clist){
boolean found = true;
for(String s : clist){
if (!plist.contains(s)){
found = false;
}
}
return found;
}
rule "GoodBye"
when
m : Message(ls:ls, pids: productIds)
l : List() from ls
eval(isContained(pids,l))
then
System.out.println( "found" );
end
Thanks,
--GG
--
View this message in context: http://drools.46999.n3.nabble.com/Uable-to-reolve-type-tp3634048p3634048....
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Function Mismatch <eof>
by gg
I have written this in my rules file: But I getting this error :
[29,0]: [ERR 102] Line 29:0 mismatched input '<eof>' in function
"isContained"
[0,0]: Parser returned a null Package
-----------------------------------------------------------------------------
function boolean isContained(List<String> plist, List<String> clist){
boolean found = true;
for(String s : clist){
if (!plist.contains(s)){
found = false;
}
return found;
}
rule "GoodBye"
when
m : Message(ls:ls, pids: productIds)
l : List() from ls
eval(isContained(pids,l))
then
System.out.println( "found" );
end
--
View this message in context: http://drools.46999.n3.nabble.com/Function-Mismatch-eof-tp3634033p3634033...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Lists of Lists membership
by gg
I have a List of List of String : List<List<String>> and an array of
strings: String [].
I want to fire a rule each time the inside "List of String" is contained in
the array of String [].
for example
List<List<String>> :
(1,2,3)
(2,3)
(4,5,6)
and String []:
(2,3,4)
so this should fire 1 rule corresponding to (2,3) contained in (2,3,4)
Thanks,
--GG
--
View this message in context: http://drools.46999.n3.nabble.com/Lists-of-Lists-membership-tp3633943p363...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Removing Special Characters
by Lalitha
Hi all,
I am working on drools. I would like to remove Special characters which
are existed in the data i.e. replacing special characters with null.
Following is the code:
rule "Wild Character validation"
when
c : CustomerInfo(customerName != "");
then
int l = c.length();
int ch = 0;
int i = 0;
for (i = 0; i < l; i++) {
if (data.charAt(i) != "*"|| data.charAt(i) != "#"){
continue;
}
ch++;
data.setCharAt(i, "");
}
c.setCustomerName(data);
end
Is there any wrong in this code? If so please help me out. Waiting for your
suggestion .
Thanks and Regards,
Lalitha.
--
View this message in context: http://drools.46999.n3.nabble.com/Removing-Special-Characters-tp3628821p3...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Could not parse knowledge when using 'not contains' in a quote leading a '!'
by Miles Wen
hi all,
This code could not be parsed correctly:
rule "out"
when
Msg(!(set not contains "test"))
then
end
I tried a few simple situations and found that when using 'not contains'
operator in a '!' leading quote triggers this problem. If no '!' prefixing
the quote,the program works like a charm...
Is this a bug? I wish that I posted in the right forum(or I would go to
submit an issue?)..
The example above seemed so stupid(you can use a 'contains' operator
instead), but this is the simplest toy example.And this problem would be
looked more important if you want to write some logic like this:
Msg(!(set not contains "test" || !bool && string == "hello"))
So...
Is there anyone who also encountered this problem? I'm using drools 5.3.0
final.
Any help would appreciated.
Thanks!
--
Regards.
Miles. Wen
14 years
Extracting management information from the content of the rules
by Henrique Lira
Hi,
I'm doing an evaluation of Guvnor tool, and one of the requirements that we
wish to be met is the ability to extract management reports from the content
of the rules. Let me explain better: assuming I have several rules that
define discounts for products depending on their characteristics, how can I
get, for example, which products have a discount of X%? I tried using the
search function of the Guvnor, but I found it very simple to more managerial
information like this? Is there any other functionality to generate more
complex queries?
Thanks in advance,
Henrique
--
View this message in context: http://drools.46999.n3.nabble.com/Extracting-management-information-from-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
MVEL optimization?!?
by ronalbury
I'm not sure how to explain this, other than it appears that MVEL is trying
to optimize the When conditions in my rules.
I have a utility class, Test, with a number of methods on it (including null
protected versions of Drools "in" and "matches"). Note that the valueInList
method can return null (e.g. if the product code is null), and the
getAgeAsInt method can also return null (if the age is null). I don't like
having to test if the result of the method is true, but I kept running into
null pointer errors in the Drools expression evaluation code and had to
adopt this convention.
Here are two example rules (one in Java dialect and one in MVEL dialect). I
realize that a list of one is a degenerate case for using 'inList', but it
should still work.
rule "Term 15Plus Max Age - Washington"
dialect "java"
when
$ea : EasyApp(
Test.valueInList($ea.getEaProductCode(), "L15P")==true
&& Test.valueInList($ea.getEaIssueState(), "WA")==true
&& $ea.getPriIns_xmPerson().getAgeAsInt() > 65
)
then
$ea.addError(drools.getRule().getName());
end
rule "Term 20 Max Age - New Jersey"
when
$ea : EasyApp(
Test.valueInList(eaProductCode, "L20")==true
&& Test.valueInList(eaIssueState, "NJ")==true
&& priIns_xmPerson.ageAsInt > 64
)
then
$ea.addError(drools.getRule().getName());
end
I have approximately 30 different rules similar to those above. When I have
the rules written in MVEL, it appears to be only be evaluating one rule per
EasyApp injection (I have a log message when ever valueInList is called),
and I get bogus results. However, when I shift to java dialect then it
appears that the methods are called for each rule I have defined (as I would
have expected).
Can anyone tell me if I am doing something wrong, and explain why Drools is
behaving as it is?
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/MVEL-optimization-tp3632072p3632072.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years