[jboss-jira] [JBoss JIRA] (DROOLS-747) declared window, type length(1), do actually contain more than 1 object (with reteoo)

Mario Fusco (JIRA) issues at jboss.org
Mon Aug 1 04:14:00 EDT 2016


     [ https://issues.jboss.org/browse/DROOLS-747?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mario Fusco closed DROOLS-747.
------------------------------
    Resolution: Out of Date


> declared window, type length(1), do actually contain more than 1 object (with reteoo)
> -------------------------------------------------------------------------------------
>
>                 Key: DROOLS-747
>                 URL: https://issues.jboss.org/browse/DROOLS-747
>             Project: Drools
>          Issue Type: Bug
>          Components: core engine
>    Affects Versions: 6.2.0.Final
>            Reporter: Matteo Mortari
>            Assignee: Mario Fusco
>         Attachments: 20150323.DROOLS-747-reproducer.zip
>
>
> h5. Premise
> I know reteoo is progressively being deprecated, but I think until is there is helpful for A/B testing of possible leaks comparing with phreak (like it happened during 610Final) so reporting this bug.
> h5. Executive summary
> Declaring a window of type length (1) should always contain 1 object.
> h5. Details
> With reference to attached reproducer.
> Given the following knowledge base:
> {code}
> global java.util.concurrent.atomic.AtomicLong globalCounter;
> declare Measurement
> 	@role(event)
> end
> declare window lastMeasurement
>     Measurement() over window:length( 1 )   // from entry-point DEFAULT
> end
> rule "IFF the last Measurement that I know of, is of ID color, increment the counter"
> no-loop
> when
> 	Measurement( id == "color" ) from window lastMeasurement
> then
> 	globalCounter.incrementAndGet();
> end
> {code}
> The goal is: IFF the last Measurement that I know of, is of ID "color", increment the counter. Please notice you ought to separate the window being just on Measurement, in order to know the last Measurement regardless of the ID, and then you have a rule acting on the declared window, to check IFF this last Measurement, is actually of ID "color".
> Now assuming you just have created the session and the following increment/insert/fire:
> {code}
> AtomicLong globalCounter = new AtomicLong(0);
> session.setGlobal("globalCounter", globalCounter);
> session.fireAllRules();
> assertEquals("no data, still 0", 0, globalCounter.get());
> LOG.info("Now running data");
> clock.advanceTime(1, TimeUnit.MINUTES);
> Measurement mRed= new Measurement("color", "red");
> session.insert(mRed);
> Measurement mGreen= new Measurement("color", "green");
> session.insert(mGreen);
> Measurement mBlue= new Measurement("color", "blue");
> session.insert(mBlue);
> session.fireAllRules();
> LOG.info("Final checks");
> assertEquals("win lenght =1 was: ", 1, globalCounter.get());
> {code}
> At the end you should have the global counter with value = 1, because we inserted 3 events of type Measurement, but the declared window lastMeasurement should reference only {{mBlue}}, which should be later picked by the rule because the ID is "color", and increment the counter by 1.
> This works with phreak, it does not work with reteo.
> phreak globalCounter = 1 : OK
> reteoo globalCounter = 3 : FAIL.
> Could you kindly advise, please?
> Thanks



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list