[jboss-jira] [JBoss JIRA] (DROOLS-4632) Optimize single pattern forall statement

Mario Fusco (Jira) issues at jboss.org
Thu Oct 10 05:15:00 EDT 2019


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

Mario Fusco resolved DROOLS-4632.
---------------------------------
    Resolution: Done


Fixed by https://github.com/kiegroup/drools/commit/21c612aee9fa0d5bc593af941f438b50a764a65f

> Optimize single pattern forall statement
> ----------------------------------------
>
>                 Key: DROOLS-4632
>                 URL: https://issues.jboss.org/browse/DROOLS-4632
>             Project: Drools
>          Issue Type: Enhancement
>            Reporter: Mario Fusco
>            Assignee: Mario Fusco
>            Priority: Major
>
> At the moment a single pattern forall statement like
> {code}
> forall( Type( constraints ) )
> {code}
> it is automatically rewritten as
> {code}
> forall( $t : Type() Type( this == $t, constraints ) )
> {code}
> and then implemented with 2 not nodes and join.
> {code}
> [EntryPointNode(1) EntryPoint::DEFAULT ] on Partition(MAIN)
>     [ObjectTypeNode(4)::EntryPoint::DEFAULT objectType=[ClassObjectType class=org.drools.testcoverage.common.model.Person] expiration=-1ms ] on Partition(MAIN)
>         [JoinNode(5) - [ClassObjectType class=org.drools.testcoverage.common.model.Person]] on Partition(1) Ld -1 Li -1 Rd 0 Ri 0
>             [NotNode(7) - [ClassObjectType class=org.drools.testcoverage.common.model.Person]] on Partition(1) Ld -1 Li -1 Rd 9223372036854775807 Ri 9223372036854775807
>                 RightInputAdapterNode(8)[ tupleMemoryEnabled=true, tupleSource=[NotNode(7) - [ClassObjectType class=org.drools.testcoverage.common.model.Person]], source=null, associations={[Rule name=R1, agendaGroup=MAIN, salience=0, no-loop=false]=1}, partitionId=Partition(1)] on Partition(1)
>                     [NotNode(9) - <source from a subnetwork>] on Partition(1) Ld 0 Li 0 Rd -1 Ri -1
>                         [RuleTerminalNode(10): rule=R1] on Partition(1) d -1 i -1
>         [AlphaNode(6) constraint=!(age >= 18) || !(name.startsWith("M"))] on Partition(1) d 2056 i 9223372036854775807
>             [NotNode(7) - [ClassObjectType class=org.drools.testcoverage.common.model.Person]] on Partition(1) Ld -1 Li -1 Rd 9223372036854775807 Ri 9223372036854775807
>     [ObjectTypeNode(2)::EntryPoint::DEFAULT objectType=[ClassObjectType class=org.drools.core.reteoo.InitialFactImpl] expiration=-1ms ] on Partition(MAIN)
>         [LeftInputAdapterNode(3)] on Partition(1) Ld 0 Li 0
>             [JoinNode(5) - [ClassObjectType class=org.drools.testcoverage.common.model.Person]] on Partition(1) Ld -1 Li -1 Rd 0 Ri 0
>             [NotNode(9) - <source from a subnetwork>] on Partition(1) Ld 0 Li 0 Rd -1 Ri -1
> {code}
> It would be much faster to rewrite it as
> {code}
> not( Type( !constraints ) )
> {code}
> and then evaluate it with one single not node.
> {code}
> [EntryPointNode(1) EntryPoint::DEFAULT ] on Partition(MAIN)
>     [ObjectTypeNode(4)::EntryPoint::DEFAULT objectType=[ClassObjectType class=org.drools.testcoverage.common.model.Person] expiration=-1ms ] on Partition(MAIN)
>         [AlphaNode(5) constraint=!(age >= 18) || !(name.startsWith("M"))] on Partition(1) d 2056 i 2056
>             [NotNode(6) - [ClassObjectType class=org.drools.testcoverage.common.model.Person]] on Partition(1) Ld -1 Li -1 Rd 0 Ri 2056
>                 [RuleTerminalNode(7): rule=R1] on Partition(1) d -1 i -1
>     [ObjectTypeNode(2)::EntryPoint::DEFAULT objectType=[ClassObjectType class=org.drools.core.reteoo.InitialFactImpl] expiration=-1ms ] on Partition(MAIN)
>         [LeftInputAdapterNode(3)] on Partition(1) Ld 0 Li 0
>             [NotNode(6) - [ClassObjectType class=org.drools.testcoverage.common.model.Person]] on Partition(1) Ld -1 Li -1 Rd 0 Ri 2056
> {code}



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


More information about the jboss-jira mailing list