Delivery reports about your e-mail
by The Post Office
The original message was received at Thu, 5 Nov 2009 14:38:35 +0800
from lists.jboss.org [100.45.141.246]
----- The following addresses had permanent fatal errors -----
rules-users(a)lists.jboss.org
----- Transcript of the session follows -----
... while talking to server 129.214.71.15:
554 Service unavailable; [12.81.29.214] blocked using bl.spamcop.net, reason: Blocked
Session aborted
16 years, 6 months
Re: [rules-users] Execution time for drools5.0 against large data size
by Abarna Ramachandran
I have tried couple of things as suggested by the rules user list. It has
improved the execution time of hello world example to some extent.
1. Moving fireallRules() out of the loop - helped very little, execution
time was almost same(150 millisecs less). - 10.35 secs
2. Commenting out the audit logger used in the example - cut the execution
time by half 5.67 secs
3. Removing system.outs from rules - reduces 2 secs of execution time -
3.433
The final execution time for HelloWorldExample in drools5.0 is 3.4 secs and
in Java is 256 milli secs. (I am attaching the java version of drools
example also to this email) .
package org.drools.examples;
import java.util.List;
import org.drools.examples.HelloWorldExample.Message;
public class HelloWorldJavaExample {
public static long starttime = 0;
public static long endtime =0;
public static void hello(Message message)
{
System.out.println(message.getMessage());
message.setMessage("Good Bye Cruel World");
message.setStatus(Message.GOODBYE);
goodbye(message);
}
public static void goodbye(Message message)
{
System.out.println(message.getMessage());
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
starttime = System.currentTimeMillis();
for(int u=0;u<10000;u++)
{
final Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
if(message.getMessage().equalsIgnoreCase("Hello
World"))
{
hello(message);
}
}
endtime = System.currentTimeMillis();
System.out.println("execution time in main is
"+(endtime-starttime));
}
public static class Message {
public static final int HELLO = 0;
public static final int GOODBYE = 1;
private String message;
private int status;
public Message() {
}
public String getMessage() {
return this.message;
}
public void setMessage(final String message) {
this.message = message;
}
public int getStatus() {
return this.status;
}
public void setStatus(final int status) {
this.status = status;
}
public static Message doSomething(Message message) {
return message;
}
public boolean isSomething(String msg, List list) {
list.add(this);
return this.message.equals(msg);
}
}
}
thanks for your suggestions.
ABRA2
16 years, 6 months
Execution time for drools5.0 against large data size
by ABRA2
Hi
I would like to test the time taken to run a single rule (eg.
HelloWorldExample from Drools5.0 documentation) against large data size (i.e
the object inserted in ksession is 10,000). The .drl file is loaded only
once and i am looping the part where message object is created and set with
values and inserted into ksession for 10,000 times. The time taken was 10.7
secs on an average. Am i doing something wrong? Can i improve it in anyway?
Your help is appreciated.
thanks
ABRA
HelloWorld.drl :
package org.drools.examples
import org.drools.examples.HelloWorldExample.Message;
global java.util.List list
rule "Hello World"
dialect "mvel"
when
m : Message( status == Message.HELLO, message : message)
then
System.out.println( message );
modify ( m ) { message = "Goodbye cruel world",
status = Message.GOODBYE };
end
rule "Good Bye"
dialect "java"
when
Message( status == Message.GOODBYE, message : message )
then
System.out.println( message );
end
HelloWorldExample.java
/**
* This is a sample file to launch a rule package from a rule source file.
*/
public class HelloWorldExample {
public static final void main(final String[] args) throws Exception {
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
// this will parse and compile in one step
kbuilder.add(ResourceFactory.newClassPathResource("HelloWorld.drl",
HelloWorldExample.class), ResourceType.DRL);
// Check the builder for errors
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors().toString());
throw new RuntimeException("Unable to compile \"HelloWorld.drl\".");
}
// get the compiled packages (which are serializable)
final Collection<KnowledgePackage> pkgs = kbuilder
.getKnowledgePackages();
// add the packages to a knowledgebase (deploy the knowledge packages).
final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);
final StatefulKnowledgeSession ksession = kbase
.newStatefulKnowledgeSession();
ksession.setGlobal("list", new ArrayList());
ksession.addEventListener(new DebugAgendaEventListener());
ksession.addEventListener(new DebugWorkingMemoryEventListener());
// setup the audit logging
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "log/helloworld");
long starttime = System.currentTimeMillis();
for(int u=0;u<10000;u++)
{
final Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
ksession.insert(message);
ksession.fireAllRules();
}
long endtime = System.currentTimeMillis();
System.out.println("execution time is "+(endtime-starttime));
logger.close();
ksession.dispose();
}
public static class Message {
public static final int HELLO = 0;
public static final int GOODBYE = 1;
private String message;
private int status;
public Message() {
}
public String getMessage() {
return this.message;
}
public void setMessage(final String message) {
this.message = message;
}
public int getStatus() {
return this.status;
}
public void setStatus(final int status) {
this.status = status;
}
public static Message doSomething(Message message) {
return message;
}
public boolean isSomething(String msg, List list) {
list.add(this);
return this.message.equals(msg);
}
}
}
--
View this message in context: http://old.nabble.com/Execution-time-for-drools5.0-against-large-data-siz...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 6 months
Performance hit in version 5.0?
by Duane Rosengartner
Group,
The following HelloWorld example is taken from the example code coming with the latest Drools downloads. One modification is the addition of the loop(10K times). Please note that the loading of the drl file is outside of this loop. Our developer tells us that this same example runs in 300milliseconds in Drools 2.0. Version 5.0 runs for 10 seconds. We have a large batch process that will suffer greatly if this is something we can't work around. Any ideas for performance gains in 5.0 will be greatly appreciated.
Duane
duane(a)proqualitysoft.com
public static final void main(final String[] args) throws Exception {
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// this will parse and compile in one step
kbuilder.add(ResourceFactory.newClassPathResource("HelloWorld.drl",
HelloWorldExample.class), ResourceType.DRL);
// Check the builder for errors
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors().toString());
throw new RuntimeException("Unable to compile \"HelloWorld.drl\".");
}
// get the compiled packages (which are serializable)
final Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
// add the packages to a knowledgebase (deploy the knowledge packages).
final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ksession.setGlobal("list", new ArrayList<Object>());
ksession.addEventListener(new DebugAgendaEventListener());
ksession.addEventListener(new DebugWorkingMemoryEventListener());
// setup the audit logging
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "log/helloworld");
long starttime = System.currentTimeMillis();
for(int u=0;u<10000;u++)
{
final Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
ksession.insert(message);
ksession.fireAllRules();
}
long endtime = System.currentTimeMillis();
System.out.println("execution time is "+(endtime-starttime));
logger.close();
ksession.dispose();
}
16 years, 6 months
DRLParser not parsing collections
by Ken Archer
I have successfully used DRLParser with several DRL files, except when they include the 'contains' syntax. My code for parsing DRL and then dumping into XML, is below:
public class DroolsDumper {
public static final void main(String[] args) throws DroolsParserException {
DrlParser parser = new DrlParser();
PackageDescr descr = parser.parse(new InputStreamReader(DroolsDumper.class.getResourceAsStream("/source.drl" )));
// Dump to xml rule.
XmlDumper dumper = new XmlDumper();
String result = dumper.dump(descr);
System.out.println(result);
}}
This code returns the following error when the DRL includes 'contains' syntax:
Exception in thread "main" java.lang.NullPointerException
at org.drools.xml.XmlDumper.visitPackageDescr(XmlDumper.java:224)
at org.drools.xml.XmlDumper.dump(XmlDumper.java:71)
at com.sample.DroolsDumper.main(DroolsDumper.java:19)
This code works fine with the following DRL (whether I dump the parsed DRL into XML or back into DRL):
rule 'cart rule'
dialect "mvel"
when
Cart ()
then
System.out.println("Hello World");
end
But it returns the above error when the same DRL includes 'contains':
rule 'cart rule'
dialect "mvel"
when
Cart (skus contains (123))
then
System.out.println("Hello World");
end
The DRL works fine in test scenarios and my cart class's array is declared simply as follows:
package shopping;
import java.util.ArrayList;
public class Cart {
public ArrayList<Integer> skus = new ArrayList<Integer>();
public ArrayList<Integer> getSkus() {
return skus;
}
public void setSkus(ArrayList<Integer> skus) {
this.skus = skus;
}
}
16 years, 6 months
Ant build script and XLS Decision Tables failing
by Adam Rinehart
Has anyone been able to compile an XLS decision table into a package via an
Ant build script?
I've scouring the documentation on the Drools Ant Compiler Task (what little
I could find) and I can't find any documentation on hw to pass configuration
into the ant task for things such as compiling XLS decision tables.
Without a configuration entry, when I try and run the build script
referencing an excel file, it fails with the following error:
Buildfile: C:\Documents and
Settings\Adam\workspace\RivaDroolsExperiment\build-5.1.xml
compileArtifacts:
BUILD FAILED
C:\Documents and
Settings\Adam\workspace\RivaDroolsExperiment\build-5.1.xml:21: RuleBaseTask
failed: null
---------------
I suspect this message is because the compiler task is failing with a null
pointer exception, which it throws when you don't provide it with a
configuration file. I am running
the build3423-rev29890-20091102-1042 Drools 5.1 Snapshot.
The relevant snippet from the build script:
<target name="compileArtifacts">
<compiler srcdir="${projectPath}src/main/rules"
tofile="${projectPath}target/experiment.pkg" binformat="package"
bintype="knowledge" classpathref="model.classpath">
<include name="Sample.xls" />
</compiler>
</target>
------------------
Thanks,
Adam
16 years, 6 months
Strange MVEL error
by Shah, Malay
Hi All,
I am trying to compile a drool rule using MVEL dialect and getting the
following weird error.
Unable to determine the used declarations.
unbalanced braces (near code: << ... core1_entityOID); ...>>) (position:
33) : [Rule name=Legacy ETSDB Rule, agendaGroup=MAIN, salience=0,
no-loop=false]
org.mvel.ParseException: unbalanced braces (near code: << ...
core1_entityOID); ...>>) (position: 33)Unable to build expression for
'consequence'
The code I am trying to compile is:
package S_124
import com.ms.ieddata.dataQuality.violation.Violation;
import com.ms.ieddata.etsdb.model.EtsExecution_core;
import com.ms.ieddata.etsdb.model.EtsExecutionOrder_core;
global java.util.HashSet violations;
global java.util.HashSet violationKeys;
dialect "mvel"
rule "Legacy ETSDB Rule"
when
EtsExecution_core1:EtsExecution_core(crossInd == "1" , lastCapacity !=
"3" , lastDestinationID not in ("EUREX","IDEM","MEFF","LIFFE"))
EtsExecutionOrder_core1:EtsExecutionOrder_core(entityOID ==
EtsExecution_core1.parentOID , exDestination in ("I","L") ,
swapComponentType != "swaps" , orderCapacity not in
("D","R","X","L","E","T","C","O","P","S"),EtsExecutionOrder_core1_entity
OID:entityOID,EtsExecutionOrder_core1_application:application,EtsExecuti
onOrder_core1_entityVID:entityVID)
then
String key="S-124_EtsExecution_core" + "_entityVID_" +
"EtsExecutionOrder_core1_entityVID" + "_application_" +
"EtsExecutionOrder_core1_application" + "_entityOID_" +
"EtsExecutionOrder_core1_entityOID";
vPresent = violationKeys.contains(key);
if (!vPresent)
{
violation = new Violation();
violation.putRuleActionAttribute("ruleId","S-124");
violation.putRuleActionAttribute("ruleName","Legacy ETSDB Rule");
violation.putRuleActionAttribute("legacyRuleType","1");
violation.putRuleActionAttribute("entityName","EtsExecution_core");
violation.putRuleActionAttribute("fieldName","Field");
violation.putRuleActionAttribute("entityVID",EtsExecutionOrder_core1_ent
ityVID);
violation.putRuleActionAttribute("application",EtsExecutionOrder_core1_a
pplication);
violation.putRuleActionAttribute("entityOID",EtsExecutionOrder_core1_ent
ityOID);
}
end
The code works fine when I use java dialect. Also, if I remove the if
statement from consequence, the code get compiled in mvel and java
dialects. Am I missing something obvious here? I am using drools 4.0.1.
Thanks
Malay Shah
Morgan Stanley | IDEAS Practice Areas
750 Seventh Avenue, 6th Floor | New York, NY 10019
Phone: +1 212 762-4495
Malay.Shah(a)morganstanley.com
--------------------------------------------------------------------------
NOTICE: If received in error, please destroy, and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. We may monitor and store emails to the extent permitted by applicable law.
16 years, 6 months
generate jar with type declarations?
by strug
hi there!
i am asking myself if there is a way to get the compiled type declaration? i
found one thread that says that guvnor can do it.
what i want to do is s.th. like that:
- writing rules using dynamic facts (type declarations)
- generating a jar with the compiled type declarations
- using this jar inside a unit-test only
- having full code completion and strong typing
- avoid using "string-based" factType API
Regards, Leif
--
View this message in context: http://old.nabble.com/generate-jar-with-type-declarations--tp26163931p261...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 6 months
Synchronization requirements on newStatelessKnowledgeSession()?
by Laird Nelson
Are there any synchronization requirements on calling
knowledgeBase.newStatelessKnowledgeSession()? Must I synchronize on
anything to make this call in a multithreaded environment?
Once I have a StatelessKnowledgeSession, must I synchronize on anything to
work with it, or is it truly stateless in all regards?
I'm not sure my previous message on this topic was received properly.
Thanks,
Laird
16 years, 6 months