Re: [rules-users] populating global variable in Condition Section?
by Greg Barton
Of course, I had to test that assertion. :)
$ java -Xmx128M -server -jar target/DroolsExistence-1.0.jar not.drl 50000
25000
2395ms
$ java -Xmx1024M -server -jar target/DroolsExistence-1.0.jar not_exists.drl 50000
25000
121378ms
You ain't kiddin'! 50x slower requiring 9x the memory.
--- On Fri, 8/21/09, Wolfgang Laun <wolfgang.laun(a)gmail.com> wrote:
> From: Wolfgang Laun <wolfgang.laun(a)gmail.com>
> Subject: Re: [rules-users] populating global variable in Condition Section?
> To: "Rules Users List" <rules-users(a)lists.jboss.org>
> Date: Friday, August 21, 2009, 4:54 PM
> <quote>
> It is rather common for people to
> write something like "(not (exists
> (A)))," but this is just a
> very inefficient way to write (not
> (A)).
> </quote>
>
> Kudos to Ernest Friedman-Hill to put this sentence into the
> Jess documentation.
>
> Maybe I should quote hiom in the Drools Expert doc ;-)
>
>
> -W
>
>
> On Fri, Aug 21, 2009 at 11:11 PM,
> Shah, Malay <Malay.Shah(a)morganstanley.com>
> wrote:
>
> May be I have not put the question right. We have a drool
> rule that is running extremely slow for large sets of data.
> The rule is something like:
>
>
>
> For every object A, perform action if there does not exist
> an object B such that A.id = B.id.
>
> And the corresponding drool rule is as follows:
>
>
>
> when
>
> A()
>
> not(exists B(A.id = id))
>
> then
>
> action......
>
>
>
> The performance is bad because of not exists clause here.
> We have got OOM exceptions with relatively large amounts of
> data for this rule. To improve performance, we basically
> hacked the rule/code into something like this:
>
>
>
>
> Create a global variable x that is a HashSet of all ids of
> object A, and the drool rule now is:
>
>
>
> global java.util.HashSet x;
>
> when
>
> B()
>
> eval
>
> (
>
> ! (x.contains(b.id) )
>
> )
>
> then
>
> action.....
>
>
>
> This obviously is performing much better with hashes
> involved. But, I don't like the fact that we have to
> write the logic of this rule at two places. I would rather
> create this variable x (don't care whether it is global
> or temporarily bound) in the rule itself and use it in the
> condition to help performance and have all logic for the
> rule at one place.
>
>
>
>
> Is there a way to generate this hashset x in the condition
> part of the rule itself? Yes, I understand that I am trying
> to mix up the procedural part of code with drool code. But,
> I was just wondering if this is possible to keep the java
> code clean and have the intelligence of information that the
> rule needs to be evaluated in the rule itself.
>
>
>
>
> Hope this clears some doubts.
>
>
>
> Thanks
>
>
>
> Malay Shah
>
>
>
> -----Original Message-----
>
> From: rules-users-bounces(a)lists.jboss.org
> [mailto:rules-users-bounces@lists.jboss.org]
> On Behalf Of Greg Barton
>
>
> Sent: Friday, August 21, 2009 4:44 PM
>
> To: Rules Users List
>
> Subject: Re: [rules-users] populating global variable in
> Condition Section?
>
>
>
> This is a galactically bad idea. Using a global in this
> way is inherently unsafe as there's no guarantee that
> ebtween the time you set the var and when it's used
> later in the condition that the value is the same. What is
> your reason for wanting to use a global in this way? You
> should use a temporary bound variable instead.
>
>
>
>
> --- On Fri, 8/21/09, Shah, Malay <Malay.Shah(a)morganstanley.com>
> wrote:
>
>
>
> > From: Shah, Malay <Malay.Shah(a)morganstanley.com>
>
> > Subject: [rules-users] populating global variable in
> Condition Section?
>
> > To: rules-users(a)lists.jboss.org
>
> > Date: Friday, August 21, 2009, 3:19 PM
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > Hi,
>
> >
>
> > Is it possible
>
> > to populate a global variable in
>
> > the condition section of the
>
> > drool rule, and use it later in the condition itself?
>
> > I currently have a
>
> > global HashSet variable that I construct before firing
> the rule, but I
>
> > would like this code of constructing this global
> variable to be with
>
> > the drool rule itself. Any help on this would be much
> appreciated.
>
> >
>
> > Thanks
>
> >
>
> > Malay
>
> >
>
> >
>
> >
>
> > 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.
>
> >
>
> >
>
> > -----Inline Attachment Follows-----
>
> >
>
> > _______________________________________________
>
> > rules-users mailing list
>
> > rules-users(a)lists.jboss.org
>
> > https://lists.jboss.org/mailman/listinfo/rules-users
>
> >
>
>
>
>
>
>
>
>
>
> _______________________________________________
>
> rules-users mailing list
>
> rules-users(a)lists.jboss.org
>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> --------------------------------------------------------------------------
>
> 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.
>
>
>
>
> _______________________________________________
>
> rules-users mailing list
>
> rules-users(a)lists.jboss.org
>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
16 years, 6 months
BRMS configuration changes to support Oracle
by David Godfrey
Hi,
Is anyone able to supply an example repository.xml used to configure Drools
BRMS to work with an Oracle database rather than flat-file based repository?
I have tried following examples I found on the internet, including the
Jackrabbit site, but it is very non-obvious and there seems to be no example
showing a full working xml file, just small snippets.
With the configuration I have, I can see that tables are being created in my
database, but I get many different errors, e.g. complaining that the
repository ".lock" file is locked by another process, even though I thought
it shouldn't be using that file any longer in favour of Oracle.
Many thanks,
Dave
--
Ted Turner <http://www.brainyquote.com/quotes/authors/t/ted_turner.html> -
"Sports is like a war without the killing."
16 years, 6 months
Drools fusion forward chaining
by Ahmed Hafsi
Hi guys ,
I am using the lastest version of DROOLS , i.e 5.0 , I am trying to achieve
forward chaining with the new features of Fusion
I was looking for examples about the different operators and how to make use
of them but the broker example does not mention in it's DRL file any time
related operators , i.e after , meets ...
I would be grateful if you guys provide me with a simple example of forward
chaining (sequence)
My goal to achieve is to implement something like this :
CmplxEvent :- a and then b and then c
my drools rule is :
rule "cmplx0"
when
$a : Event()
$b : Event()
Event(this after $b && $b after $a)
then
//whatever
end
however this does not work , it complains about "unable to create field
exatractor"
Event is an event that I have declared using declare Event and then the
metadata @event as described in the docs.
Thanks for help.
Khalil Hafsi
16 years, 6 months
Re: [rules-users] not able to debug drools flow
by Bernd Rücker
Same for me, Eclipse 3.5.0 with jdk 6 and Drools 5 (contained in JBoss
Tools) under Windows XP.
I get exactly the same exception when trying to debug.
With Eclipse 3.4.2 it works (the other environment keeps the same).
Cheers
Bernd
P.S: Maybe the wrong place and time, but a forum for drools users would be
much more handy to use than the mailing list ;-)
--
Hi,
I am using Eclipse 3.5.0, jdk 1.6.0_13-b03 and Drools 5.0 all on Windows
XP
Professional SP3.
Jakob
On Sat, Aug 22, 2009 at 11:47 PM, Kris Verlaenen <
kris.verlae...(a)cs.kuleuven.be> wrote:
> I just tried using Eclipse 3.5.0, jdk 1.6.0_06 and the latest Drools
> 5.1.0.SNAPSHOT on RHEL and everything seems to be working fine ...
>
> Could you specify the exact environment you are getting this error in,
> so I can at least try to reproduce?
>
> Kris
16 years, 6 months
Weird NullPointerException when deploying Drools rules on FUSE OSGI 4 ESB
by Marcel Casado
Hi,
I'm trying to deploy a simple decision service using Drools on a OSGI
environment (FUSE ESB 4.). The rule right now is really simple is like a
look up service. The rules run fine on my tests on the IDE but when
deploying it on Fuse ESB throws an exception. To be clear I'm not using the
Drool's servicemix component (Drools Service Engine), I'm building my OSGI
bundle that imports it's Drools dependencies from some other "servicemix"
bundles deployed on the OSGI kernel. I know that drools builder finds my
rule file but then throws this exception :
... 32 more
Caused by: java.lang.NullPointerException
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:47)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
at
edu.ucar.rap.flighthazard.decisionservice.service.impl.SessionManagerImpl.instantiateRuleBase(SessionManagerImpl.java:173)
at
edu.ucar.rap.flighthazard.decisionservice.service.impl.SessionManagerImpl.initialize(SessionManagerImpl.java:96)
What I'm doing is really basic and it works on my IDE but seems I'm missing
something when deploying on the OSGI. I tried also to use the Drools 5.0.1
API with KnowledgeBase but the same thing. I saw other posts with
classloader problems on OSGI but this seems something different.
The java code :
private RuleBase instantiateRuleBase() throws DroolsParserException,
IOException {
Reader reader;
PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
PackageBuilder builder = new PackageBuilder(conf);
Package pkg;
RuleBase ruleBase;
/* Process DRLS */
Iterator<String> iter = drls.iterator();
while (iter.hasNext()) {
URL url = URLUtils.getURL(iter.next());
reader = new InputStreamReader(url.openStream());
builder.addPackageFromDrl(reader);
}
// get the compiled package (which is serializable)
pkg = builder.getPackage();
// add the package to a rulebase (deploy the rule package).
ruleBase = RuleBaseFactory.newRuleBase();
try {
ruleBase.addPackage(pkg);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ruleBase;
}
The rule .drl :
package edu.ucar.rap.flighthazard.decision.rules
import org.drools.base.extractors.*;
import
edu.ucar.rap.flighthazard.decisionservice.dto.FlightHazardsDecisionRequest;
import edu.ucar.rap.flighthazard.decisionservice.dto.FlightHazardThresholds;
import
edu.ucar.rap.flighthazard.core.dto.weatherHazard.WeatherHazardDefinition;
import
edu.ucar.rap.flighthazard.core.dto.weatherHazard.CoverageHazardDefinition;
import edu.ucar.rap.flighthazard.core.dto.weatherHazard.Threshold;
import edu.ucar.rap.flighthazard.core.dto.aircraft.AircraftCharacteristic;
import edu.ucar.rap.flighthazard.core.dto.aircraft.FlightCharacteristic;
import java.util.List;
rule "FindFlightCoverageHazardsThresholds"
salience 50
no-loop
when
$request : FlightHazardsDecisionRequest();
$hazardDefinition : WeatherHazardDefinition(eval(type.value() ==
"COVERAGE")) from $request.getHazardsOfInterest();
$fhthresholds : FlightHazardThresholds (aircraft.type.code ==
$request.aircraft.type.code,
hazardOfInterest.data_ref == $hazardDefinition.data_ref,
hazardOfInterest.field_ref == $hazardDefinition.field_ref);
then
System.out.println( "Request is: " + $request.toString());
System.out.println( "fhthresholds is: " +
$fhthresholds.getHazardOfInterest().getData_ref());
$hazardDefinition.setThresholds($fhthresholds.getHazardOfInterest().getThresholds());
end
# This rule sets special CEILING, VISIBILITY and FLTCAT thresholds if the
Flight Rule provided in the request is VFR - Visual flight rules
# in this case ceiling and visibility does not matters as hazards.
rule "FlightRule"
salience 10
no-loop
when
$request : FlightHazardsDecisionRequest(
eval(flightCharacteristic.getRule().value() == "VFR" ))
$hazardDefinition : WeatherHazardDefinition(data_ref ==
"urn:fdc:ncar.ucar.edu:Dataset:CEIL" ||
data_ref == "urn:fdc:ncar.ucar.edu:Dataset:Visibility" || data_ref ==
"urn:fdc:ncar.ucar.edu:Dataset:FLTCAT" ) from
$request.getHazardsOfInterest()
# eval(System.out.println(hazardDefinition.data_ref); true)
$fhthresholds : FlightHazardThresholds (aircraft.type.code ==
$request.aircraft.type.code,
eval(hazardOfInterest.getData_ref() ==
$hazardDefinition.getData_ref().concat(":VFR")), hazardOfInterest.field_ref
== $hazardDefinition.field_ref)
then
// System.out.println( "Request is: " + request.toString());
// System.out.println( "fhthresholds is: " +
fhthresholds.getHazardOfInterest().getData_ref());
$hazardDefinition.setThresholds($fhthresholds.getHazardOfInterest().getThresholds());
end
Any suggestions will be appreciated.
Thanks,
-Marcel
--
View this message in context: http://www.nabble.com/Weird-NullPointerException-when-deploying-Drools-ru...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 6 months
Maps again - key derived from another object
by KDR
Hi, I'm still having issues with this despite getting the snapshot update to
the mvel jar. Can anyone suggest what else to try please? Am I doing
something wrong?
Say I insert 2 objects:
- ObjectWithKey which has a field that is a string to be used as the key.
- ObjectWithMap has a field that is a map, which contains entries -
including one for the key string that's in the inserted ObjectWithKey.
With the rule below, trying to get the value with the key always produces
null (although with the updated jar at least I no longer get a compilation
error!). However if I use a literal for the key, or from an inserted String
object (the commented out $s below), then it works to print out the right
value for the key.
rule "Tester"
dialect "mvel"
when
# $s : String (this == "aString") # works if I use $s as key
$a : ObjectWithKey (
$k: aStringForKey,
$o: objectWithMap
)
$b: ObjectWithMap (
this == $o,
map != null # works fine, it can see there's a map in existence
# map[$k] != null, # no good, Drools thinks this value is always null
# map[$s] # this works however
)
then
System.out.println("ObjectWithMap has non-null map, value for key is "); #
prints OK
System.out.println($b.map[$k]); # prints out null!
end
I'm at my wit's end. I've also tried Java (with get) and eval alternatives
and can't get it to work. If anyone can suggest a way to get a value out of
the map (for testing against other conditions) when the map is a field of
one object, using a key that is a field in another object, I'd really
appreciate it.
Cheers
--
View this message in context: http://www.nabble.com/Maps-again---key-derived-from-another-object-tp2509...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 6 months
Drool Flow persistence Doubt
by Pardeep.Ruhil@lntinfotech.com
Hi Users,
I am having a doubt regarding the Drools Workflow in my scenario.
I want to integrate Drools Flow in my application and have some doubts
regarding the
persistence of Workflow process instances.
Let suppose I have a workflow running in my application and at point
my application crashed or i restart my application. So is their way i can
restart the workflow the point it was.
If i store the process instance Id in the database, so am I able to start
my workflow process
from where it had stopped , if it is possible can you tell me the method
responsible for the same.
Please help me to get through the situation.
Thanks & Regards
Pardeep Ruhil
L&T Infotech Ltd
Mumbai
Ph: +919820283884
Larsen & Toubro Infotech Ltd.
www.Lntinfotech.com
This Document is classified as:
L&T Infotech Proprietary L&T Infotech Confidential L&T Infotech
Internal Use Only L&T Infotech General Business
This Email may contain confidential or privileged information for the
intended recipient (s) If you are not the intended recipient, please do
not use or disseminate the information, notify the sender and delete it
from your system.
______________________________________________________________________
16 years, 6 months
populating global variable in Condition Section?
by Shah, Malay
Hi,
Is it possible to populate a global variable in the condition section of
the drool rule, and use it later in the condition itself? I currently
have a global HashSet variable that I construct before firing the rule,
but I would like this code of constructing this global variable to be
with the drool rule itself. Any help on this would be much appreciated.
Thanks
Malay
--------------------------------------------------------------------------
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