<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I think you have to follow the structure of accumulate function. Like
<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<b><i><span style="font-size:10.5pt;font-family:"Courier New";color:black;border:none windowtext 1.0pt;padding:0in"><result pattern></span></i></b><span style="font-size:11.0pt;font-family:"Courier New";color:black"> from accumulate(
</span><b><i><span style="font-size:10.5pt;font-family:"Courier New";color:black;border:none windowtext 1.0pt;padding:0in"><source pattern></span></i></b><span style="font-size:11.0pt;font-family:"Courier New";color:black">,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"> init(
</span><b><i><span style="font-size:10.5pt;font-family:"Courier New";color:black;border:none windowtext 1.0pt;padding:0in"><init code></span></i></b><span style="font-size:11.0pt;font-family:"Courier New";color:black"> ),<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"> action(
</span><b><i><span style="font-size:10.5pt;font-family:"Courier New";color:black;border:none windowtext 1.0pt;padding:0in"><action code></span></i></b><span style="font-size:11.0pt;font-family:"Courier New";color:black"> ),<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"> reverse(
</span><b><i><span style="font-size:10.5pt;font-family:"Courier New";color:black;border:none windowtext 1.0pt;padding:0in"><reverse code></span></i></b><span style="font-size:11.0pt;font-family:"Courier New";color:black"> ), (optional)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"> result(
</span><b><i><span style="font-size:10.5pt;font-family:"Courier New";color:black;border:none windowtext 1.0pt;padding:0in"><result expression></span></i></b><span style="font-size:11.0pt;font-family:"Courier New";color:black"> ) )<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black">examples are:<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:#0070C0">when<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:#0070C0"> $order : Order()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:#0070C0"> $total : Number( doubleValue > 100 )
<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:#0070C0"> from accumulate( OrderItem( order == $order, $value : value ),<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:#0070C0"> init( double total = 0; ),<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:#0070C0"> action( total += $value; ),<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:#0070C0"> result( total ) )<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:#0070C0">then<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:#0070C0"> # apply discount to $order<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:#0070C0">end<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black">As I understand from your code,
<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;line-height:13.65pt;mso-list:l0 level1 lfo1;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman"">
</span></span></span><span style="font-size:11.0pt;font-family:"Courier New";color:black">Make List for Event class, because accumulate will loop through the elements of List<Event><o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;line-height:13.65pt;mso-list:l0 level1 lfo1;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"><span style="mso-list:Ignore">2.<span style="font:7.0pt "Times New Roman"">
</span></span></span><span style="font-size:11.0pt;font-family:"Courier New";color:black">Init (write action codes, i.e. initialize value so you will find how many time it got looped)<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;line-height:13.65pt;mso-list:l0 level1 lfo1;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"><span style="mso-list:Ignore">3.<span style="font:7.0pt "Times New Roman"">
</span></span></span><span style="font-size:11.0pt;font-family:"Courier New";color:black">Write code inside the block of action(//code here) and
<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;line-height:13.65pt;mso-list:l0 level1 lfo1;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"><span style="mso-list:Ignore">4.<span style="font:7.0pt "Times New Roman"">
</span></span></span><span style="font-size:11.0pt;font-family:"Courier New";color:black">Update it in result block i.e. result(//update here);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black">Being said, follow the structure 1) init, 2) action, 3) result as above..<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:13.65pt;background:whitesmoke;vertical-align:baseline">
<span style="font-size:11.0pt;font-family:"Courier New";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Sandhya Sree [via Drools] [mailto:ml-node+<a href="/user/SendEmail.jtp?type=node&node=4028640&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>]
<br>
<b>Sent:</b> Tuesday, March 11, 2014 1:51 PM<br>
<b>To:</b> Gopu Shrestha<br>
<b>Subject:</b> [rules-users] sliding window problem<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;line-height:13.35pt;vertical-align:baseline">
<span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:black">i have a class called Event which has the following members { name, source, timestamp } with getters ,setters and constructor. i have a rule file which creates Event objects whenever
a file is added / deleted in a particular folder. the rule file is as follows<o:p></o:p></span></p>
<pre style="margin-bottom:7.5pt;line-height:13.35pt;background:#EEEEEE;vertical-align:baseline;max-height:600px;word-wrap:normal;overflow:auto"><span style="font-size:10.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">rule "new file"<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">when<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">$p: RuleContext( $old : getOldContext().getContainedFiles(), $new :getNewContext().getContainedFiles())<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">RuleContext( $old != $new)<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">accumulate( $s : Object( this not memberOf $old ) from $new, $plus : collectList( $s ) ) <o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">events : Object() from $plus;<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">then<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">Event event = new Event("new file added",$p.getOldContext().getParent(),new Date());<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">end<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in"><o:p> </o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in"><o:p> </o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">rule " file deleted"<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">when<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">$p: RuleContext( $old : getOldContext().getContainedFiles(), $new:getNewContext().getContainedFiles())<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">RuleContext( $old != $new)<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">accumulate( $t : Object( this not memberOf $new ) from $old, $mins : collectList( $t ) )<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">events : Object() from $mins; <o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">then<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">Event event = new Event("file deleted",$p.getOldContext().getParent(),new Date());<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">end <o:p></o:p></span></code></pre>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;line-height:13.35pt;vertical-align:baseline">
<span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:black">(do not confuse with RuleContext and other unknown identifiers.. they r just related with other classes in the project.. these two rules just works fine )..i need to use a sliding time
window and create another event if the number of file additions are > 5 over the past 1 minute. my rule file is :<o:p></o:p></span></p>
<pre style="margin-bottom:7.5pt;line-height:13.35pt;background:#EEEEEE;vertical-align:baseline;max-height:600px;word-wrap:normal;overflow:auto"><span style="font-size:10.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">declare Event <o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">@role( event ) <o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">end <o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in"><o:p> </o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in"><o:p> </o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">rule "More than 5 additions"<o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">when <o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">Number(intValue > 5) <o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">from accumulate( $tick : Event ( name == "new file added" ) over window:time( 1m ),</span></code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in"><br><code><span style="font-family:Consolas"> count( $tick ) ) )<o:p></o:p></span></code></span></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">then <o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in"> System.out.println("too many additions"); <o:p></o:p></span></code></pre>
<pre style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline"><code><span style="font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">end <o:p></o:p></span></code></pre>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;line-height:13.35pt;vertical-align:baseline">
<span style="font-size:10.5pt;font-family:"Arial","sans-serif";color:black">i have enabled stream mode processing too.. but it doesnt seem to work. what could be the problem?<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________ <br>
rules-users mailing list <br>
<a href="/user/SendEmail.jtp?type=node&node=4028639&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>
<br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_top" rel="nofollow" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a>
<o:p></o:p></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="1" width="100%" noshade="" style="color:#CCCCCC" align="center">
</div>
<div>
<div>
<p class="MsoNormal"><b><span style="font-size:9.0pt;font-family:"Tahoma","sans-serif";color:#444444">If you reply to this email, your message will be added to the discussion below:<o:p></o:p></span></b></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Tahoma","sans-serif";color:#444444"><a href="http://drools.46999.n3.nabble.com/rules-users-sliding-window-problem-tp4028639.html" target="_top" rel="nofollow" link="external">http://drools.46999.n3.nabble.com/rules-users-sliding-window-problem-tp4028639.html</a>
<o:p></o:p></span></p>
</div>
<div style="margin-top:4.8pt">
<p class="MsoNormal" style="line-height:18.0pt"><span style="font-size:8.5pt;font-family:"Tahoma","sans-serif";color:#666666">To start a new topic under Drools: User forum, email
<a href="/user/SendEmail.jtp?type=node&node=4028640&i=1" target="_top" rel="nofollow" link="external">[hidden email]</a>
<br>
To unsubscribe from Drools, <a href="" target="_top" rel="nofollow" link="external">
click here</a>.<br>
<a href="http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" target="_top" rel="nofollow" link="external"><span style="font-size:7.0pt;font-family:"Times New Roman","serif"">NAML</span></a>
<o:p></o:p></span></p>
</div>
</div>
        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://drools.46999.n3.nabble.com/RE-rules-users-sliding-window-problem-tp4028640.html">RE: [rules-users] sliding window problem</a><br/>
Sent from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html">Drools: User forum mailing list archive</a> at Nabble.com.<br/>