<br>   Chris,<br><br>   I am glad you asked these questions, because I am looking for feedback on the approaches we are using. <br>   <br>   So, first thing to understand is: sliding windows AND memory management are only active when the processing mode is set to STREAM. There is no memory management or support to sliding windows in CLOUD mode as this would not make sense.<br>
<br>   Assuming the engine is set to STREAM mode, it will use 2 sources of information to calculate the expiration time for each event type: the @expiration policy and temporal constraints. @expiration is explicit and obvious. For temporal constraints, the calculation is quite complex, so let me show the simplest possible example: imagine a rule:<br>
<br>when<br>   $a : A()<br>   $b : B( this after[1s,30s] $a )<br>then<br>end<br><br>    In the above example, it is obvious that any A() must wait at least 30s for eventual B()s. B()s on the other hand will either match immediately or will never match. So, the expiration offset for A will be 30s and for B will be 0 (zero). Now the engine will calculate the offset based on all temporal constraints from all rules and (simplistically speaking) take the max between the value calculated and the @expiration policy if it exists as long as the max is not infinite. Any object type for which there are no explicit expiration policy, nor temporal constraints from which to derive the expiration offset will have an infinite expiration offset, i.e., will never be automatically retracted.<br>
<br>   So, length sliding windows, that was what you asked about, as it is today, will not hold the object beyond its expiration offset. Maybe we should, maybe not... I am open to arguments on that field.<br><br>    Feedback and arguments welcome.<br>
<br>    []s<br>    Edson<br><br>   <br><br><div class="gmail_quote">2009/6/12 Chris Richmond <span dir="ltr">&lt;<a href="mailto:crichmond@referentia.com">crichmond@referentia.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">









<div link="blue" vlink="purple" lang="EN-US">

<div>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Hello,</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">I wanted to ask this question in a separate email so as to
keep each email to one topic for easier thread following.  Let me know if
you prefer multiple questions per email next time.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"><br>
I am using Drools fusion basically with some success where I am at this point
only running some aggregates and calling some java functions when a running
average over the last 1 minute or so drops below a certain value.   </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">The sources for those values come from objects I am
injecting into memory space, but I am not specifically calling retraction code since
it is my understanding that I can set the policy in the rule file for how long
to hold objects in memory.  So for example I have this rule which simpoly
outputs to out when the average goes above 100 for the last 10 items(you can
tell I created mine based on the stock ticker).  It seems to be working,
but I have some questions to ensure I understand before moving forward.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">So below the “declare MyObject” with assigning
it role event with a default expiration of 2 minutes.  Is my undertanding
correct that fusion will disregard thos objects that are injected without me
having to take any other action?  </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Also, in my “show averages” rule below, if I did
ont have the “declare MyObject” delcaration with expiration policy
set, would fusion automatially throw away MyObjects older than the last 10  based
on my rule no longer needing them?    If it would, then which
takes priority, the expires declaration for MyObject or the no longer needed by
my aggregate rule below.  I am assuming that the rule would keep them
beyond 2 minutes it it was necessary, but is this correct?  If the rule as
written would not automatically remove objects from memory space, then is there
something I could do to tell the rule to do so when it is no longer needed by
my aggregate?</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Thanks,</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"><br>
Chris</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">&lt;imports removed&gt;</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"># default dialect for the semantic code will be MVEL</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">dialect &quot;mvel&quot;</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"># tells the engine that a object instance will
assume the</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"># role (semantics) of events and that the default
retention </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"># policy will be 2 minutes </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">declare MyObject</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">    @role( event )</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">    @expires( 2m )</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">end </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">rule &quot;show averages&quot;</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">when</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">      $n : Number( doubleValue
&gt; 100 ) from accumulate (</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">            </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">      </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">            $stat:MyObject($bc:
byteCount, srcIPAddress == &quot;10.5.0.4&quot;) over window:length(10) from
entry-point &quot;MyObject stream&quot;,</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">            average(
$bc )</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">            </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">        ) </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">        </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">        </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">then</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">    System.err.println(&quot;average:
&quot; + $n)</span></font></p>

<p><font size="2" face="Courier New"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">end </span></font></p>

</div>

</div>


<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">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></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>