<div>What do you guys think of this: my facts are all the same type, so I didn't have anything like a consumer object to break things down with. But what I did was:</div>
<div> </div>
<div>rule "group 1"<br>when<br> $a : Trans( $groupValue : prodCat, $date : date )<br> not Trans( this != $a, prodCat == $groupValue, date < $date )<br> $b : LinkedList( size >= 1 ) from collect ( Trans( this != $a, prodCat == $groupValue, date > $date ) )<br>
then<br> //do something<br>end</div>
<div> </div>
<div>This is quite quick. The rule grabs all the Trans objects that have the same prodCat, in a single firing, without the need to iteractively retract things or fire multiple times for the same group value. As the first condition only matches a single fact (the one with the oldest date), there is only ever a single permutation that can fulfill the conditions.</div>
<div> </div>
<div>This is only aggregating on a single attribute, but the principal should work with more.</div>
<div> </div>
<div><br> </div>
<div class="gmail_quote">On 18 October 2010 16:12, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Doing <a href="http://s.th/" target="_blank">s.th</a>. like<br> $t1 : Trans( $id : id, $pc : pc, $tt : tt )<br>
$t2 : Trans( this != $t1, id == $id, pc == $pc, tt < ($tt + 3600) )<br>is bound to produce poor performanc.<br><br>Divide and conquer!<br><br>You might start with a Consumer record<br> Consumer( $id : id )<br> $t1 : Trans( id == $id: , $pc : pc, $tt : tt )<br>
$t2 : Trans( this != $t1, id == $id, pc == $pc, tt < ($tt + 3600) )<br><br>You might run an (external) sort on the Transaction records and<br>process it in batches of identical id+pc.<br><br>If transaction times don't go around the clock, you might sort by<br>
date, and process day by day.<br><br>You may have to create a Domain Specific Language for the<br>non-programmers, putting a firm rein on how they combine the basic<br>facts. Processing large batches is bound to require skills they just<br>
dont have.<br><font color="#888888"><br>-W<br></font>
<div>
<div></div>
<div><br><br>On 18 October 2010 16:14, Greg Barton <<a href="mailto:greg_barton@yahoo.com" target="_blank">greg_barton@yahoo.com</a>> wrote:<br>> It would be nice if we had an example of some rules. That way we can rule out obvious performance killers like cartesian products and multiple "from" clauses in one rule.<br>
><br>> GreG<br>><br>> On Oct 18, 2010, at 5:19, Tim 4076 <<a href="mailto:tm4076@gmail.com" target="_blank">tm4076@gmail.com</a>> wrote:<br>><br>> Hi,<br>> I'm trying to use drools to do grouping of data according to patterns defined in my rules, but I'm having issues creating something that works in a reasonable amount of time (seconds). I've tried all sorts of permutations without much luck and would like to hear how others would do the same thing.<br>
><br>> To give an example: I've got a big batch of transaction records and I want to aggregate all the records where the consumer id and product category are the same and the purchases were made within an hour of each other.<br>
><br>> The fact that its matching the same values between facts, rather than against constants seems to scupper it somewhat.<br>><br>> I would go down the ETL route, but the idea is for non-techies to define their own aggregations using rules.<br>
><br>> -Cheers. Tim<br>><br>><br>> _______________________________________________<br>> rules-users mailing list<br>> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>><br>><br>><br>><br>> _______________________________________________<br>
> rules-users mailing list<br>> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>