<div>What do you guys think of this: my facts are all the same type, so I didn&#39;t have anything like a consumer object to break things down with. But what I did was:</div>
<div> </div>
<div>rule &quot;group 1&quot;<br>when<br>  $a : Trans( $groupValue : prodCat, $date : date )<br>  not Trans( this != $a, prodCat == $groupValue, date &lt; $date )<br>  $b : LinkedList( size &gt;= 1 ) from collect ( Trans( this != $a, prodCat == $groupValue, date &gt; $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">&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</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 &lt; ($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 &lt; ($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&#39;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 &lt;<a href="mailto:greg_barton@yahoo.com" target="_blank">greg_barton@yahoo.com</a>&gt; wrote:<br>&gt; 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 &quot;from&quot; clauses in one rule.<br>
&gt;<br>&gt; GreG<br>&gt;<br>&gt; On Oct 18, 2010, at 5:19, Tim 4076 &lt;<a href="mailto:tm4076@gmail.com" target="_blank">tm4076@gmail.com</a>&gt; wrote:<br>&gt;<br>&gt; Hi,<br>&gt; I&#39;m trying to use drools to do grouping of data according to patterns defined in my rules, but I&#39;m having issues creating something that works in a reasonable amount of time (seconds). I&#39;ve tried all sorts of permutations without much luck and would like to hear how others would do the same thing.<br>
&gt;<br>&gt; To give an example: I&#39;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>
&gt;<br>&gt; The fact that its matching the same values between facts, rather than against constants seems to scupper it somewhat.<br>&gt;<br>&gt; I would go down the ETL route, but the idea is for non-techies to define their own aggregations using rules.<br>
&gt;<br>&gt; -Cheers. Tim<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; rules-users mailing list<br>&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<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>