<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Drools does not have "groupBy", the
      rule you have written will react to each Product.<br>
      <br>
      You need something like:<br>
      <br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rule Acc<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; when<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; // get all Ids<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; accumulate( Product( $id : id ), $ids :
      collectSet( $id ) )&nbsp; <br>
      &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; // for each Id<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $idx : String() from $ids <br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // accumulate the Products<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; accumulate( Product( id == $idx, $p : price ),
      $sum : sum( $p ) ) <br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; then<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println( $idx + ' : ' + $sum ); <br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br>
      <br>
      This is to give you an idea, for example you could split the rule
      in two<br>
      or use helper facts<br>
      <br>
      <br>
      <br>
      On 03/03/2014 12:43 PM, Raja Sekhar wrote:<br>
    </div>
    <blockquote
cite="mid:CAJhvg6_Tk1cYKURv0LJNC1WKR7uA5+SKGntKBCA8BYKBzyWukA@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi&nbsp;<span
          style="font-family:arial,sans-serif;font-size:13px">Davide,</span>
        <div><span style="font-family:arial,sans-serif;font-size:13px">I
            am trying to group by Hild. Here first i will get the hlld
            into id and segregate the results by hild and sum the value
            t1</span></div>
        <div><span style="font-family:arial,sans-serif;font-size:13px">If
            you take an sql&nbsp;</span></div>
        <div><span style="font-family:arial,sans-serif;font-size:13px">select
            sum(t1),hlid from product group by hild</span></div>
        <div>
          <span style="font-family:arial,sans-serif;font-size:13px">so i
            will get</span></div>
        <div><span style="font-family:arial,sans-serif;font-size:13px">if
            the data is&nbsp;</span></div>
        <div><span style="font-family:arial,sans-serif;font-size:13px">hlid
            t1</span></div>
        <div><span style="font-family:arial,sans-serif;font-size:13px">1
            &nbsp; &nbsp;10&nbsp;</span></div>
        <div><span style="font-family:arial,sans-serif;font-size:13px">1
            &nbsp; &nbsp;10</span></div>
        <div><span style="font-family:arial,sans-serif;font-size:13px">2
            &nbsp; 10</span></div>
        <div><span style="font-family:arial,sans-serif;font-size:13px">2
            &nbsp; 10</span></div>
        <div><font face="arial, sans-serif">the result would be</font></div>
        <div><font face="arial, sans-serif">hiid t1</font></div>
        <div><font face="arial, sans-serif">1 &nbsp; 20</font></div>
        <div><font face="arial, sans-serif">2 &nbsp; 20</font></div>
        <div><font face="arial, sans-serif">Hope you understand what i
            am trying to do here</font></div>
        <div><font face="arial, sans-serif"><br>
          </font></div>
        <div><font face="arial, sans-serif">Regards,</font></div>
        <div><font face="arial, sans-serif">Raja</font></div>
        <div><font face="arial, sans-serif"><br>
          </font></div>
        <div><font face="arial, sans-serif">Regards,</font></div>
        <div><font face="arial, sans-serif">Raja</font></div>
        <div>
          <span style="font-family:arial,sans-serif;font-size:13px"><br>
          </span></div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On 3 March 2014 17:05, Davide Sottara <span
            dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:dsotty@gmail.com" target="_blank">dsotty@gmail.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>Raja,<br>
                it is not clear what you are trying to achieve.<br>
                <br>
                The rule might be well written or not, we don't know
                your requirements.<br>
                If "id" is what it should be - an identifier - your
                accumulate constraint<br>
                would match a single object for each Product (the
                original product itself),<br>
                which looks suspicious.<br>
                <br>
                I'll assume that you are doing a performance test and
                you are not satisfied<br>
                with the overall execution time.<br>
                The question, however, is: how many facts are you
                inserting? Are you firing<br>
                all rules after the insertion of each fact, or just once
                at the end?<br>
                Last, but not least, which version are you using?<br>
                <br>
                Accumulate should be used carefully in combination with
                insertLogical,<br>
                since the former updates its result every time its fact
                collection changes.<br>
                The latter will generate a new fact, keep track of its
                dependencies,<br>
                and replace it when the accumulation result itself
                changes.<br>
                <br>
                Of course, if you were inserting 100 facts, the numbers
                would raise<br>
                a warning, but could be reasonable for several
                thousands, if not<br>
                hundred thousands. Citing one of your previous emails:<br>
                "I want to test my rules with 10,000 facts to 20,000,000
                facts"<br>
                <br>
                Best<br>
                Davide
                <div>
                  <div class="h5"><br>
                    <br>
                    <br>
                    On 03/03/2014 12:10 PM, Raja Sekhar wrote:<br>
                  </div>
                </div>
              </div>
              <blockquote type="cite">
                <div>
                  <div class="h5">
                    <div dir="ltr">Hi,
                      <div>I am using the following rule</div>
                      <div>
                        <div>package com.demo;</div>
                        <div>import com.sample.model.Product;</div>
                        <div>import com.sample.model.Products;</div>
                        <div>import java.util.List;</div>
                        <div>import java.util.Set;</div>
                        <div>dialect "mvel"</div>
                        <div><br>
                        </div>
                        <div>rule "Product_0"</div>
                        <div>no-loop</div>
                        <div>when</div>
                        <div><span style="white-space:pre-wrap"> </span>Product(id:

                          hlId) <span style="white-space:pre-wrap"> </span>accumulate

                          (e :Product(hlId == id), <span
                            style="white-space:pre-wrap"> </span>$sum1
                          : sum(e.t1) )&nbsp;</div>
                        <div>then</div>
                        <div>&nbsp;insertLogical("hid=" + id +",T1=" +
                          $sum1);</div>
                        <div>end</div>
                        <div><br>
                        </div>
                        <div>I am inserting facts (Product objects) into
                          it and firing the rules.</div>
                        <div>When i took performance stats from visual
                          vm with JMX. got a time of 3832ms. I can you
                          suggest if i am doing any thing wrong with
                          this.</div>
                        <div><br>
                        </div>
                        <div>Regards,</div>
                        <div>Raja Sekhar&nbsp;</div>
                        <div><br>
                        </div>
                        -- <br>
                        <div dir="ltr">Raja Sekhar Amirapu<br>
                          ------------------------------------------------------

                          <div>"If any anyone can do it, i can do it. If
                            no one else can do it, i must do it"<br>
                          </div>
                        </div>
                      </div>
                    </div>
                    <br>
                    <fieldset></fieldset>
                    <br>
                  </div>
                </div>
                <pre>_______________________________________________
rules-users mailing list
<a moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></pre>
              </blockquote>
              <br>
            </div>
            <br>
            _______________________________________________<br>
            rules-users mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
            <a moz-do-not-send="true"
              href="https://lists.jboss.org/mailman/listinfo/rules-users"
              target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <div dir="ltr">Raja Sekhar Amirapu<br>
          ------------------------------------------------------
          <div>"If any anyone can do it, i can do it. If no one else can
            do it, i must do it"<br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></pre>
    </blockquote>
    <br>
  </body>
</html>