[rules-users] Question about collect and sliding windows

Wolfgang Laun wolfgang.laun at gmail.com
Wed Dec 1 10:27:38 EST 2010


A sliding window requires the use of STREAM mode, and you must use a
session clock, pseudo or real-time.

I'm also a worried about "size==80"; shouldn't you use "size >= 80"?
But this depends on the way you run the session; are you doing this
with fireUntilHalt in a separate thread?

It shouldn't be a problem if the session is run with a real-time clock and
delayed events (with the timestamp in the data, as you apparently have)
arrive and are inserted. Docs say that that this is OK, as long as events
are inserted in each entry-point in chronological order. If there are
different streams, each with individual delays, you may have to use
multiple entry-points.


On 1 December 2010 16:10, Anais Martinez <amartinez at iti.upv.es> wrote:

>
> Hello. I have two questions about collect and sliding windows. I have
> created
> this rule:
>
> rule "Active risk"
> when
>  $n:Node()
>  $readings: ArrayList(size==80)  from collect(
>   Reading( nodeID == $n.nodeID,
>    (signalType == SignalType.PLUVIOSITY && value >= 10)||
>    (signalType == SignalType.AIR_TEMPERATURE && value>=12)
>   ) over window:time(10h))
> then
>  System.out.println("Active risk in node "+ $n.getNodeID());
> end
>
> And the declarations are the following (Reading and Node are java classes):
>
> declare Reading
>        @role(event)
>        @timestamp (timestamp)
> end
>
> declare Node
>        @role(fact)
> end
>
>
> Well, I have probe the rule. I have inserted 100 readings which satisfy the
> conditions, in a single time but with different timestamp (I have simulated
> that there are a pluviosity reading and a air_temperature reading each 15
> minutes), that is, in main:
>
> long init= 1290729600000L;
> long interval = 1000*60*15;
> for (int i=0; i<100; i++){
>        long fecha = init+i*interval;
>        Reading r1 = new Reading(SignalType.PLUVIOSITY, value1, node);
>        session.insert(r1);
>
>        Reading r2 = new Reading(SignalType.AIR_TEMPERATURE, value1, node);
>        session.insert(r2);
> }
>
> The message is not written (I have fired rules after insertions).
>
> My questions:
> Has drools any problem if I inserted all readings at same time? (Do I have
> to use the pseudo-clock?)
> My problem is that the readings will be sent from a server in real system,
> and it's possible that the server will send all readings belonging to an
> interval of one/two hour/s at same time.
>
> Thanks.
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Question-about-collect-and-sliding-windows-tp1999562p1999562.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101201/4518299c/attachment.html 


More information about the rules-users mailing list