[jboss-jira] [JBoss JIRA] (DROOLS-694) accumulate with sliding window and other LHS condition

Matteo Mortari (JIRA) issues at jboss.org
Wed Jan 21 04:42:49 EST 2015


Matteo Mortari created DROOLS-694:
-------------------------------------

             Summary: accumulate with sliding window and other LHS condition
                 Key: DROOLS-694
                 URL: https://issues.jboss.org/browse/DROOLS-694
             Project: Drools
          Issue Type: Bug
    Affects Versions: 6.2.0.CR4, 6.1.0.Final
         Environment: fail with PHREAK, work correctly as expected with RETEOO
            Reporter: Matteo Mortari
            Assignee: Mark Proctor


With reference to attached reproducer.

Assuming the following KB, where to goal is to keep a {{Counter}} fact for the amount of {{Measurement}} events received in the last hour.
{code:java}
declare Measurement
	@role(event)
end

rule "Init Counter last 1h"
agenda-group "USERSPACE"
salience 1
no-loop
when
	not Counter( name == "Counter last 1h" )
then
	Counter c = new Counter("Counter last 1h", 0);
	insert(c);
	System.out.println("RHS Init Counter last 1h " + c);
end

rule "Update Counter last 1h"
agenda-group "USERSPACE"
no-loop
when
	accumulate( $token : Measurement() over window:time( 1h ) ;
 				$val : count($token)
 			   )
 	$cv1 : Counter( name == "Counter last 1h", value != $val.doubleValue() )
then
	int count = $val.intValue();
	$cv1.setValue(count);
	update($cv1);
	System.out.println("RHS Update Counter last 1h : "+$cv1);
end
{code}

The following Unit test shall have the effect in the end to obtain value 2.0 in the {{Counter}} object, as I've inserted 2 {{MEasurement}} within the last hour and within two minutes
{code:java}
advance(clock, 1, TimeUnit.MINUTES);
insert(session, new Measurement("voltage", "220"));
fire(session);

advance(clock, 1, TimeUnit.MINUTES);
insert(session, new Measurement("voltage", "221"));
fire(session);

LOG.info("Final checks");
Counter counter = (Counter) session.getObjects(counterFilter).iterator().next();         // I'm taking a shortcut as for this reproducer I know there is only 1 Counter in WM
assertEquals("I've inserted 2 Measurement within the hour ", 2, counter.getValue(), 0);
{code}

However this works only with ReteOO and the test FAILS with Phreak.

Can you kindly advise, please?
Thank you
MM



--
This message was sent by Atlassian JIRA
(v6.3.11#6341)


More information about the jboss-jira mailing list