[rules-users] Question about collect and sliding windows

Anais Martinez amartinez at iti.upv.es
Wed Dec 1 10:10:34 EST 2010


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.



More information about the rules-users mailing list