[jboss-jira] [JBoss JIRA] (DROOLS-4898) Accumulates: min does not work after retracting fact.

Hiroko Miura (Jira) issues at jboss.org
Mon Jan 6 00:11:00 EST 2020


    [ https://issues.redhat.com/browse/DROOLS-4898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13941334#comment-13941334 ] 

Hiroko Miura commented on DROOLS-4898:
--------------------------------------

[~mfusco] Thank you for your clarification. I thought that retracting object of same type  is enough to re-evaluation of existing facts as  property 'longVal'  in this reproducer (which is compared in accumulate function)  is not changed.

> Accumulates: min does not work after retracting fact.
> -----------------------------------------------------
>
>                 Key: DROOLS-4898
>                 URL: https://issues.redhat.com/browse/DROOLS-4898
>             Project: Drools
>          Issue Type: Bug
>          Components: core engine
>    Affects Versions: 7.26.0.Final, 7.31.0.Final
>            Reporter: Hiroko Miura
>            Assignee: Mario Fusco
>            Priority: Major
>              Labels: support
>
> The following rules does not work with specific facts.
> {noformat}
> rule "rule1_long"
>     when
>         accumulate( Fact( $longVal: longVal), $minVal : min($longVal))
>         accumulate( Fact( $longVal2: longVal, $longVal2 > $minVal), $minVal2 : min($longVal2))
>         $minFact: Fact( longVal == $minVal)
>         $minFact2: Fact( longVal == $minVal2)
>     then
> 		System.out.println("Rule ["+kcontext.getRule().getName()+ "] fires!");        
> 		Long $diff = (Long)$minVal2 - (Long)$minVal;
> 		$minFact2.setDiff($diff);
> //		update($minFact2);
>  		String errmsg = $diff == 0?  " !!!!! ERROR !!!!!" : "";
> 		System.out.println( drools.getRule().getName() + " diff:" + $minFact2.getLongVal()  + " - " + $minFact.getLongVal() + " = " + $diff + errmsg);
> 		System.out.println("\tretract <= "+$minFact );
> 		retract($minFact);			
> end
> {noformat}
> There seems to be 2 kind of issues (root cause might be same though).
> - 2nd accumulate return same min value with 1st one. 
> - rule fire count is less than expected.
> This does not work with specific set of facts, but works with another set of facts.
> If update is called for the fact like above commented out line, this does not happen.



--
This message was sent by Atlassian Jira
(v7.13.8#713008)



More information about the jboss-jira mailing list