Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-10 Thread Vincent LEGENDRE
ok thanks. seems dangerous anyway .. and you said should be possible, which is (according to what I know in english) not really sure ? - Mail original - De: Davide Sottara dso...@gmail.com À: rules-users@lists.jboss.org Envoyé: Mercredi 9 Mai 2012 23:50:54 Objet: Re: [rules-users] Is

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-10 Thread Davide Sottara
should as in bugs/regressions apart :) -- View this message in context: http://drools.46999.n3.nabble.com/Is-there-a-faster-way-of-doing-this-in-Drools-tp3973888p3976439.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___

[rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
I've a use case where I need to create a rule dynamically every time the user sends a request. My current understanding of Drools is that you need to create a KnowledgeBuilder and then add the rules I'm creating the KnowledgeBase as follows. private static KnowledgeBase

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Mauricio Salatino
You can do that step once and then reload the compiled rules from the disk, or use guvnor which will compile the rules for you. Cheers On Wed, May 9, 2012 at 12:55 PM, soumya_sd soumya...@yahoo.com wrote: I've a use case where I need to create a rule dynamically every time the user sends a

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
salaboy wrote You can do that step once and then reload the compiled rules from the disk, or use guvnor which will compile the rules for you. Cheers Thanks for responding so quickly. I tried using Guvnor. Do you think it will be faster than this ? In the worse case, the rules that I

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Mauricio Salatino
Can you explain a little bit more about your context? having completely dynamic rules is not an usual use case, rules tends to be static because they define the business logic that you want to apply. So please elaborate on the context. On Wed, May 9, 2012 at 1:07 PM, soumya_sd soumya...@yahoo.com

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Davide Sottara
Could you please provide a more detailed example? The usecase you propose is really interesting and the optimization of something very similar is on the todo-list (@salaboy: request-when rings a bell?) Now, depending on your exact requirements, there could be various options, more or less clean ;)

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
Davide Sottara wrote Could you please provide a more detailed example? The usecase you propose is really interesting and the optimization of something very similar is on the todo-list (@salaboy: request-when rings a bell?) Now, depending on your exact requirements, there could be various

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Vincent LEGENDRE
Users changing rules IS the correct use-case of drools (I would even say that if rules never change, drools is likely to be worse than pure java). What others said is changing the rules at each request by regenerating and recompiling is not. I can't imagine that users may change rules at each

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
Vincent Legendre wrote Users changing rules IS the correct use-case of drools (I would even say that if rules never change, drools is likely to be worse than pure java). What others said is changing the rules at each request by regenerating and recompiling is not. I can't imagine that

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
Vincent Legendre wrote Users changing rules IS the correct use-case of drools (I would even say that if rules never change, drools is likely to be worse than pure java). What others said is changing the rules at each request by regenerating and recompiling is not. I can't imagine that

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Vincent LEGENDRE
At this point I'm designing for the worst case i.e., I'm assuming the rules with change with every request. Keeping a cache will work for the worst case, but will work faster for normal (see below) cases. You can imagine the user changing these rules in a span of less than a minute.

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Davide Sottara
If the structure of the constraints/filters the user can define remains static, and only the values are changing, then a single rule with parametric joins will be enough. E.g.: Params( $cat : categorySet, $minPrice : minPrice, $maxPrice : maxPrice, ) Product( category in $cat, price =

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
Vincent Legendre wrote At this point I'm designing for the worst case i.e., I'm assuming the rules with change with every request. Keeping a cache will work for the worst case, but will work faster for normal (see below) cases. I don't see how can a cache would work in the worse

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Wolfgang Laun
Merely filtering a subset of data items from a collection according to user's changing needs and whims is NOT the primary use case of a production rule system. This kind of problem has been solved adequately and efficiently by SQL queries or some similar DB query technique. It is true that such

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
laune wrote Merely filtering a subset of data items from a collection according to user's changing needs and whims is NOT the primary use case of a production rule system. This kind of problem has been solved adequately and efficiently by SQL queries or some similar DB query technique.

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Wolfgang Laun
On 9 May 2012 19:52, soumya_sd soumya...@yahoo.com wrote: laune wrote Merely filtering a subset of data items from a collection according to user's changing needs and whims is NOT the primary use case of a production rule system. This kind of problem has been solved adequately and

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
laune wrote On 9 May 2012 19:52, soumya_sd lt;soumya_sd@gt; wrote: laune wrote Merely filtering a subset of data items from a collection according to user's changing needs and whims is NOT the primary use case of a production rule system. This kind of problem has been solved

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
@ laune - so are you suggesting that I don't use Drools ? -- View this message in context: http://drools.46999.n3.nabble.com/Is-there-a-faster-way-of-doing-this-in-Drools-tp3973888p3974950.html Sent from the Drools: User forum mailing list archive at Nabble.com.

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread GPatel
so you are using drools to build on-the-fly queries based on user input. You could probably do this via static rules. Since you basically have 4 variables (price, avg_user_rating, num_ratings, category), you could write 4 rules, one each that filters based on one of the 4 variables and then

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Vincent LEGENDRE
I did not assume that I've seen all use cases, nor that what I am a telling is the absolute truth. See no offense in my previous post. Yes, I was supposing some use case of my own experience, but please note it is the first post when you describe what you are really trying to do, ie

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Vincent LEGENDRE
And I did not see all pending posts ... By reading them, there is another fact that lead to don't use drools. You said that you query a distant DB. So, if you write rules to filter your data, you will have first to get ALL data from your distant DB, add ALL data in the drools WM, and only then

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
Vincent Legendre wrote I did not assume that I've seen all use cases, nor that what I am a telling is the absolute truth. See no offense in my previous post. No offense taken at all. In fact, I would like to thank you for asking important questions. These questions help me validate my

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
Vincent Legendre wrote And I did not see all pending posts ... By reading them, there is another fact that lead to don't use drools. You said that you query a distant DB. So, if you write rules to filter your data, you will have first to get ALL data from your distant DB, add ALL data in

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Vincent LEGENDRE
... OR load everything into a WM and then apply these dynamic rules. Beware, I am not sure whether we can add/remove rules in an existing session (I don't think so but I may be wrong). Basically, a WM is built from a kBase, not the inverse ... So you will have to recompile rules, that re-add

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread soumya_sd
Vincent Legendre wrote ... OR load everything into a WM and then apply these dynamic rules. Beware, I am not sure whether we can add/remove rules in an existing session (I don't think so but I may be wrong). Basically, a WM is built from a kBase, not the inverse ... So you will have to

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Davide Sottara
@Vincent: it should indeed be possible to hot-plug rules directly into a knowledge BASE (meaning all sessions derived from that KB will be affected: existing facts will be matched against the new rules). More typically, this is done using a Knowledge Agent to manage the Knowledge Base. Whether

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Davide Sottara
@Vincent: it should indeed be possible to hot-plug rules directly into a knowledge BASE (meaning all sessions derived from that KB will be affected: existing facts will be matched against the new rules). More typically, this is done using a Knowledge Agent to manage the Knowledge Base. Whether

Re: [rules-users] Is there a faster way of doing this in Drools ?

2012-05-09 Thread Wolfgang Laun
You can compile Java by invoking javac from a Java program and load and execute the resulting class file. 1.7 has an API for calling the Java compiler. -W On 9 May 2012 20:21, soumya_sd soumya...@yahoo.com wrote: laune wrote On 9 May 2012 19:52, soumya_sd soumya_sd@ wrote: I didn't