[rules-users] Is there a faster way of doing this in Drools ?
Davide Sottara
dsotty at gmail.com
Wed May 9 13:26:37 EDT 2012
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 >= $minPrice && <= $maxPrice, num_ratings
... )
You'd then have to update the "Params" according to what the user e.g.
selects from a checkbox.
A "null" selection would then be converted e.g. categorySet = all
categories, minPrice = -infinity, maxPrice = +infinity etc...
If, on the other hand, the user is completely free to create their own
rules, this strategy may not be applicable. Wouldn't then the bottleneck be
the user writing/picking the rules (seconds) rather than their compilation
(a few milliseconds)? If so, you might have "horizontal" scalability issues
- allowing more and more users to do this - rather than "vertical" ones -
responding faster to a single user.
If, instead, the criteria are built automatically by a software agent of
some sort, then the direct creation might be taken into consideration. You
can skip the parsing step by creating the Abstract Syntax Tree directly -
the compiler APIs ("Descrs") have a nice fluent structure.
Davide
btw, what are your rules supposed to do as a consequence? Do you have
chaining? or actions?
If all you need is selection and filtering, I wonder if a production rule
system is the best option
for your application, or at least this sub-module...
--
View this message in context: http://drools.46999.n3.nabble.com/Is-there-a-faster-way-of-doing-this-in-Drools-tp3973888p3974782.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list